public class DelegatingUserManager extends Object implements UserManager
UserManager
delegating to a set of user managers. The first user manager which does not
throw an UnsupportedOperationException
will be used.ANONYMOUS_USER, SYSTEM_PSWD, SYSTEM_USER
Constructor and Description |
---|
DelegatingUserManager(Map<String,UserManager> delegates) |
Modifier and Type | Method and Description |
---|---|
User |
addGroup(User user,
String groupName)
Adds user to a group.
|
User |
addRole(User user,
String roleName)
Grants user role.
|
User |
changePassword(User user,
String newPassword)
Sets a new password.
|
User |
createUser(String name,
String pw)
Creates a user without security restrictions.
|
User |
createUser(String path,
String name,
String pw)
Creates a user on given path.
|
Map<String,ACL> |
getACLs(User user) |
Collection<User> |
getAllUsers()
Get all users.
|
User |
getAnonymousUser()
Get Anonymous user, this user must always exist in magnolia repository.
|
int |
getLockTimePeriod()
Gets a time period for account lock.
|
int |
getMaxFailedLoginAttempts()
Gets a number of failed attempts before locking account.
|
User |
getSystemUser()
Get system user, this user must always exist in magnolia repository.
|
User |
getUser(String name)
Find a specific user.
|
User |
getUser(Subject subject)
Initialize new user using JAAS authenticated/authorized subject.
|
User |
getUserById(String id)
Find a specific user.
|
Collection<String> |
getUsersWithGroup(String groupName)
Returns all users which are the provided group.
|
Collection<String> |
getUsersWithGroup(String groupName,
boolean transitive)
Returns all users which are in the provided group.
|
Collection<String> |
getUsersWithRole(String roleName) |
boolean |
hasAny(String principal,
String resourceName,
String resourceTypeName) |
User |
removeGroup(User user,
String groupName)
Removes user from a group.
|
User |
removeRole(User user,
String roleName)
Removes role from a user.
|
void |
setLockTimePeriod(int lockTimePeriod)
Sets a time period for account lock.
|
void |
setMaxFailedLoginAttempts(int maxFailedLoginAttempts)
Sets a number of failed attempts before locking account.
|
User |
setProperty(User user,
String propertyName,
String propertyValue)
Sets given property for the user and returns updated user object with new value of the property.
|
User |
setProperty(User user,
String propertyName,
javax.jcr.Value propertyValue)
Sets given property for the user.
|
void |
updateLastAccessTimestamp(User user)
Updates last access timestamp for the user.
|
public DelegatingUserManager(Map<String,UserManager> delegates)
delegates
- public User createUser(String name, String pw) throws UnsupportedOperationException
UserManager
createUser
in interface UserManager
UnsupportedOperationException
- if the current implementation doesn't support this operationpublic User createUser(String path, String name, String pw) throws UnsupportedOperationException
UserManager
createUser
in interface UserManager
UnsupportedOperationException
- if the current implementation doesn't support this operationpublic User changePassword(User user, String newPassword) throws UnsupportedOperationException
UserManager
changePassword
in interface UserManager
UnsupportedOperationException
- if the current implementation doesn't support this operationpublic User getAnonymousUser()
UserManager
getAnonymousUser
in interface UserManager
public User getSystemUser()
UserManager
getSystemUser
in interface UserManager
public User getUser(String name) throws UnsupportedOperationException
UserManager
getUser
in interface UserManager
name
- the name of the userUnsupportedOperationException
public User getUserById(String id) throws UnsupportedOperationException
UserManager
getUserById
in interface UserManager
id
- user identifierUnsupportedOperationException
public User getUser(Subject subject) throws UnsupportedOperationException
UserManager
getUser
in interface UserManager
UnsupportedOperationException
- if the current implementation doesn't support this operationpublic Collection<User> getAllUsers() throws UnsupportedOperationException
UserManager
getAllUsers
in interface UserManager
UnsupportedOperationException
- if the current implementation doesn't support this operationpublic void updateLastAccessTimestamp(User user)
UserManager
updateLastAccessTimestamp
in interface UserManager
public boolean hasAny(String principal, String resourceName, String resourceTypeName)
hasAny
in interface UserManager
principal
- name of the principalresourceName
- either group or role nameresourceTypeName
- either group or role seepublic Map<String,ACL> getACLs(User user)
getACLs
in interface UserManager
public User addRole(User user, String roleName)
UserManager
addRole
in interface UserManager
public User addGroup(User user, String groupName)
UserManager
addGroup
in interface UserManager
public int getLockTimePeriod() throws UnsupportedOperationException
UserManager
getLockTimePeriod
in interface UserManager
UnsupportedOperationException
- if the current implementation doesn't support this operationpublic int getMaxFailedLoginAttempts() throws UnsupportedOperationException
UserManager
getMaxFailedLoginAttempts
in interface UserManager
UnsupportedOperationException
- if the current implementation doesn't support this operationpublic void setLockTimePeriod(int lockTimePeriod) throws UnsupportedOperationException
UserManager
setLockTimePeriod
in interface UserManager
UnsupportedOperationException
- if the current implementation doesn't support this operationpublic void setMaxFailedLoginAttempts(int maxFailedLoginAttempts) throws UnsupportedOperationException
UserManager
setMaxFailedLoginAttempts
in interface UserManager
UnsupportedOperationException
- if the current implementation doesn't support this operationpublic User setProperty(User user, String propertyName, javax.jcr.Value propertyValue) throws UnsupportedOperationException
UserManager
setProperty
in interface UserManager
user
- User to be updated. If property doesn't exist yet, it will be created. If the value is null, property will be removed if existing.propertyName
- Name of the property.propertyValue
- Value of the property. Use org.apache.jackrabbit.value.ValueFactoryImpl to convert type to Value.UnsupportedOperationException
public User setProperty(User user, String propertyName, String propertyValue)
UserManager
setProperty
in interface UserManager
public User removeGroup(User user, String groupName)
UserManager
removeGroup
in interface UserManager
public User removeRole(User user, String roleName)
UserManager
removeRole
in interface UserManager
public Collection<String> getUsersWithGroup(String groupName)
UserManager
getUsersWithGroup
in interface UserManager
groupName
- name of the grouppublic Collection<String> getUsersWithRole(String roleName)
getUsersWithRole
in interface UserManager
public Collection<String> getUsersWithGroup(String groupName, boolean transitive) throws UnsupportedOperationException
UserManager
getUsersWithGroup
in interface UserManager
groupName
- name of the grouptransitive
- whether the method should return also users which are in transitive groups of the given group.UnsupportedOperationException
Copyright © 2003–2018 Magnolia International Ltd.. All rights reserved.