Interface UserAdmin
Role
objects,
which can be used for authentication and authorization purposes.
This version of the User Admin service defines two types of Role
objects: "User" and "Group". Each type of role is represented by an
int
constant 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 User
object can be configured with credentials (e.g., a password)
and properties (e.g., a street address, phone number, etc.).
A Group
object represents an aggregation of User
and
Group
objects. In other words, the members of a Group
object
are roles themselves.
Every User Admin service manages and maintains its own namespace of
Role
objects, in which each Role
object has a unique name.
- "Consumers of this API must not implement this interface"
-
Method Summary
Modifier and TypeMethodDescriptioncreateRole
(String name, int type) Creates aRole
object with the given name and of the given type.getAuthorization
(User user) Creates anAuthorization
object that encapsulates the specifiedUser
object and theRole
objects it possesses.Gets theRole
object with the givenname
from this User Admin service.Role[]
Gets theRole
objects managed by this User Admin service that have properties matching the specified LDAP filter criteria.Gets the user with the given propertykey
-value
pair from the User Admin service database.boolean
removeRole
(String name) Removes theRole
object with the given name from this User Admin service and all groups it is a member of.
-
Method Details
-
createRole
Creates aRole
object with the given name and of the given type.If a
Role
object was created, aUserAdminEvent
object of typeUserAdminEvent.ROLE_CREATED
is broadcast to anyUserAdminListener
object.- Parameters:
name
- Thename
of theRole
object to create.type
- The type of theRole
object to create. Must be either aRole.USER
type orRole.GROUP
type.- Returns:
- The newly created
Role
object, ornull
if a role with the given name already exists. - Throws:
IllegalArgumentException
- iftype
is invalid.SecurityException
- If a security manager exists and the caller does not have theUserAdminPermission
with nameadmin
.
-
removeRole
Removes theRole
object with the given name from this User Admin service and all groups it is a member of.If the
Role
object was removed, aUserAdminEvent
object of typeUserAdminEvent.ROLE_REMOVED
is broadcast to anyUserAdminListener
object.- Parameters:
name
- The name of theRole
object to remove.- Returns:
true
If aRole
object with the given name is present in this User Admin service and could be removed, otherwisefalse
.- Throws:
SecurityException
- If a security manager exists and the caller does not have theUserAdminPermission
with nameadmin
.
-
getRole
Gets theRole
object with the givenname
from this User Admin service.- Parameters:
name
- The name of theRole
object to get.- Returns:
- The requested
Role
object, ornull
if this User Admin service does not have aRole
object with the givenname
.
-
getRoles
Gets theRole
objects managed by this User Admin service that have properties matching the specified LDAP filter criteria. Seeorg.osgi.framework.Filter
for a description of the filter syntax. If anull
filter is specified, all Role objects managed by this User Admin service are returned.- Parameters:
filter
- The filter criteria to match.- Returns:
- The
Role
objects managed by this User Admin service whose properties match the specified filter criteria, or allRole
objects if anull
filter is specified. If no roles match the filter,null
will be returned. - Throws:
InvalidSyntaxException
- If the filter is not well formed.
-
getUser
Gets the user with the given propertykey
-value
pair from the User Admin service database. This is a convenience method for retrieving aUser
object based on a property for which everyUser
object 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,
null
is returned.
-
getAuthorization
Creates anAuthorization
object that encapsulates the specifiedUser
object and theRole
objects it possesses. Thenull
user is interpreted as the anonymous user. The anonymous user represents a user that has not been authenticated. AnAuthorization
object for an anonymous user will be unnamed, and will only imply groups that user.anyone implies.- Parameters:
user
- TheUser
object to create anAuthorization
object for, ornull
for the anonymous user.- Returns:
- the
Authorization
object for the specifiedUser
object.
-