Interface UserAdmin
-
public interface UserAdminThis interface is used to manage a database of namedRoleobjects, which can be used for authentication and authorization purposes.This version of the User Admin service defines two types of
Roleobjects: "User" and "Group". Each type of role is represented by anintconstant and an interface. The range of positive integers is reserved for new types of roles that may be added in the future. When defining proprietary role types, negative constant values must be used.Every role has a name and a type.
A
Userobject can be configured with credentials (e.g., a password) and properties (e.g., a street address, phone number, etc.).A
Groupobject represents an aggregation ofUserandGroupobjects. In other words, the members of aGroupobject are roles themselves.Every User Admin service manages and maintains its own namespace of
Roleobjects, in which eachRoleobject has a unique name.
-
-
Method Summary
All Methods Instance Methods Abstract Methods Modifier and Type Method Description RolecreateRole(java.lang.String name, int type)Creates aRoleobject with the given name and of the given type.AuthorizationgetAuthorization(User user)Creates anAuthorizationobject that encapsulates the specifiedUserobject and theRoleobjects it possesses.RolegetRole(java.lang.String name)Gets theRoleobject with the givennamefrom this User Admin service.Role[]getRoles(java.lang.String filter)Gets theRoleobjects managed by this User Admin service that have properties matching the specified LDAP filter criteria.UsergetUser(java.lang.String key, java.lang.String value)Gets the user with the given propertykey-valuepair from the User Admin service database.booleanremoveRole(java.lang.String name)Removes theRoleobject with the given name from this User Admin service and all groups it is a member of.
-
-
-
Method Detail
-
createRole
Role createRole(java.lang.String name, int type)
Creates aRoleobject with the given name and of the given type.If a
Roleobject was created, aUserAdminEventobject of typeUserAdminEvent.ROLE_CREATEDis broadcast to anyUserAdminListenerobject.- Parameters:
name- Thenameof theRoleobject to create.type- The type of theRoleobject to create. Must be either aRole.USERtype orRole.GROUPtype.- Returns:
- The newly created
Roleobject, ornullif a role with the given name already exists. - Throws:
java.lang.IllegalArgumentException- iftypeis invalid.java.lang.SecurityException- If a security manager exists and the caller does not have theUserAdminPermissionwith nameadmin.
-
removeRole
boolean removeRole(java.lang.String name)
Removes theRoleobject with the given name from this User Admin service and all groups it is a member of.If the
Roleobject was removed, aUserAdminEventobject of typeUserAdminEvent.ROLE_REMOVEDis broadcast to anyUserAdminListenerobject.- Parameters:
name- The name of theRoleobject to remove.- Returns:
trueIf aRoleobject with the given name is present in this User Admin service and could be removed, otherwisefalse.- Throws:
java.lang.SecurityException- If a security manager exists and the caller does not have theUserAdminPermissionwith nameadmin.
-
getRole
Role getRole(java.lang.String name)
Gets theRoleobject with the givennamefrom this User Admin service.- Parameters:
name- The name of theRoleobject to get.- Returns:
- The requested
Roleobject, ornullif this User Admin service does not have aRoleobject with the givenname.
-
getRoles
Role[] getRoles(java.lang.String filter) throws org.osgi.framework.InvalidSyntaxException
Gets theRoleobjects managed by this User Admin service that have properties matching the specified LDAP filter criteria. Seeorg.osgi.framework.Filterfor a description of the filter syntax. If anullfilter is specified, all Role objects managed by this User Admin service are returned.- Parameters:
filter- The filter criteria to match.- Returns:
- The
Roleobjects managed by this User Admin service whose properties match the specified filter criteria, or allRoleobjects if anullfilter is specified. If no roles match the filter,nullwill be returned. - Throws:
org.osgi.framework.InvalidSyntaxException- If the filter is not well formed.
-
getUser
User getUser(java.lang.String key, java.lang.String value)
Gets the user with the given propertykey-valuepair from the User Admin service database. This is a convenience method for retrieving aUserobject based on a property for which everyUserobject is supposed to have a unique value (within the scope of this User Admin service), such as for example a X.500 distinguished name.- Parameters:
key- The property key to look for.value- The property value to compare with.- Returns:
- A matching user, if exactly one is found. If zero or
more than one matching users are found,
nullis returned.
-
getAuthorization
Authorization getAuthorization(User user)
Creates anAuthorizationobject that encapsulates the specifiedUserobject and theRoleobjects it possesses. Thenulluser is interpreted as the anonymous user. The anonymous user represents a user that has not been authenticated. AnAuthorizationobject for an anonymous user will be unnamed, and will only imply groups that user.anyone implies.- Parameters:
user- TheUserobject to create anAuthorizationobject for, ornullfor the anonymous user.- Returns:
- the
Authorizationobject for the specifiedUserobject.
-
-