org.apache.slide.security
Class SecurityImpl

java.lang.Object
  |
  +--org.apache.slide.security.SecurityImpl
All Implemented Interfaces:
Security

public final class SecurityImpl
extends java.lang.Object
implements Security

Security helper.

Version:
$Revision: 1.27 $
Author:
Remy Maucherat

Constructor Summary
SecurityImpl(Namespace namespace, NamespaceConfig namespaceConfig)
          Constructor.
 
Method Summary
 void checkCredentials(SlideToken token, ObjectNode object, ActionNode action)
          Check if the credentials given grants permission to perform the specified action on the specified subject.
 void checkPermission(ObjectNode object, SubjectNode subject, ActionNode action)
          Check whether or not an actor can perform the specified activity on a collection.
 void denyPermission(SlideToken token, NodePermission permission)
          Deny a new permission.
 void denyPermission(SlideToken token, ObjectNode object, SubjectNode subject, ActionNode action)
          Deny a new permission.
 void denyPermission(SlideToken token, ObjectNode object, SubjectNode subject, ActionNode action, boolean inheritable)
          Deny a new permission.
 java.util.Enumeration enumeratePermissions(SlideToken token, ObjectNode object)
          Enumerates permissions on an object.
 java.util.Enumeration enumeratePermissions(SlideToken token, java.lang.String object)
          Enumerates permissions on an object.
 ObjectNode getPrincipal(SlideToken token)
          Get the principal associated with the credentials token.
 java.util.Enumeration getRoles(ObjectNode object)
          Return the list of roles the specified node has.
 java.util.Enumeration getRoles(SlideToken token)
          Return the list of roles the specified token has.
 void grantPermission(SlideToken token, NodePermission permission)
          Grants a new permission.
 void grantPermission(SlideToken token, ObjectNode object, SubjectNode subject, ActionNode action)
          Grants a new permission.
 void grantPermission(SlideToken token, ObjectNode object, SubjectNode subject, ActionNode action, boolean inheritable)
          Grants a new permission.
 boolean hasPermission(ObjectNode object, SubjectNode subject, ActionNode action)
          Check whether or not an actor can perform the specified activity on a collection.
 boolean hasRole(ObjectNode object, java.lang.String role)
          Check whether or not the current user has the specified role.
 boolean hasRole(SlideToken token, java.lang.String role)
          Check whether or not the current user has the specified role.
 void revokePermission(SlideToken token, NodePermission permission)
          Revokes a permission.
 void revokePermission(SlideToken token, ObjectNode object, SubjectNode subject, ActionNode action)
          Revokes a permission.
 void setPermissions(SlideToken token, java.lang.String object, java.util.Enumeration permissions)
          Set a new set of permissions on an object.
 
Methods inherited from class java.lang.Object
, clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

SecurityImpl

public SecurityImpl(Namespace namespace,
                    NamespaceConfig namespaceConfig)
Constructor.
Parameters:
namespace - Namespace
namespaceConfig - Namespace configuration
Method Detail

setPermissions

public void setPermissions(SlideToken token,
                           java.lang.String object,
                           java.util.Enumeration permissions)
                    throws ServiceAccessException,
                           ObjectNotFoundException,
                           AccessDeniedException
Set a new set of permissions on an object.
Specified by:
setPermissions in interface Security
Parameters:
token - Credentials token
object - Object on which permission is granted
Throws:
ServiceAccessException - DataSource access error
ObjectNotFoundException - Specified object was not found in the DataSource
AccessDeniedException - Insufficent credentials

grantPermission

public void grantPermission(SlideToken token,
                            ObjectNode object,
                            SubjectNode subject,
                            ActionNode action)
                     throws ServiceAccessException,
                            ObjectNotFoundException,
                            AccessDeniedException
Grants a new permission.
Specified by:
grantPermission in interface Security
Parameters:
token - Credentials token
object - Object on which permission is granted
activity - Activity which the actor can perform
collection - Collection on which the actor can perform the specified action
Throws:
ServiceAccessException - DataSource access error
ObjectNotFoundException - Specified object was not found in the DataSource
AccessDeniedException - Insufficent credentials

