org.apache.turbine.util.security
Class TurbineAccessControlList

java.lang.Object
  extended byorg.apache.turbine.util.security.TurbineAccessControlList
All Implemented Interfaces:
AccessControlList, java.io.Serializable

public class TurbineAccessControlList
extends java.lang.Object
implements AccessControlList

This is a control class that makes it easy to find out if a particular User has a given Permission. It also determines if a User has a a particular Role.

Version:
$Id: TurbineAccessControlList.java 534527 2007-05-02 16:10:59Z tv $
Author:
John D. McNally, Brett McLaughlin, Greg Ritter, Rafal Krzewski, Henning P. Schmiedehausen, Marco Knüttel
See Also:
Serialized Form

Field Summary
 
Fields inherited from interface org.apache.turbine.util.security.AccessControlList
SESSION_KEY
 
Constructor Summary
TurbineAccessControlList(java.util.Map roleSets, java.util.Map permissionSets)
          Constructs a new AccessControlList.
 
Method Summary
 Group[] getAllGroups()
          Returns all groups definded in the system.
 java.lang.String getName()
          Returns the name of this ACL.
 PermissionSet getPermissions()
          Retrieves a set of Permissions an user is assigned in the global Group.
 PermissionSet getPermissions(Group group)
          Retrieves a set of Permissions an user is assigned in a Group.
 RoleSet getRoles()
          Retrieves a set of Roles an user is assigned in the global Group.
 RoleSet getRoles(Group group)
          Retrieves a set of Roles an user is assigned in a Group.
 boolean hasPermission(Permission permission)
          Checks if the user is assigned a specific Permission in the global Group.
 boolean hasPermission(Permission permission, Group group)
          Checks if the user is assigned a specific Permission in the Group.
 boolean hasPermission(Permission permission, GroupSet groupset)
          Checks if the user is assigned a specific Permission in any of the given Groups
 boolean hasPermission(java.lang.String permission)
          Checks if the user is assigned a specific Permission in the global Group.
 boolean hasPermission(java.lang.String permission, Group group)
          Checks if the user is assigned a specific Permission in the Group.
 boolean hasPermission(java.lang.String permissionName, GroupSet groupset)
          Checks if the user is assigned a specifie Permission in any of the given Groups
 boolean hasPermission(java.lang.String permission, java.lang.String group)
          Checks if the user is assigned a specific Permission in the Group.
 boolean hasRole(Role role)
          Checks if the user is assigned a specific Role in the global Group.
 boolean hasRole(Role role, Group group)
          Checks if the user is assigned a specific Role in the Group.
 boolean hasRole(Role role, GroupSet groupset)
          Checks if the user is assigned a specific Role in any of the given Groups
 boolean hasRole(java.lang.String role)
          Checks if the user is assigned a specific Role in the global Group.
 boolean hasRole(java.lang.String rolename, GroupSet groupset)
          Checks if the user is assigned a specifie Role in any of the given Groups
 boolean hasRole(java.lang.String role, java.lang.String group)
          Checks if the user is assigned a specific Role in the Group.
 void setName(java.lang.String name)
          Sets the name of this ACL.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

TurbineAccessControlList

public TurbineAccessControlList(java.util.Map roleSets,
                                java.util.Map permissionSets)
Constructs a new AccessControlList. This class follows 'immutable' pattern - it's objects can't be modified once they are created. This means that the permissions the users have are in effect form the moment they log in to the moment they log out, and changes made to the security settings in that time are not reflected in the state of this object. If you need to reset an user's permissions you need to invalidate his session.
The objects that constructs an AccessControlList must supply hashtables of role/permission sets keyed with group objects.

Parameters:
roleSets - a hashtable containing RoleSet objects keyed with Group objects
permissionSets - a hashtable containing PermissionSet objects keyed with Group objects
Method Detail

getName

public java.lang.String getName()
Returns the name of this ACL.

Returns:
The ACL Name

setName

public void setName(java.lang.String name)
Sets the name of this ACL.

Parameters:
name - The new ACL name.

getRoles

public RoleSet getRoles(Group group)
Retrieves a set of Roles an user is assigned in a Group.

Specified by:
getRoles in interface AccessControlList
Parameters:
group - the Group
Returns:
the set of Roles this user has within the Group.

getRoles

public RoleSet getRoles()
Retrieves a set of Roles an user is assigned in the global Group.

Specified by:
getRoles in interface AccessControlList
Returns:
the set of Roles this user has within the global Group.

getPermissions

public PermissionSet getPermissions(Group group)
Retrieves a set of Permissions an user is assigned in a Group.

