com.day.cq.security.impl
Class CrxAuthorizable

java.lang.Object
  extended by org.apache.sling.adapter.SlingAdaptable
      extended by com.day.cq.security.impl.CrxAuthorizable
All Implemented Interfaces:
Authorizable, org.apache.sling.api.adapter.Adaptable
Direct Known Subclasses:
CrxGroup, CrxUser

public abstract class CrxAuthorizable
extends org.apache.sling.adapter.SlingAdaptable
implements Authorizable

Implementation of an Authorizable backed by a CRX Repository Covenantee

See Also:
Authorizable, UserManager

Field Summary
protected static org.slf4j.Logger log
           
 
Fields inherited from interface com.day.cq.security.Authorizable
PROPERTY_DESCRIPTION, PROPERTY_EMAIL, PROPERTY_ID, PROPERTY_NAME, PROPERTY_PRINCIPAL
 
Method Summary
<AdapterType>
AdapterType
adaptTo(Class<AdapterType> type)
          Adapat to the Home if the type argument is a Node Class Delegates all other Adapater types to AdapterFactory
 boolean equals(Object obj)
           
 Privilege getEffectivePrivilege(String privilege)
          The getPrivilege method, only accesses Privilges garanted to this Authorizable, the effective Privilege access additionally those inherited
 String getHomePath()
          
 Principal getPrincipal()
          
 Privilege getPrivilege(String privilege)
          
 Collection<Privilege> getPrivileges()
          
 String getProperty(String name)
          Some property.
 Iterator<String> getPropertyNames()
          Returns the names of properties present with this Authorizable.
 void grantPrivilege(String privilege)
          
 int hashCode()
           
 boolean hasPermission(String privilege)
          
 boolean hasPermissionOn(String privilege, String resourcePath)
          
 boolean isUser()
          If an Authorizable is a User according this test-method a cast to User Class MUST be possible.
 Iterator<Group> memberOf()
          The Groups a Authorizable is member of.
Transitive membership is not resolved.
 void remove()
          delete this Authorizable
 boolean removeProperty(String name)
          Removes the property with the given name.
 void revokePrivilege(String privilege)
          
 void setProperty(String name, String value)
          Set an arbitrary property to this Authorizable.
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface com.day.cq.security.Authorizable
getID, getName
 

Field Detail

log

protected static final org.slf4j.Logger log
Method Detail

isUser

public boolean isUser()
If an Authorizable is a User according this test-method a cast to User Class MUST be possible.

Specified by:
isUser in interface Authorizable
Returns:
true if the Authorizable is a User
See Also:
User

getPrincipal

public Principal getPrincipal()

Specified by:
getPrincipal in interface Authorizable
Returns:
this Authorizable holds, if authenticated

getProperty

public String getProperty(String name)
Some property. Its open for implementers to provide any Property. See constants of this Interface for commonly used properties

Specified by:
getProperty in interface Authorizable
Parameters:
name - of the Property
Returns:
Property or nullif property does not exist or does not have a value

getPropertyNames

public Iterator<String> getPropertyNames()
Returns the names of properties present with this Authorizable.

Specified by:
getPropertyNames in interface Authorizable
Returns:
names of properties.
See Also:
Authorizable.getProperty(String)

setProperty

public void setProperty(String name,
                        String value)
                 throws AccessDeniedException
Set an arbitrary property to this Authorizable.

Specified by:
setProperty in interface Authorizable
Parameters:
name - name of the Property to set
value - to set
Throws:
AccessDeniedException - the session, aquireing thie Authroizable is not allowed to write authorizables

removeProperty

public boolean removeProperty(String name)
                       throws AccessControlException
Removes the property with the given name.

Specified by:
removeProperty in interface Authorizable
Parameters:
name - of the Property to remove
Returns:
true If the property with the specified name was successfully removed; false if no such property was present.
Throws:
AccessControlException

getHomePath

public String getHomePath()

Specified by:
getHomePath in interface Authorizable
Returns:
an absolute Path, this User may use as Home-Directory