grantPermission

public void grantPermission(SlideToken token,
                            ObjectNode object,
                            SubjectNode subject,
                            ActionNode action,
                            boolean inheritable)
                     throws ServiceAccessException,
                            ObjectNotFoundException,
                            AccessDeniedException
Grants a new permission.
Specified by:
grantPermission in interface Security
Parameters:
token - Credentials token
object - Object on which permission is granted
subject - Subject who can perform the action
action - Action which can be performed
inheritable - Create an inheritable permission
Throws:
ServiceAccessException - DataSource access error
ObjectNotFoundException - Specified object was not found in the DataSource
AccessDeniedException - Insufficent credentials

grantPermission

public void grantPermission(SlideToken token,
                            NodePermission permission)
                     throws ServiceAccessException,
                            ObjectNotFoundException,
                            AccessDeniedException
Grants a new permission.
Specified by:
grantPermission in interface Security
Parameters:
token - Credentials token
permission - New permission
Throws:
ServiceAccessException - DataSource access error
ObjectNotFoundException - Specified object was not found in the DataSource
AccessDeniedException - Insufficent credentials

denyPermission

public void denyPermission(SlideToken token,
                           ObjectNode object,
                           SubjectNode subject,
                           ActionNode action)
                    throws ServiceAccessException,
                           ObjectNotFoundException,
                           AccessDeniedException
Deny a new permission.
Specified by:
denyPermission in interface Security
Parameters:
token - Credentials token
object - Object on which permission is granted
activity - Activity which the actor can perform
collection - Collection on which the actor can perform the specified action
Throws:
ServiceAccessException - DataSource access error
ObjectNotFoundException - Specified object was not found in the DataSource
AccessDeniedException - Insufficent credentials

denyPermission

public void denyPermission(SlideToken token,
                           ObjectNode object,
                           SubjectNode subject,
                           ActionNode action,
                           boolean inheritable)
                    throws ServiceAccessException,
                           ObjectNotFoundException,
                           AccessDeniedException
Deny a new permission.
Specified by:
denyPermission in interface Security
Parameters:
token - Credentials token
object - Object on which permission is granted
subject - Subject who can perform the action
action - Action which can be performed
inheritable - Create an inheritable permission
Throws:
ServiceAccessException - DataSource access error
ObjectNotFoundException - Specified object was not found in the DataSource
AccessDeniedException - Insufficent credentials

denyPermission

public void denyPermission(SlideToken token,
                           NodePermission permission)
                    throws ServiceAccessException,
                           ObjectNotFoundException,
                           AccessDeniedException
Deny a new permission.
Specified by:
denyPermission in interface Security
Parameters:
token - Credentials token
permission - New permission
Throws:
ServiceAccessException - DataSource access error
ObjectNotFoundException - Specified object was not found in the DataSource
AccessDeniedException - Insufficent credentials

revokePermission

public void revokePermission(SlideToken token,
                             ObjectNode object,
                             SubjectNode subject,
                             ActionNode action)
                      throws ServiceAccessException,
                             ObjectNotFoundException,
                             AccessDeniedException
Revokes a permission.
Specified by:
revokePermission in interface Security
Parameters:
token - Credentials token
object - Object on which permission is revoked
subject - Subject who can perform the action
action - Action which can be performed
Throws:
ServiceAccessException - DataSource access error
ObjectNotFoundException - Specified object was not found in the DataSource
AccessDeniedException - Insufficent credentials

revokePermission

public void revokePermission(SlideToken token,
                             NodePermission permission)
                      throws ServiceAccessException,
                             ObjectNotFoundException,
                             AccessDeniedException
Revokes a permission.
Specified by:
revokePermission in interface Security
Parameters:
token - Credentials token
permission - Permission to be removed
Throws:
ServiceAccessException - DataSource access error
ObjectNotFoundException - Specified object was not found in the DataSource
AccessDeniedException - Insufficent credentials

checkCredentials

public void checkCredentials(SlideToken token,
                             ObjectNode object,
                             ActionNode action)
                      throws ServiceAccessException,
                             AccessDeniedException