Specified by:
getPermissions in interface AccessControlList
Parameters:
group - the Group
Returns:
the set of Permissions this user has within the Group.

getPermissions

public PermissionSet getPermissions()
Retrieves a set of Permissions an user is assigned in the global Group.

Specified by:
getPermissions in interface AccessControlList
Returns:
the set of Permissions this user has within the global Group.

hasRole

public boolean hasRole(Role role,
                       Group group)
Checks if the user is assigned a specific Role in the Group.

Specified by:
hasRole in interface AccessControlList
Parameters:
role - the Role
group - the Group
Returns:
true if the user is assigned the Role in the Group.

hasRole

public boolean hasRole(Role role,
                       GroupSet groupset)
Checks if the user is assigned a specific Role in any of the given Groups

Specified by:
hasRole in interface AccessControlList
Parameters:
role - the Role
groupset - a Groupset
Returns:
true if the user is assigned the Role in any of the given Groups.

hasRole

public boolean hasRole(java.lang.String role,
                       java.lang.String group)
Checks if the user is assigned a specific Role in the Group.

Specified by:
hasRole in interface AccessControlList
Parameters:
role - the Role
group - the Group
Returns:
true if the user is assigned the Role in the Group.

hasRole

public boolean hasRole(java.lang.String rolename,
                       GroupSet groupset)
Checks if the user is assigned a specifie Role in any of the given Groups

Specified by:
hasRole in interface AccessControlList
Parameters:
rolename - the name of the Role
groupset - a Groupset
Returns:
true if the user is assigned the Role in any of the given Groups.

hasRole

public boolean hasRole(Role role)
Checks if the user is assigned a specific Role in the global Group.

Specified by:
hasRole in interface AccessControlList
Parameters:
role - the Role
Returns:
true if the user is assigned the Role in the global Group.

hasRole

public boolean hasRole(java.lang.String role)
Checks if the user is assigned a specific Role in the global Group.

Specified by:
hasRole in interface AccessControlList
Parameters:
role - the Role
Returns:
true if the user is assigned the Role in the global Group.

hasPermission

public boolean hasPermission(Permission permission,
                             Group group)
Checks if the user is assigned a specific Permission in the Group.

Specified by:
hasPermission in interface AccessControlList
Parameters:
permission - the Permission
group - the Group
Returns:
true if the user is assigned the Permission in the Group.

hasPermission

public boolean hasPermission(Permission permission,
                             GroupSet groupset)
Checks if the user is assigned a specific Permission in any of the given Groups

Specified by:
hasPermission in interface AccessControlList
Parameters:
permission - the Permission
groupset - a Groupset
Returns:
true if the user is assigned the Permission in any of the given Groups.

hasPermission

public boolean hasPermission(java.lang.String permission,
                             java.lang.String group)
Checks if the user is assigned a specific Permission in the Group.

Specified by:
hasPermission in interface AccessControlList
Parameters:
permission - the Permission
group - the Group
Returns:
true if the user is assigned the Permission in the Group.

hasPermission

public boolean hasPermission(java.lang.String permission,
                             Group group)
Checks if the user is assigned a specific Permission in the Group.

Specified by:
hasPermission in interface AccessControlList
Parameters:
permission - the Permission
group - the Group
Returns:
true if the user is assigned the Permission in the Group.

hasPermission

public boolean hasPermission(java.lang.String permissionName,
                             GroupSet groupset)
Checks if the user is assigned a specifie Permission in any of the given Groups

Specified by:
hasPermission in interface AccessControlList
Parameters:
permissionName - the name of the Permission
groupset - a Groupset
Returns:
true if the user is assigned the Permission in any of the given Groups.

hasPermission

public boolean hasPermission(Permission permission)
Checks if the user is assigned a specific Permission in the global Group.

Specified by:
hasPermission in interface AccessControlList
Parameters:
permission - the Permission
Returns:
true if the user is assigned the Permission in the global Group.

hasPermission

public boolean hasPermission(java.lang.String permission)
Checks if the user is assigned a specific Permission in the global Group.

Specified by:
hasPermission in interface AccessControlList
Parameters:
permission - the Permission
Returns:
true if the user is assigned the Permission in the global Group.

getAllGroups

public Group[] getAllGroups()
Returns all groups definded in the system. This is useful for debugging, when you want to display all roles and permissions an user is assingned. This method is needed because you can't call static methods of TurbineSecurity class from within WebMacro/Velocity template

Specified by:
getAllGroups in interface AccessControlList
Returns:
A Group [] of all groups in the system.


Copyright © 2000-2008 Apache Software Foundation. All Rights Reserved.