org.figure8.join.businessfacades.security
Class DefaultPermissionManager

java.lang.Object
  extended by org.figure8.join.businessfacades.security.DefaultPermissionManager
All Implemented Interfaces:
PermissionManager

public class DefaultPermissionManager
extends java.lang.Object
implements PermissionManager

Default implementation of PermissionManager

Version:
$Revision: 1.1 $
Author:
Laurent Broudoux

Field Summary
protected  PermissionDao dao
          Permission data access object
protected  RoleDao roleDao
          Role data access object
 
Constructor Summary
DefaultPermissionManager()
          Creates a new instance of DefaultPermissionManager
 
Method Summary
 Role getRole(long id)
          Retrieve an application security Role using its unique identifier
 Role getRole(java.lang.String name)
          Retrieve an application security Role using its name
 java.util.List getRoles()
          Retrieve the available security roles within application
 java.util.List getUserPermissions(User user)
          Retrieves all the permission acquired by a specified User
 boolean hasPermission(Role role, java.lang.String userId)
          Tells if a user has permission to endorse this security role
 boolean hasPermissionForResource(java.lang.Object resource, Role role, java.lang.String userId)
          Tells if a user has permission to endorse this security role for this resource
 void removeAllUserPermissions(User user)
          Remove all permissions assigned to a specific user
 void removePermission(Permission permission)
          Remove a given permission from datastore
 void removeRole(Role role)
          Remove a given security role from datastore
 void savePermission(Permission permission)
          Save or update a given permission into datastore
 void saveRole(Role role)
          Save or update a givean security role into datastore.
 void setPermissionDao(PermissionDao dao)
           
 void setRoleDao(RoleDao dao)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

roleDao

protected RoleDao roleDao
Role data access object


dao

protected PermissionDao dao
Permission data access object

Constructor Detail

DefaultPermissionManager

public DefaultPermissionManager()
Creates a new instance of DefaultPermissionManager

Method Detail

setRoleDao

public void setRoleDao(RoleDao dao)
Parameters:
dao - A Role data access object

setPermissionDao

public void setPermissionDao(PermissionDao dao)
Parameters:
dao - A Permission data access object

saveRole

public void saveRole(Role role)
              throws DuplicateEntityException
Save or update a givean security role into datastore. This is indeed a create or update method.

Specified by:
saveRole in interface PermissionManager
Parameters:
role - The security role to save
Throws:
DuplicateEntityException - if a role with same name already exists

removeRole

public void removeRole(Role role)
Remove a given security role from datastore

Specified by:
removeRole in interface PermissionManager
Parameters:
role - The role to remove

getRoles

public java.util.List getRoles()
Retrieve the available security roles within application

Specified by:
getRoles in interface PermissionManager
Returns:
A List of org.figure8.join.businessobjects.security.Role

getRole

public Role getRole(long id)
Retrieve an application security Role using its unique identifier

Specified by:
getRole in interface PermissionManager
Parameters:
id - Unique identifier of role within datastore
Returns:
The corresponding role or null if no role has this id

getRole

public Role getRole(java.lang.String name)
Retrieve an application security Role using its name

Specified by:
getRole in interface PermissionManager
Parameters:
name - The name of security role to retrieve
Returns:
The corresponding role or null if no role has this name

savePermission

public void savePermission(Permission permission)
Save or update a given permission into datastore

Specified by:
savePermission in interface PermissionManager
Parameters:
permission - The permission to save

removePermission

public void removePermission(Permission permission)
Remove a given permission from datastore

Specified by:
removePermission in interface PermissionManager
Parameters:
permission - The permission to remove

removeAllUserPermissions

public void removeAllUserPermissions(User user)
Remove all permissions assigned to a specific user

Specified by:
removeAllUserPermissions in interface PermissionManager
Parameters:
user - The user to remove permissions for

hasPermission

public boolean hasPermission(Role role,
                             java.lang.String userId)
Tells if a user has permission to endorse this security role

Specified by:
hasPermission in interface PermissionManager
Parameters:
role - Security role that has to be endorsed by user
userId - Id of user for whom permission test is done
Returns:
true is user as permission corresponding to role, false otherwise

hasPermissionForResource

public boolean hasPermissionForResource(java.lang.Object resource,
                                        Role role,
                                        java.lang.String userId)
Tells if a user has permission to endorse this security role for this resource

Specified by:
hasPermissionForResource in interface PermissionManager
Parameters:
resource - Entity for whom user should have permission
role - Security role that has to be endorsed by user
userId - Id of user for whom permission test is done
Returns:
true is user as permission corresponding to role for resource, false otherwise

getUserPermissions

public java.util.List getUserPermissions(User user)
Retrieves all the permission acquired by a specified User

Specified by:
getUserPermissions in interface PermissionManager
Parameters:
user - The user to retrieve permissions for
Returns:
A list of org.figure8.join.businessobjects.security.Permission


Copyright © 2005-2008 Join. All Rights Reserved.