com.day.cq.security.impl
Class CRXUserManager

java.lang.Object
  extended by com.day.cq.security.impl.CRXUserManager
All Implemented Interfaces:
UserManager

public class CRXUserManager
extends Object
implements UserManager

UserManager Implemenation that provides CRX's Authorizables

See Also:
UserManager

Nested Class Summary
 class CRXUserManager.EveryOne
           
 
Field Summary
 
Fields inherited from interface com.day.cq.security.UserManager
TYPE_GROUP, TYPE_USER
 
Method Summary
 void addModificationListener(AuthorizableListener listener)
           
protected  Authorizable build(com.day.crx.security.Covenantee covenantee)
          Helper to convert the CRX's Covenantee into a CQ Authorizable
 Group createGroup(String groupId, String principalName)
          Creates a new Group for the given name and Principal-Name
 User createUser(String userId, String password, String principalName)
          Creates a new User for given Id, password and PrincipalName.
 Authorizable find(Principal principal)
          Searches for an Authorizable for the given Principal.
<AuthType extends Authorizable>
RangeIterator<AuthType>
find(String query, Class<AuthType> type)
          allways conduct a starts-with search Search for Authorizables that contain the given Query.
 Iterator<Authorizable> find(String propertyName, String substring)
          Searches among CRX's Authorizables for a given Property.
 Iterator<Authorizable> find(String propertyName, String query, int type)
           
 Authorizable findByHome(String homePath)
          Searches an Authorizable which has the given path as Path of it's Home Path property.
 Authorizable get(String id)
          Accesses an Authorizable by its ID.
 Iterator<Group> getGroups()
          
 Iterator<User> getUsers()
          
 boolean hasAuthorizable(String id)
          This method tests if the Manager has any Authorizable with this given ID.
If this method evaluates to true a call to get(id) has to return a non-null Authorizable
 void removeModificationListener(AuthorizableListener listener)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

hasAuthorizable

public boolean hasAuthorizable(String id)
This method tests if the Manager has any Authorizable with this given ID.
If this method evaluates to true a call to get(id) has to return a non-null Authorizable

Specified by:
hasAuthorizable in interface UserManager
Parameters:
id - to be probed
Returns:
true if an Authorizable with the given id exists
See Also:
UserManager.get(String)

get

public Authorizable get(String id)
                 throws NoSuchAuthorizableException
Accesses an Authorizable by its ID. if an Authorizable exists a test with hasAuthorizable(id) has to be true.

Specified by:
get in interface UserManager
Parameters:
id - of the Authorizable requested
Returns:
the requests Authorizable
Throws:
NoSuchAuthorizableException - in case no Authorizable for that ID exists

find

public Authorizable find(Principal principal)
Searches for an Authorizable for the given Principal.

Specified by:
find in interface UserManager
Parameters:
principal - the Authorizable should contain
Returns:
the Authorizable or null if none found
See Also:
Authorizable.getPrincipal()

getUsers

public Iterator<User> getUsers()

Specified by:
getUsers in interface UserManager
Returns:
all Users this Manager knows. Should be used with care, may be time-consuming

getGroups

public Iterator<Group> getGroups()

Specified by:
getGroups in interface UserManager
Returns:
all Groups this Manager knows.Should be used with care, may be time-consuming

find

public Iterator<Authorizable> find(String propertyName,
                                   String substring)
Searches among CRX's Authorizables for a given Property. todo: update CRX userMgr. for better search

Specified by:
find in interface UserManager
Parameters:
propertyName - to search for, currently ignored
substring - value queried
Returns:
all Authorizables that match the query
See Also:
UserManager.find(String, String)

find

public Iterator<Authorizable> find(String propertyName,
                                   String query,
                                   int type)

createUser

public User createUser(String userId,
                       String password,
                       String principalName)
                throws AuthorizableExistsException,
                       AccessDeniedException
Creates a new User for given Id, password and PrincipalName.

Specified by:
createUser in interface UserManager
Parameters:
userId - Id for the User
password - plain password, implementations may encrypt
principalName - principalName to be used when authenticated
Returns:
the newly created User
Throws:
AuthorizableExistsException - in case the ID is already in use
AccessDeniedException - in case the requesting session is not allowed to create a User

createGroup

public Group createGroup(String groupId,
                         String principalName)
                  throws AuthorizableExistsException,
                         AccessDeniedException
Creates a new Group for the given name and Principal-Name

Specified by:
createGroup in interface UserManager
Parameters:
groupId - to be assigned to the new Group
principalName - for the new Group
Returns:
newly created Group
Throws:
AuthorizableExistsException - if the id is already in use
AccessDeniedException - in case the requesting session is not allowed to create a Group

findByHome

public Authorizable findByHome(String homePath)
Searches an Authorizable which has the given path as Path of it's Home Path property. Thus that findByHomepath(homePath).getHomePath().equals(homePath)

Specified by:
findByHome in interface UserManager
Parameters:
homePath - path of the Authorizable's Home
Returns:
the Authorizable or null
See Also:
Authorizable.getHomePath()

build

protected Authorizable build(com.day.crx.security.Covenantee covenantee)
Helper to convert the CRX's Covenantee into a CQ Authorizable

Parameters:
covenantee - to convert
Returns:
the build Authorizable

addModificationListener

public void addModificationListener(AuthorizableListener listener)
Specified by:
addModificationListener in interface UserManager

removeModificationListener

public void removeModificationListener(AuthorizableListener listener)
Specified by:
removeModificationListener in interface UserManager

find

public <AuthType extends Authorizable> RangeIterator<AuthType> find(String query,
                                                                    Class<AuthType> type)
allways conduct a starts-with search Search for Authorizables that contain the given Query. Searches typical ID-Properties, like authorizable ID, principal name.

Specified by:
find in interface UserManager
Parameters:
query - token to find
type - Class of Authorizable to take Authorizable to search for any kind
Returns:
that match the query


Copyright © 2008 Day Management AG. All Rights Reserved.