public interface UserManager
UserManager
provides access to and means to maintain
authorizable objects
i.e. users
and
groups
. The UserManager
is bound to a particular
Session
.
Note that all create
calls will modify the session associated
with the UserManager (whether this is the current session or not
depends on the repository configuration). If the user manager is not
in "autosave" mode (see isAutoSave()
), problems like
overlapping creation of intermediate nodes may only surface upon a subsequent
Session#save()
operation; callers should be prepared to repeat them
in case this happens.
Modifier and Type | Field and Description |
---|---|
static int |
SEARCH_TYPE_AUTHORIZABLE
Filter flag indicating that all
Authorizable s should be
searched. |
static int |
SEARCH_TYPE_GROUP
Filter flag indicating that only
Group s should be searched
and returned. |
static int |
SEARCH_TYPE_USER
Filter flag indicating that only
User s should be searched
and returned. |
Modifier and Type | Method and Description |
---|---|
void |
autoSave(boolean enable)
Changes the auto save behavior of this
UserManager . |
Group |
createGroup(java.security.Principal principal)
Creates a new
Group that is based on the given principal. |
Group |
createGroup(java.security.Principal principal,
java.lang.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(java.lang.String groupID)
Creates a Group for the given groupID, which must not be
null . |
Group |
createGroup(java.lang.String groupID,
java.security.Principal principal,
java.lang.String intermediatePath)
Creates a new
Group that is based on the given id, principal
and the specified intermediatePath hint. |
User |
createSystemUser(java.lang.String userID,
java.lang.String intermediatePath)
Create a new system user for the specified
userID . |
User |
createUser(java.lang.String userID,
java.lang.String password)
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 . |
User |
createUser(java.lang.String userID,
java.lang.String password,
java.security.Principal principal,
java.lang.String intermediatePath)
Creates an User for the given parameters.
|
java.util.Iterator<Authorizable> |
findAuthorizables(Query query)
Return
Authorizable s that match a specific Query . |
java.util.Iterator<Authorizable> |
findAuthorizables(java.lang.String relPath,
java.lang.String value)
Returns all
Authorizable s that have a
property with the given relative
path (or name) that matches the specified value. |
java.util.Iterator<Authorizable> |
findAuthorizables(java.lang.String relPath,
java.lang.String value,
int searchType)
Returns all
Authorizable s that have a
property with the given relative
path (or name) that matches the specified value. |
Authorizable |
getAuthorizable(java.security.Principal principal)
Get the Authorizable by its Principal.
|
Authorizable |
getAuthorizable(java.lang.String id)
Get the Authorizable by its id.
|
<T extends Authorizable> |
getAuthorizable(java.lang.String id,
java.lang.Class<T> authorizableClass)
Get the Authorizable of a specific type by its id.
|
Authorizable |
getAuthorizableByPath(java.lang.String path)
In accordance to
Authorizable.getPath()
this method allows to retrieve an given authorizable by it's path. |
boolean |
isAutoSave()
If any write operations executed through the User API are automatically
persisted this method returns
true . |
static final int SEARCH_TYPE_USER
User
s should be searched
and returned.static final int SEARCH_TYPE_GROUP
Group
s should be searched
and returned.static final int SEARCH_TYPE_AUTHORIZABLE
Authorizable
s should be
searched.Authorizable getAuthorizable(java.lang.String id) throws RepositoryException
id
- The user or group id.null
, if not present.RepositoryException
- If an error occurs.Authorizable.getID()
<T extends Authorizable> T getAuthorizable(java.lang.String id, java.lang.Class<T> authorizableClass) throws AuthorizableTypeException, RepositoryException
T
- the required Authorizable type.id
- the user or group id.authorizableClass
- the class of the type of Authorizable required; must not be null
.null
, if not present.AuthorizableTypeException
- If an authorizable exists but is not of the requested type.RepositoryException
- If an error occursAuthorizable getAuthorizable(java.security.Principal principal) throws RepositoryException
principal
- The principal of the authorizable to retrieve.null
, if not present.RepositoryException
- If an error occurs.Authorizable getAuthorizableByPath(java.lang.String path) throws UnsupportedRepositoryOperationException, RepositoryException
Authorizable.getPath()
this method allows to retrieve an given authorizable by it's path.path
- The path to an authorizable.null
, if not present.UnsupportedRepositoryOperationException
- If this implementation does
support to retrieve authorizables by path.RepositoryException
- If another error occurs.Authorizable.getPath()
java.util.Iterator<Authorizable> findAuthorizables(java.lang.String relPath, java.lang.String value) throws RepositoryException
Authorizable
s 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.
relPath
- A relative property path or name.value
- A string value to match.Authorizable
s that have a property with the given
name exactly matching the given value.RepositoryException
- If an error occurs.Authorizable.getProperty(String)
java.util.Iterator<Authorizable> findAuthorizables(java.lang.String relPath, java.lang.String value, int searchType) throws RepositoryException
Authorizable
s 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.
relPath
- A relative property path or name.value
- A string value to match.searchType
- Any of the following constants:
Authorizable
.RepositoryException
- If an error occurs.java.util.Iterator<Authorizable> findAuthorizables(Query query) throws RepositoryException
Authorizable
s that match a specific Query
.query
- A queryquery
.RepositoryException
- If an error occurs.User createUser(java.lang.String userID, java.lang.String password) throws AuthorizableExistsException, RepositoryException
null
.createUser(String,String,Principal,String)
where
the specified userID is equal to the principal name and the intermediate
path is null
.userID
- The ID of the new user.password
- The initial password of this user.User
.AuthorizableExistsException
- in case the given userID is already
in use or another Authorizable with the same principal name exists.RepositoryException
- If another error occurs.User createUser(java.lang.String userID, java.lang.String password, java.security.Principal principal, java.lang.String intermediatePath) throws AuthorizableExistsException, RepositoryException
intermediatePath
that parameter should
be ignored.
Except for the intermediatePath
, neither of the specified
parameters can be null
.userID
- The ID of the new user.password
- The initial password of the new user.principal
- The principal of the new user.intermediatePath
- An optional intermediate path used to create the
new user. If the intermediate path is null
an internal,
implementation specific structure will be used.User
.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.User createSystemUser(java.lang.String userID, java.lang.String intermediatePath) throws AuthorizableExistsException, RepositoryException
userID
. The new authorizable
is required to have the following characteristics:
User.isSystemUser()
returns true
.userID
.intermediatePath
.userID
- A valid userID.intermediatePath
- An optional intermediate path to create the new
system user. The implemenation may decide to reject intermediate paths
if they violate an implementation specific requirement with respect to
the location where systems users are being held. If the intermediate path
is null
an internal implementation specific structure will be used.AuthorizableExistsException
- if an Authorizable with this id already exists.RepositoryException
- If another error occurs.Group createGroup(java.lang.String groupID) throws AuthorizableExistsException, RepositoryException
null
.
createGroup(String, Principal,String)
where the specified
groupID is the name of the Principal
the intermediate path
is null
.groupID
- The ID of the new group; must not be null
.Group
.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.Group createGroup(java.security.Principal principal) throws AuthorizableExistsException, RepositoryException
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.principal
- A non-null Principal
Group
.AuthorizableExistsException
- in case the given principal is
already in use with another Authorizable.RepositoryException
- If another error occurs.Group createGroup(java.security.Principal principal, java.lang.String intermediatePath) throws AuthorizableExistsException, RepositoryException
createGroup(String, Principal, String)
where the
name of the specified principal is used to create the group's ID.principal
- The principal associated with the new group.intermediatePath
- An optional intermediate path used to create the
new group. If the intermediate path is null
an internal,
implementation specific structure will be used.Group
.AuthorizableExistsException
- in case the given principal is
already in use with another Authorizable.RepositoryException
- If another error occurs.Group createGroup(java.lang.String groupID, java.security.Principal principal, java.lang.String intermediatePath) throws AuthorizableExistsException, RepositoryException
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.groupID
- The ID of the new group.principal
- The principal of the new group.intermediatePath
- An optional intermediate path used to create the
new group. If the intermediate path is null
an internal,
implementation specific structure will be used.Group
.AuthorizableExistsException
- in case the given principal is already
in use with another Authorizable.RepositoryException
- If another error occurs.boolean isAutoSave()
true
. In this case there are
no pending transient changes left and there is no need to explicitly call
javax.jcr.Session#save()
. If this method returns false
any changes must be completed by an extra save call on the
Session
associated with this UserManager
.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 javax.jcr.Session#save()
.autoSave(boolean)
void autoSave(boolean enable) throws UnsupportedRepositoryOperationException, RepositoryException
UserManager
.
Note, that this shouldn't be allowed in cases where the associated session is different from the original session accessing the user manager.
enable
- If true
changes made through this API will
be automatically saved; otherwise an explicit call to
javax.jcr.Session#save()
is required in order to persist changes.UnsupportedRepositoryOperationException
- If the implementation
does not allow to change the auto save behavior.RepositoryException
- If some other error occurs."Copyright © 2010 - 2020 Adobe Systems Incorporated. All Rights Reserved"