org.apache.jackrabbit.api.security.user
Interface UserManager

All Known Implementing Classes:
UserManagerImpl, UserPerWorkspaceUserManager

public interface UserManager

The UserManager provides access to and means to maintain authoriable objects i.e. users and groups. The UserManager is bound to a particular Session.


Field Summary
static int SEARCH_TYPE_AUTHORIZABLE
          Filter flag indicating that all Authorizables should be searched.
static int SEARCH_TYPE_GROUP
          Filter flag indicating that only Groups should be searched and returned.
static int SEARCH_TYPE_USER
          Filter flag indicating that only Users should be searched and returned.
 
Method Summary
 void autoSave(boolean enable)
          Changes the auto save behavior of this UserManager.
 Group createGroup(Principal principal)
          Creates a new Group that is based on the given principal.
 Group createGroup(Principal principal, String intermediatePath)
          Same as createGroup(String, Principal, String) where the name of the specified principal is used to create the group's ID.
 Group createGroup(String groupID)
          Creates a Group for the given groupID, which must not be null.
 Group createGroup(String groupID, Principal principal, String intermediatePath)
          Creates a new Group that is based on the given id, principal and the specified intermediatePath hint.
 User createUser(String userID, String password)
          Creates an User for the given userID / password pair; neither of the specified parameters can be null.
 User createUser(String userID, String password, Principal principal, String intermediatePath)
          Creates an User for the given parameters.
 Iterator<Authorizable> findAuthorizables(Query query)
          Return Authorizables that match a specific Query.
 Iterator<Authorizable> findAuthorizables(String relPath, String value)
          Returns all Authorizables that have a property with the given relative path (or name) that matches the specified value.
 Iterator<Authorizable> findAuthorizables(String relPath, String value, int searchType)
          Returns all Authorizables that have a property with the given relative path (or name) that matches the specified value.
 Authorizable getAuthorizable(Principal principal)
          Get the Authorizable by its main Principal.
 Authorizable getAuthorizable(String id)
          Get the Authorizable by its id.
 boolean isAutoSave()
          If any write operations executed through the User API are automatically persisted this method returns true.
 

Field Detail

SEARCH_TYPE_USER

static final int SEARCH_TYPE_USER
Filter flag indicating that only Users should be searched and returned.

See Also:
Constant Field Values

SEARCH_TYPE_GROUP

static final int SEARCH_TYPE_GROUP
Filter flag indicating that only Groups should be searched and returned.

See Also:
Constant Field Values

SEARCH_TYPE_AUTHORIZABLE

static final int SEARCH_TYPE_AUTHORIZABLE
Filter flag indicating that all Authorizables should be searched.

See Also:
Constant Field Values
Method Detail

getAuthorizable

Authorizable getAuthorizable(String id)
                             throws RepositoryException
Get the Authorizable by its id.

Parameters:
id - The user or group id.
Returns:
Authorizable or null, if not present.
Throws:
RepositoryException - If an error occurs.
See Also:
Authorizable.getID()

getAuthorizable

Authorizable getAuthorizable(Principal principal)
                             throws RepositoryException
Get the Authorizable by its main Principal.

Parameters:
principal -
Returns:
Authorizable or null, if not present.
Throws:
RepositoryException - If an error occurs.

findAuthorizables

Iterator<Authorizable> findAuthorizables(String relPath,
                                         String value)
                                         throws RepositoryException
Returns all Authorizables that have a property with the given relative path (or name) that matches the specified value.

If a relative path with more than one segment is specified only properties exactly matching that patch will be returned. If, however, a name is specified all properties that may be retrieved using Authorizable.getProperty(String) will be searched for a match.

Parameters:
relPath - A relative property path or name.
value -
Returns:
All Authorizables that have a property with the given name exactly matching the given value.
Throws:
RepositoryException - If an error occurs.
See Also:
Authorizable.getProperty(String)

findAuthorizables

Iterator<Authorizable> findAuthorizables(String relPath,
                                         String value,
                                         int searchType)
                                         throws RepositoryException
Returns all Authorizables that have a property with the given relative path (or name) that matches the specified value. In contrast to findAuthorizables(String, String) the type of authorizable is respected while executing the search.

If a relative path with more than one segment is specified only properties exactly matching that path will be returned. If, however, a name is specified all properties that may be retrieved using Authorizable.getProperty(String) will be searched for a match.

Parameters:
relPath - A relative property path or name.
value -
searchType - Any of the following constants:
Returns:
An iterator of Authorizable.
Throws:
RepositoryException - If an error occurs.