hasPermission

public boolean hasPermission(String privilege)

Specified by:
hasPermission in interface Authorizable
Parameters:
privilege - identifier of the privilege (eg. workflow/privilege/start)
Returns:
true if the privilege is set. false if not or if Privilege.isPathDependent() privilege is pathDependant}
See Also:
Authorizable.grantPrivilege(String)

hasPermissionOn

public boolean hasPermissionOn(String privilege,
                               String resourcePath)

Specified by:
hasPermissionOn in interface Authorizable
Parameters:
privilege - identifier of the privilege (eg. workflow/privilege/start)
resourcePath - path of the resource
Returns:
true if the privilege is set. if Privilege.isPathDependent() privilege is pathDependant}. it has additionaly to grant on the given resource-path
See Also:
Authorizable.grantPrivilege(String), Privilege.isGranted(String)

getPrivilege

public Privilege getPrivilege(String privilege)
                       throws AccessDeniedException

Specified by:
getPrivilege in interface Authorizable
Parameters:
privilege - identifier of the privilege (eg. workflow/privilege/start)
Returns:
Privilege or null if none set
Throws:
AccessDeniedException - in case the session that acquired this authorizable is not allowed read Privileges
See Also:
Authorizable.grantPrivilege(String)

grantPrivilege

public void grantPrivilege(String privilege)
                    throws AccessDeniedException

Specified by:
grantPrivilege in interface Authorizable
Parameters:
privilege - identifier to grant the current Authorizable
Throws:
AccessDeniedException - in case the session that acquired this authorizable is not allowed grant Privileges

revokePrivilege

public void revokePrivilege(String privilege)
                     throws AccessDeniedException

Specified by:
revokePrivilege in interface Authorizable
Parameters:
privilege - identifier of the privilege to remove from this Authorizable
Throws:
AccessDeniedException - in case the session that acquired this authorizable is not allowed revoke Privileges

getPrivileges

public Collection<Privilege> getPrivileges()
                                    throws AccessDeniedException

Specified by:
getPrivileges in interface Authorizable
Returns:
collection of Privileges grantet the current Authorizable this includes only the privileges granted explicitly and not those granted by group-membership.
Throws:
AccessDeniedException - in case the session that acquired this authorizable is not allowed read Privileges

getEffectivePrivilege

public Privilege getEffectivePrivilege(String privilege)
                                throws AccessDeniedException
The getPrivilege method, only accesses Privilges garanted to this Authorizable, the effective Privilege access additionally those inherited

Parameters:
privilege - idedntifier to access
Returns:
Privilege or null if non is effective
Throws:
AccessDeniedException - in case the current User does not have permission to test privileges todo: add if to check to api

memberOf

public Iterator<Group> memberOf()
The Groups a Authorizable is member of.
Transitive membership is not resolved. Thus the following is true: if Authorizable A is memebrOf Group G g.getMemebers() contains A.

Specified by:
memberOf in interface Authorizable
Returns:
Iterator containing all Groups the Authorizable is direct member of

remove

public void remove()
            throws AccessDeniedException
delete this Authorizable

Specified by:
remove in interface Authorizable
Throws:
AccessDeniedException - in case the session that acquired this authorizable is not allowed to remove this

adaptTo

public <AdapterType> AdapterType adaptTo(Class<AdapterType> type)
Adapat to the Home if the type argument is a Node Class Delegates all other Adapater types to AdapterFactory

Specified by:
adaptTo in interface org.apache.sling.api.adapter.Adaptable
Overrides:
adaptTo in class org.apache.sling.adapter.SlingAdaptable
Parameters:
type - Adapter type
Returns:
Adapted Object if Adapter is found for the requested type
See Also:
Authorizable.getHomePath()

equals

public boolean equals(Object obj)
Overrides:
equals in class Object

hashCode

public int hashCode()
Overrides:
hashCode in class Object


Copyright © 2008 Day Management AG. All Rights Reserved.