Interface Group
-
public interface Group extends User
A named grouping of roles (Roleobjects).Whether or not a given
Authorizationcontext implies aGroupobject depends on the members of thatGroupobject.A
Groupobject can have two kinds of members: basic and required . AGroupobject is implied by anAuthorizationcontext if all of its required members are implied and at least one of its basic members is implied.A
Groupobject must contain at least one basic member in order to be implied. In other words, aGroupobject without any basic member roles is never implied by anyAuthorizationcontext.A
Userobject always implies itself.No loop detection is performed when adding members to
Groupobjects, which means that it is possible to create circular implications. Loop detection is instead done when roles are checked. The semantics is that if a role depends on itself (i.e., there is an implication loop), the role is not implied.The rule that a
Groupobject must have at least one basic member to be implied is motivated by the following example:group foo required members: marketing basic members: alice, bobPrivileged operations that require membership in "foo" can be performed only by "alice" and "bob", who are in marketing.If "alice" and "bob" ever transfer to a different department, anybody in marketing will be able to assume the "foo" role, which certainly must be prevented. Requiring that "foo" (or any
Groupobject for that matter) must have at least one basic member accomplishes that.However, this would make it impossible for a
Groupobject to be implied by just its required members. An example where this implication might be useful is the following declaration: "Any citizen who is an adult is allowed to vote." An intuitive configuration of "voter" would be:group voter required members: citizen, adult basic members:However, according to the above rule, the "voter" role could never be assumed by anybody, since it lacks any basic members. In order to address this issue a predefined role named "user.anyone" can be specified, which is always implied. The desired implication of the "voter" group can then be achieved by specifying "user.anyone" as its basic member, as follows:group voter required members: citizen, adult basic members: user.anyone
-
-
Field Summary
-
Fields inherited from interface org.osgi.service.useradmin.Role
GROUP, ROLE, USER, USER_ANYONE
-
-
Method Summary
All Methods Instance Methods Abstract Methods Modifier and Type Method Description booleanaddMember(Role role)Adds the specifiedRoleobject as a basic member to thisGroupobject.booleanaddRequiredMember(Role role)Adds the specifiedRoleobject as a required member to thisGroupobject.Role[]getMembers()Gets the basic members of thisGroupobject.Role[]getRequiredMembers()Gets the required members of thisGroupobject.booleanremoveMember(Role role)Removes the specifiedRoleobject from thisGroupobject.-
Methods inherited from interface org.osgi.service.useradmin.Role
getName, getProperties, getType
-
Methods inherited from interface org.osgi.service.useradmin.User
getCredentials, hasCredential
-
-
-
-
Method Detail
-
addMember
boolean addMember(Role role)
Adds the specifiedRoleobject as a basic member to thisGroupobject.- Parameters:
role- The role to add as a basic member.- Returns:
trueif the given role could be added as a basic member, andfalseif thisGroupobject already contains aRoleobject whose name matches that of the specified role.- Throws:
java.lang.SecurityException- If a security manager exists and the caller does not have theUserAdminPermissionwith nameadmin.
-
addRequiredMember
boolean addRequiredMember(Role role)
Adds the specifiedRoleobject as a required member to thisGroupobject.- Parameters:
role- TheRoleobject to add as a required member.- Returns:
trueif the givenRoleobject could be added as a required member, andfalseif thisGroupobject already contains aRoleobject whose name matches that of the specified role.- Throws:
java.lang.SecurityException- If a security manager exists and the caller does not have theUserAdminPermissionwith nameadmin.
-
removeMember
boolean removeMember(Role role)
Removes the specifiedRoleobject from thisGroupobject.- Parameters:
role- TheRoleobject to remove from thisGroupobject.- Returns:
trueif theRoleobject could be removed, otherwisefalse.- Throws:
java.lang.SecurityException- If a security manager exists and the caller does not have theUserAdminPermissionwith nameadmin.
-
getMembers
Role[] getMembers()
Gets the basic members of thisGroupobject.- Returns:
- The basic members of this
Groupobject, ornullif thisGroupobject does not contain any basic members.
-
getRequiredMembers
Role[] getRequiredMembers()
Gets the required members of thisGroupobject.- Returns:
- The required members of this
Groupobject, ornullif thisGroupobject does not contain any required members.
-
-