Check if the credentials given grants permission to perform the specified action on the specified subject.
Specified by:
checkCredentials in interface Security
Parameters:
token - Credentials token
object - Object on which the action is performed
action - Action performed
Throws:
ServiceAccessException - DataSource access error
AccessDeniedException - The credentials does not grant the permission to perform the specified action

checkPermission

public void checkPermission(ObjectNode object,
                            SubjectNode subject,
                            ActionNode action)
                     throws ServiceAccessException,
                            AccessDeniedException,
                            ObjectNotFoundException
Check whether or not an actor can perform the specified activity on a collection.
Specified by:
checkPermission in interface Security
Parameters:
object - Object on which access is tested
subject - Subject who seeks to perform the action
action - Action which is to be performed
Throws:
ServiceAccessException - DataSource access error
ObjectNotFoundException - Specified object was not found in the DataSource
AccessDeniedException - Insufficent credentials

hasPermission

public boolean hasPermission(ObjectNode object,
                             SubjectNode subject,
                             ActionNode action)
                      throws ServiceAccessException,
                             ObjectNotFoundException
Check whether or not an actor can perform the specified activity on a collection.
Specified by:
hasPermission in interface Security
Parameters:
object - Object on which access is tested
subject - Subject who seeks to perform the action
action - Action which is to be performed
Returns:
true if the action can be performed
Throws:
ServiceAccessException - DataSource access error
ObjectNotFoundException - Specified object was not found in the DataSource

enumeratePermissions

public java.util.Enumeration enumeratePermissions(SlideToken token,
                                                  ObjectNode object)
                                           throws ServiceAccessException,
                                                  ObjectNotFoundException,
                                                  AccessDeniedException
Enumerates permissions on an object.
Specified by:
enumeratePermissions in interface Security
Parameters:
token - Credentials token
object - Object on which permission is granted
Throws:
ServiceAccessException - DataSource access error
ObjectNotFoundException - Specified object was not found in the DataSource
AccessDeniedException - Insufficent credentials

enumeratePermissions

public java.util.Enumeration enumeratePermissions(SlideToken token,
                                                  java.lang.String object)
                                           throws ServiceAccessException,
                                                  ObjectNotFoundException,
                                                  AccessDeniedException
Enumerates permissions on an object.
Specified by:
enumeratePermissions in interface Security
Parameters:
token - Credentials token
object - Object on which permission is granted
Throws:
ServiceAccessException - DataSource access error
ObjectNotFoundException - Specified object was not found in the DataSource
AccessDeniedException - Insufficent credentials

hasRole

public boolean hasRole(SlideToken token,
                       java.lang.String role)
                throws ServiceAccessException,
                       ObjectNotFoundException
Check whether or not the current user has the specified role.
Specified by:
hasRole in interface Security
Parameters:
token - Credentials token
role - Role
Throws:
ServiceAccessException - DataSource access error
ObjectNotFoundException - Specified object was not found in the DataSource

hasRole

public boolean hasRole(ObjectNode object,
                       java.lang.String role)
                throws ServiceAccessException,
                       ObjectNotFoundException
Check whether or not the current user has the specified role.
Specified by:
hasRole in interface Security
Parameters:
object - Object node
role - Role
Throws:
ServiceAccessException - DataSource access error
ObjectNotFoundException - Specified object was not found in the DataSource

getRoles

public java.util.Enumeration getRoles(ObjectNode object)
Return the list of roles the specified node has.
Specified by:
getRoles in interface Security
Parameters:
object - Object node

getRoles

public java.util.Enumeration getRoles(SlideToken token)
                               throws ServiceAccessException,
                                      ObjectNotFoundException
Return the list of roles the specified token has.
Specified by:
getRoles in interface Security
Parameters:
token - Credentials token

getPrincipal

public ObjectNode getPrincipal(SlideToken token)
                        throws ServiceAccessException,
                               ObjectNotFoundException
Get the principal associated with the credentials token.
Specified by:
getPrincipal in interface Security
Parameters:
token - Creadentials token