Class UserManagerImpl
- java.lang.Object
-
- org.apache.jackrabbit.oak.security.user.UserManagerImpl
-
- All Implemented Interfaces:
UserManager
public class UserManagerImpl extends Object implements UserManager
UserManagerImpl...
-
-
Field Summary
-
Fields inherited from interface org.apache.jackrabbit.api.security.user.UserManager
SEARCH_TYPE_AUTHORIZABLE, SEARCH_TYPE_GROUP, SEARCH_TYPE_USER
-
-
Constructor Summary
Constructors Constructor Description UserManagerImpl(@NotNull Root root, @NotNull PartialValueFactory valueFactory, @NotNull SecurityProvider securityProvider, @NotNull UserMonitor monitor, @NotNull DynamicMembershipService dynamicMembershipService)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
autoSave(boolean enable)
Changing the auto-save behavior is not supported by this implementation and this method always throwsUnsupportedRepositoryOperationException
@NotNull Group
createGroup(@NotNull String groupId)
Creates a Group for the given groupID, which must not benull
.@NotNull Group
createGroup(@NotNull String groupID, @NotNull Principal principal, @Nullable String intermediatePath)
Creates a newGroup
that is based on the given id, principal and the specifiedintermediatePath
hint.@NotNull Group
createGroup(@NotNull Principal principal)
Creates a newGroup
that is based on the given principal.@NotNull Group
createGroup(@NotNull Principal principal, @Nullable String intermediatePath)
Same asUserManager.createGroup(String, Principal, String)
where the name of the specified principal is used to create the group's ID.@NotNull User
createSystemUser(@NotNull String userID, @Nullable String intermediatePath)
Create a new system user for the specifieduserID
.@NotNull User
createUser(@NotNull String userID, @Nullable String password)
Creates a user for the given userID / password pair.@NotNull User
createUser(@NotNull String userID, @Nullable String password, @NotNull Principal principal, @Nullable String intermediatePath)
Creates a user for the given parameters.@NotNull Iterator<Authorizable>
findAuthorizables(@NotNull String relPath, @Nullable String value)
Returns allAuthorizable
s that have aproperty
with the given relative path (or name) that matches the specified value.@NotNull Iterator<Authorizable>
findAuthorizables(@NotNull String relPath, @Nullable String value, int searchType)
Returns allAuthorizable
s that have aproperty
with the given relative path (or name) that matches the specified value.@NotNull Iterator<Authorizable>
findAuthorizables(@NotNull Query query)
ReturnAuthorizable
s that match a specificQuery
.@Nullable Authorizable
getAuthorizable(@NotNull String id)
Get the Authorizable by its id.<T extends Authorizable>
TgetAuthorizable(@NotNull String id, @NotNull Class<T> authorizableClass)
Get the Authorizable of a specific type by its id.@Nullable Authorizable
getAuthorizable(@NotNull Principal principal)
Get the Authorizable by its Principal.@Nullable Authorizable
getAuthorizable(@Nullable Tree tree)
@Nullable Authorizable
getAuthorizableByPath(@NotNull String path)
In accordance toAuthorizable.getPath()
this method allows to retrieve an given authorizable by it's path.boolean
isAutoSave()
Always returnsfalse
.
-
-
-
Constructor Detail
-
UserManagerImpl
public UserManagerImpl(@NotNull @NotNull Root root, @NotNull @NotNull PartialValueFactory valueFactory, @NotNull @NotNull SecurityProvider securityProvider, @NotNull @NotNull UserMonitor monitor, @NotNull @NotNull DynamicMembershipService dynamicMembershipService)
-
-
Method Detail
-
getAuthorizable
@Nullable public @Nullable Authorizable getAuthorizable(@NotNull @NotNull String id) throws RepositoryException
Description copied from interface:UserManager
Get the Authorizable by its id.- Specified by:
getAuthorizable
in interfaceUserManager
- 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
@Nullable public <T extends Authorizable> T getAuthorizable(@NotNull @NotNull String id, @NotNull @NotNull Class<T> authorizableClass) throws RepositoryException
Description copied from interface:UserManager
Get the Authorizable of a specific type by its id.- Specified by:
getAuthorizable
in interfaceUserManager
- Type Parameters:
T
- the required Authorizable type.- Parameters:
id
- the user or group id.authorizableClass
- the class of the type of Authorizable required; must not benull
.- Returns:
- Authorizable or
null
, if not present. - Throws:
AuthorizableTypeException
- If an authorizable exists but is not of the requested type.RepositoryException
- If an error occurs
-
getAuthorizable
@Nullable public @Nullable Authorizable getAuthorizable(@NotNull @NotNull Principal principal) throws RepositoryException
Description copied from interface:UserManager
Get the Authorizable by its Principal.- Specified by:
getAuthorizable
in interfaceUserManager
- Parameters:
principal
- The principal of the authorizable to retrieve.- Returns:
- Authorizable or
null
, if not present. - Throws:
RepositoryException
- If an error occurs.
-
getAuthorizableByPath
@Nullable public @Nullable Authorizable getAuthorizableByPath(@NotNull @NotNull String path) throws RepositoryException
Description copied from interface:UserManager
In accordance toAuthorizable.getPath()
this method allows to retrieve an given authorizable by it's path.- Specified by:
getAuthorizableByPath
in interfaceUserManager
- Parameters:
path
- The path to an authorizable.- Returns:
- Authorizable or
null
, if not present. - Throws:
UnsupportedRepositoryOperationException
- If this implementation does not support to retrieve authorizables by path.RepositoryException
- If another error occurs.- See Also:
Authorizable.getPath()
-
findAuthorizables
@NotNull public @NotNull Iterator<Authorizable> findAuthorizables(@NotNull @NotNull String relPath, @Nullable @Nullable String value) throws RepositoryException
Description copied from interface:UserManager
Returns allAuthorizable
s that have aproperty
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.- Specified by:
findAuthorizables
in interfaceUserManager
- Parameters:
relPath
- A relative property path or name.value
- A string value to match.- Returns:
- All
Authorizable
s 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
@NotNull public @NotNull Iterator<Authorizable> findAuthorizables(@NotNull @NotNull String relPath, @Nullable @Nullable String value, int searchType) throws RepositoryException
Description copied from interface:UserManager
Returns allAuthorizable
s that have aproperty
with the given relative path (or name) that matches the specified value. In contrast toUserManager.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.- Specified by:
findAuthorizables
in interfaceUserManager
- Parameters:
relPath
- A relative property path or name.value
- A string value to match.searchType
- Any of the following constants:- Returns:
- An iterator of
Authorizable
. - Throws:
RepositoryException
- If an error occurs.
-
findAuthorizables
@NotNull public @NotNull Iterator<Authorizable> findAuthorizables(@NotNull @NotNull Query query) throws RepositoryException
Description copied from interface:UserManager
ReturnAuthorizable
s that match a specificQuery
.- Specified by:
findAuthorizables
in interfaceUserManager
- Parameters:
query
- A query- Returns:
- Iterator of authorizables witch match the
query
. - Throws:
RepositoryException
- If an error occurs.
-
createUser
@NotNull public @NotNull User createUser(@NotNull @NotNull String userID, @Nullable @Nullable String password) throws RepositoryException
Description copied from interface:UserManager
Creates a user for the given userID / password pair.
Same asUserManager.createUser(String,String,Principal,String)
where the specified userID is equal to the principal name and the intermediate path isnull
.- Specified by:
createUser
in interfaceUserManager
- 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
@NotNull public @NotNull User createUser(@NotNull @NotNull String userID, @Nullable @Nullable String password, @NotNull @NotNull Principal principal, @Nullable @Nullable String intermediatePath) throws RepositoryException
Description copied from interface:UserManager
Creates a user for the given parameters. If the implementation is not able to deal with theintermediatePath
that parameter should be ignored. Except for theintermediatePath
andpassword
, neither of the specified parameters can benull
.The given password may be
null
however the behavior of such users depend on the implementation (usually those users cannot be used for authentication but only for impersonation). Consider usingUserManager.createSystemUser(String, String)
rather than creating a user with anull
password with this method.- Specified by:
createUser
in interfaceUserManager
- Parameters:
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 isnull
an internal, implementation specific structure will be used.- 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.- See Also:
UserManager.createSystemUser(String, String)
-
createSystemUser
@NotNull public @NotNull User createSystemUser(@NotNull @NotNull String userID, @Nullable @Nullable String intermediatePath) throws RepositoryException
Description copied from interface:UserManager
Create a new system user for the specifieduserID
. The new authorizable is required to have the following characteristics:User.isSystemUser()
returnstrue
.- The system user doesn't have a password set and doesn't allow change the password.
- The principal name is generated by the system; it may be the same as
userID
. - A given implementation may choose to keep system users in a dedicated
location and thus may impose restrictions on the
intermediatePath
.
- Specified by:
createSystemUser
in interfaceUserManager
- Parameters:
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 isnull
an internal implementation specific structure will be used.- Returns:
- The new system user.
- Throws:
AuthorizableExistsException
- if an Authorizable with this id already exists.RepositoryException
- If another error occurs.
-
createGroup
@NotNull public @NotNull Group createGroup(@NotNull @NotNull String groupId) throws RepositoryException
Description copied from interface:UserManager
Creates a Group for the given groupID, which must not benull
.
Same asUserManager.createGroup(String, Principal,String)
where the specified groupID is the name of thePrincipal
the intermediate path isnull
.- Specified by:
createGroup
in interfaceUserManager
- Parameters:
groupId
- The ID of the new group; must not benull
.- Returns:
- The new
Group
. - Throws:
AuthorizableExistsException
- in case the given groupID is already in use or anotherAuthorizable
with the sameID
or principal name already exists.RepositoryException
- If another error occurs.
-
createGroup
@NotNull public @NotNull Group createGroup(@NotNull @NotNull Principal principal) throws RepositoryException
Description copied from interface:UserManager
Creates a newGroup
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.- Specified by:
createGroup
in interfaceUserManager
- Parameters:
principal
- A non-nullPrincipal
- Returns:
- The new
Group
. - Throws:
AuthorizableExistsException
- in case the given principal is already in use with another Authorizable.RepositoryException
- If another error occurs.
-
createGroup
@NotNull public @NotNull Group createGroup(@NotNull @NotNull Principal principal, @Nullable @Nullable String intermediatePath) throws RepositoryException
Description copied from interface:UserManager
Same asUserManager.createGroup(String, Principal, String)
where the name of the specified principal is used to create the group's ID.- Specified by:
createGroup
in interfaceUserManager
- Parameters:
principal
- The principal associated with the new group.intermediatePath
- An optional intermediate path used to create the new group. If the intermediate path isnull
an internal, implementation specific structure will be used.- Returns:
- The new
Group
. - Throws:
AuthorizableExistsException
- in case the given principal is already in use with another Authorizable.RepositoryException
- If another error occurs.
-
createGroup
@NotNull public @NotNull Group createGroup(@NotNull @NotNull String groupID, @NotNull @NotNull Principal principal, @Nullable @Nullable String intermediatePath) throws RepositoryException
Description copied from interface:UserManager
Creates a newGroup
that is based on the given id, principal and the specifiedintermediatePath
hint. If the implementation is not able to deal with theintermediatePath
this parameter should be ignored.- Specified by:
createGroup
in interfaceUserManager
- Parameters:
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 isnull
an internal, implementation specific structure will be used.- Returns:
- The new
Group
. - Throws:
AuthorizableExistsException
- in case the given principal is already in use with another Authorizable.RepositoryException
- If another error occurs.
-
isAutoSave
public boolean isAutoSave()
Always returnsfalse
. Any modifications made to this user manager instance require a subsequent call toSession.save()
in order to have the changes persisted.- Specified by:
isAutoSave
in interfaceUserManager
- Returns:
true
if changes are automatically persisted;false
if changes made through this API (including method calls onAuthorizable
and subclasses are only transient and must be persisted usingSession.save()
.- See Also:
UserManager.autoSave(boolean)
-
autoSave
public void autoSave(boolean enable) throws RepositoryException
Changing the auto-save behavior is not supported by this implementation and this method always throwsUnsupportedRepositoryOperationException
- Specified by:
autoSave
in interfaceUserManager
- Parameters:
enable
- Iftrue
changes made through this API will be automatically saved; otherwise an explicit call toSession.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.
-
getAuthorizable
@Nullable public @Nullable Authorizable getAuthorizable(@Nullable @Nullable Tree tree) throws RepositoryException
- Throws:
RepositoryException
-
-