org.apache.jetspeed.security.impl
Class RoleManagerImpl

java.lang.Object
  extended by org.apache.jetspeed.security.impl.RoleManagerImpl
All Implemented Interfaces:
RoleManager

public class RoleManagerImpl
extends java.lang.Object
implements RoleManager

Implementation for managing roles.

Role hierarchy elements are being returned as a Rolecollection. The backing implementation must appropriately map the role hierarchy to a preferences sub-tree.

The convention {principal}.{subprincipal} has been chosen to name roles hierachies in order to support declarative security. Implementation follow the conventions enforced by the PreferencesAPI.

Author:
David Le Strat , David Sean Taylor

Constructor Summary
RoleManagerImpl(SecurityProvider securityProvider)
           
 
Method Summary
 void addRole(java.lang.String roleFullPathName)
          Add a new role.
 void addRoleToGroup(java.lang.String roleFullPathName, java.lang.String groupFullPathName)
          Add a role to a group.
 void addRoleToUser(java.lang.String username, java.lang.String roleFullPathName)
          Add a role to a user.
 Role getRole(java.lang.String roleFullPathName)
          Get a role Role for a given role full path name.
 java.util.Iterator getRoles(java.lang.String filter)
          Get all roles available from all role handlers
 java.util.Collection getRolesForUser(java.lang.String username)
          A collection of Role for all the roles associated to a specific user.
 java.util.Collection getRolesInGroup(java.lang.String groupFullPathName)
          A collection of Role for all the roles associated to a specific group.
 boolean isGroupInRole(java.lang.String groupFullPathName, java.lang.String roleFullPathName)
          Whether or not a role is in a group.
 boolean isUserInRole(java.lang.String username, java.lang.String roleFullPathName)
          Whether or not a user is in a role.
 void removeRole(java.lang.String roleFullPathName)
          Remove a given role and all the children of that role.
 void removeRoleFromGroup(java.lang.String roleFullPathName, java.lang.String groupFullPathName)
          Remove a role from a group.
 void removeRoleFromUser(java.lang.String username, java.lang.String roleFullPathName)
          Remove a user from a role.
 boolean roleExists(java.lang.String roleFullPathName)
          Whether or not a role exists.
 void setRoleEnabled(java.lang.String roleFullPathName, boolean enabled)
          Enable or disable a role.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

RoleManagerImpl

public RoleManagerImpl(SecurityProvider securityProvider)
Parameters:
securityProvider - The security provider.
Method Detail

addRole

public void addRole(java.lang.String roleFullPathName)
             throws SecurityException
Description copied from interface: RoleManager

Add a new role.

Role principal names are expressed as {principal}.{subprincipal} where "." is the separator expressing the hierarchical nature of a role.

Role principal path names are stored leveraging the Preferences api. Roles will be stored under /role/theGroupName/theGroupNameChild when given the full path name theRoleName.theRoleNameChild.

Specified by:
addRole in interface RoleManager
Parameters:
roleFullPathName - The role name full path (e.g. theRoleName.theRoleNameChild).
Throws:
SecurityException
See Also:
RoleManager.addRole(java.lang.String)

removeRole

public void removeRole(java.lang.String roleFullPathName)
                throws SecurityException
Description copied from interface: RoleManager

Remove a given role and all the children of that role.

Role principal names are expressed as {principal}.{subprincipal} where "." is the separator expressing the hierarchical nature of a role.

Role principal path names are stored leveraging the Preferences api. Roles will be stored under /role/theGroupName/theGroupNameChild when given the full path name theRoleName.theRoleNameChild.

Specified by:
removeRole in interface RoleManager
Parameters:
roleFullPathName - The role name full path (e.g. theRoleName.theRoleNameChild).
Throws:
SecurityException
See Also:
RoleManager.removeRole(java.lang.String)

roleExists

public boolean roleExists(java.lang.String roleFullPathName)
Description copied from interface: RoleManager

Whether or not a role exists.

Specified by:
roleExists in interface RoleManager
Parameters:
roleFullPathName - The role name full path (e.g. theRoleName.theRoleNameChild).
Returns:
Whether or not a role exists.
See Also:
RoleManager.roleExists(java.lang.String)

getRole

public Role getRole(java.lang.String roleFullPathName)
             throws SecurityException
Description copied from interface: RoleManager

Get a role Role for a given role full path name.

Specified by:
getRole in interface RoleManager
Parameters:
roleFullPathName - The role name full path (e.g. theRoleName.theRoleNameChild).
Returns:
The Preferences node.
Throws:
SecurityException
See Also:
RoleManager.getRole(java.lang.String)

getRolesForUser

public java.util.Collection getRolesForUser(java.lang.String username)
                                     throws SecurityException
Description copied from interface: RoleManager

A collection of Role for all the roles associated to a specific user.

