Two hierarchy resolution strategies are supported for authorization decisions:
user.getSubject().getPrincipals()
returns:
user.getSubject().getPrincipals()
returns:
As described in the
authorization SPI section
, the
SecurityMappingHandler
is configured with a specific hierarchy strategy for group and role hierarchy management. See the
authorization SPI configuration
for a configuration example.
The default hierarchy management implementation resolves the hierarchy strategy by leveraging Jetspeed 2's
java.util.prefs.Preferences
implementation. The
Preferences
implementation provides the underlying structure in Jetspeed to store user attributes, and roles and groups definitions. The
Preferences
model provides a hierarchy model that is leveraged to store the base roles and groups hierarchy upon which various resolving strategies can be
applied (resolution by generalization or aggregation).
See Jetspeed 2 Preferences implementation section for more information.
The
SecurityMappingHandler
implementation resolves the mappings between roles and groups. Let's say that we want to find out the roles mapping to a specific group
name. To do so, the
SecurityMappingHandler
implements a
getRolePrincipalsInGroup(String groupFullPathName)
method. In this method, the group name is mapped to a specific
Preferences
node. According to a given hierarchy resolution strategy (see
overview section
), being in [group A] may mean belonging to a set of groups; the HierarchyResolver is used to do so as illustrated below:
public Set getRolePrincipalsInGroup(String groupFullPathName) { ... Preferences preferences = Preferences.userRoot().node( GroupPrincipalImpl.getFullPathFromPrincipalName(groupFullPathName)); String[] fullPaths = groupHierarchyResolver.resolve(preferences); ... }
As a result of this implementation, the name of a role principal (Principal
getName())
in the security layer should match the full path of that user preferences
root in the preferences layer (Preference
absolutePath(); e.g:
/role/theRolePrincipal
).
Group and roles hierarchy are stored in the
Preferences
layer as follow (the output of
exportNode() for Jetspeed's RBMS Preferences implementation):
<preferences EXTERNAL_XML_VERSION="1.0"> <root type="user"> <map /> <node name="group1"> <map /> <node name="groupid1.1"> <map /> <node name="groupid1.1.1"> <map /> </node> </node> </node> <node name="role1"> <map /> <node name="roleid1.1"> <map /> <node name="roleid1.1.1"> <map /> </node> </node> </node> </root>
/group1/groupid1.1/groupid1.1.1
/role1/roleid1.1/roleid1.1.1
map
element can define groups or roles custom properties. For instance, a role could have a rule custom property (or a pointer to a rule) that
allow rule based role definition tied to some rule engine (Drools for instance) and is validated when the isInRole method is invoked. For
groups, a portal could use group to describe organization and have custom property such as address, city, etc. associated with the
organization/group.