findAuthorizables

Iterator<Authorizable> findAuthorizables(Query query)
                                         throws RepositoryException
Return Authorizables that match a specific Query.

Parameters:
query - A query
Returns:
Iterator of authorizables witch match the query.
Throws:
RepositoryException - If an error occurs.

createUser

User createUser(String userID,
                String password)
                throws AuthorizableExistsException,
                       RepositoryException
Creates an User for the given userID / password pair; neither of the specified parameters can be null.
Same as createUser(String,String,Principal,String) where the specified userID is equal to the principal name and the intermediate path is null.

Parameters:
userID - The id of the new user.
password - The initial password of this user.
Returns:
The new User.
Throws:
AuthorizableExistsException - in case the given userID is already in use or another Authorizable with the same principal name exists.
RepositoryException - If another error occurs.

createUser

User createUser(String userID,
                String password,
                Principal principal,
                String intermediatePath)
                throws AuthorizableExistsException,
                       RepositoryException
Creates an User for the given parameters. If the implementation is not able to deal with the intermediatePath that parameter should be ignored. Except for the intermediatePath, neither of the specified parameters can be null.

Parameters:
userID -
password -
principal -
intermediatePath -
Returns:
The new User.
Throws:
AuthorizableExistsException - in case the given userID is already in use or another Authorizable with the same principal name exists.
RepositoryException - If the current Session is not allowed to create users or some another error occurs.

createGroup

Group createGroup(String groupID)
                  throws AuthorizableExistsException,
                         RepositoryException
Creates a Group for the given groupID, which must not be null.
Same as createGroup(String, Principal,String) where the specified groupID is the name of the Principal the intermediate path is null.

Parameters:
groupID - The id of the new group; must not be null.
Returns:
The new Group.
Throws:
AuthorizableExistsException - in case the given groupID is already in use or another Authorizable with the same ID or principal name already exists.
RepositoryException - If another error occurs.

createGroup

Group createGroup(Principal principal)
                  throws AuthorizableExistsException,
                         RepositoryException
Creates a new Group that is based on the given principal. Note that the group's ID is implementation specific. The implementation may take the principal name as ID hint but must in any case assert that it is unique among the IDs known to this manager.

Parameters:
principal - A non-null Principal
Returns:
The new Group.
Throws:
AuthorizableExistsException - in case the given principal is already in use with another Authorizable.
RepositoryException - If another error occurs.

createGroup

Group createGroup(Principal principal,
                  String intermediatePath)
                  throws AuthorizableExistsException,
                         RepositoryException
Same as createGroup(String, Principal, String) where the name of the specified principal is used to create the group's ID.

Parameters:
principal -
intermediatePath -
Returns:
The new Group.
Throws:
AuthorizableExistsException - in case the given principal is already in use with another Authorizable.
RepositoryException - If another error occurs.

createGroup

Group createGroup(String groupID,
                  Principal principal,
                  String intermediatePath)
                  throws AuthorizableExistsException,
                         RepositoryException
Creates a new Group that is based on the given id, principal and the specified intermediatePath hint. If the implementation is not able to deal with the intermediatePath this parameter should be ignored.

Parameters:
principal -
intermediatePath -
Returns:
The new Group.
Throws:
AuthorizableExistsException - in case the given principal is already in use with another Authorizable.
RepositoryException - If another error occurs.

isAutoSave

boolean isAutoSave()
If any write operations executed through the User API are automatically persisted this method returns true. In this case there are no pending transient changes left and there is no need to explicitly call Session.save(). If this method returns false any changes must be completed by an extra save call on the Session associated with this UserManager.

Returns:
true if changes are automatically persisted; false if changes made through this API (including method calls on Authorizable and subclasses are only transient and must be persisted using Session.save().
See Also:
autoSave(boolean)

autoSave

void autoSave(boolean enable)
              throws UnsupportedRepositoryOperationException,
                     RepositoryException
Changes the auto save behavior of this UserManager.

Note, that this shouldn't be allowed in cases where the associated session is different from the original session accessing the user manager.

Parameters:
enable - If true changes made through this API will be automatically saved; otherwise an explicit call to Session.save() is required in order to persist changes.
Throws:
UnsupportedRepositoryOperationException - If the implementation does not allow to change the auto save behavior.
RepositoryException - If some other error occurs.


Copyright © 2004-2010 The Apache Software Foundation. All Rights Reserved.