Specified by:
getRolesForUser in interface RoleManager
Parameters:
username - The user name.
Returns:
A Collection of Role.
Throws:
SecurityException
See Also:
RoleManager.getRolesForUser(java.lang.String)

getRolesInGroup

public java.util.Collection getRolesInGroup(java.lang.String groupFullPathName)
                                     throws SecurityException
Description copied from interface: RoleManager

A collection of Role for all the roles associated to a specific group.

Specified by:
getRolesInGroup in interface RoleManager
Parameters:
groupFullPathName - The group full path (e.g. theGroupName.theGroupChildName).
Returns:
A Collection of Role.
Throws:
SecurityException
See Also:
RoleManager.getRolesInGroup(java.lang.String)

addRoleToUser

public void addRoleToUser(java.lang.String username,
                          java.lang.String roleFullPathName)
                   throws SecurityException
Description copied from interface: RoleManager

Add a role to a user.

Specified by:
addRoleToUser in interface RoleManager
Parameters:
username - The user name.
roleFullPathName - The role name full path (e.g. theRoleName.theRoleChildName).
Throws:
SecurityException
See Also:
RoleManager.addRoleToUser(java.lang.String, java.lang.String)

removeRoleFromUser

public void removeRoleFromUser(java.lang.String username,
                               java.lang.String roleFullPathName)
                        throws SecurityException
Description copied from interface: RoleManager

Remove a user from a role.

Specified by:
removeRoleFromUser in interface RoleManager
Parameters:
username - The user name.
roleFullPathName - The role name full path relative to the /role node (e.g. /theRoleName/theRoleChildName).
Throws:
SecurityException
See Also:
RoleManager.removeRoleFromUser(java.lang.String, java.lang.String)

isUserInRole

public boolean isUserInRole(java.lang.String username,
                            java.lang.String roleFullPathName)
                     throws SecurityException
Description copied from interface: RoleManager

Whether or not a user is in a role.

Specified by:
isUserInRole in interface RoleManager
Parameters:
username - The user name.
roleFullPathName - The role name full path (e.g. theRoleName.theRoleChildName).
Returns:
Whether or not a user is in a role.
Throws:
SecurityException
See Also:
RoleManager.isUserInRole(java.lang.String, java.lang.String)

addRoleToGroup

public void addRoleToGroup(java.lang.String roleFullPathName,
                           java.lang.String groupFullPathName)
                    throws SecurityException
Description copied from interface: RoleManager

Add a role to a group.

Specified by:
addRoleToGroup in interface RoleManager
Parameters:
roleFullPathName - The role name full path (e.g. theRoleName.theRoleChildName).
groupFullPathName - The group name full path (e.g. theGroupName.theGroupChildName).
Throws:
SecurityException
See Also:
RoleManager.addRoleToGroup(java.lang.String, java.lang.String)

removeRoleFromGroup

public void removeRoleFromGroup(java.lang.String roleFullPathName,
                                java.lang.String groupFullPathName)
                         throws SecurityException
Description copied from interface: RoleManager

Remove a role from a group.

Specified by:
removeRoleFromGroup in interface RoleManager
Parameters:
roleFullPathName - The role name full path (e.g. theRoleName.theRoleChildName).
groupFullPathName - The group name full path (e.g. theGroupName.theGroupChildName).
Throws:
SecurityException
See Also:
RoleManager.removeRoleFromGroup(java.lang.String, java.lang.String)

isGroupInRole

public boolean isGroupInRole(java.lang.String groupFullPathName,
                             java.lang.String roleFullPathName)
                      throws SecurityException
Description copied from interface: RoleManager

Whether or not a role is in a group.

Specified by:
isGroupInRole in interface RoleManager
Parameters:
groupFullPathName - The group name full path (e.g. theGroupName.theGroupChildName).
roleFullPathName - The role name full path (e.g. theRoleName.theRoleChildName).
Returns:
Whether or not a role is in a group.
Throws:
SecurityException
See Also:
RoleManager.isGroupInRole(java.lang.String, java.lang.String)

getRoles

public java.util.Iterator getRoles(java.lang.String filter)
                            throws SecurityException
Description copied from interface: RoleManager
Get all roles available from all role handlers

Specified by:
getRoles in interface RoleManager
Parameters:
filter - The filter used to retrieve matching roles.
Returns:
all roles available as Principal
Throws:
SecurityException
See Also:
RoleManager.getRoles(java.lang.String)

setRoleEnabled

public void setRoleEnabled(java.lang.String roleFullPathName,
                           boolean enabled)
                    throws SecurityException
Description copied from interface: RoleManager
Enable or disable a role.

Specified by:
setRoleEnabled in interface RoleManager
Parameters:
roleFullPathName - The role name full path (e.g. theRoleName.theRoleChildName).
enabled - enabled flag for the role
Throws:
SecurityException
See Also:
RoleManager.setRoleEnabled(java.lang.String, boolean)


Copyright © 1999-2009 Apache Software Foundation. All Rights Reserved.