Package org.ametys.plugins.core.user
Class UserDAO
java.lang.Object
org.apache.avalon.framework.logger.AbstractLogEnabled
org.ametys.plugins.core.user.UserDAO
- All Implemented Interfaces:
Component
,Contextualizable
,LogEnabled
,Serviceable
DAO for manipulating
User
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic class
A fake credential provider used by the impersonate process -
Field Summary
FieldsModifier and TypeFieldDescriptionprotected Context
The Avalon contextprotected CurrentUserProvider
The current user provider.protected GroupManager
The group managerprotected PopulationContextHelper
The population context helperprotected RightManager
The right managerprotected ServiceManager
The service managerprotected UserHelper
The user helperprotected UserManager
The user managerprotected UserPopulationDAO
The user population DAOstatic final String
The avalon role -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprotected boolean
_canHandle
(String populationId) Check current user can handle the population of usersprotected UserIdentity
Provides the login of the current user._getSearchParameters
(String searchCriteria) Get the search parametersCreates a Uservoid
contextualize
(Context context) deleteUsers
(List<Map<String, String>> users) Deletes usersEdits a UsergetEditionModelForDirectory
(String populationId, String userDirectoryId) Get the users edition modelgetEditionModelForUSer
(String login, String populationId) Get the users edition modelgetStoredUser
(String login, String populationId) Get user's informationGet user's informationgetUsersByUserIdentitiesAndContexts
(List<String> userIdentities, List<String> contexts, Boolean limitedToStoredUserData) Get the list of users for given user identities in given contextsimpersonate
(String login, String populationId) Impersonate the selected userisModifiable
(String login, String populationId) Checks if the user is modifiable and if current user is allowed to edit itisRemovable
(String login, String populationId) Checks if the user is removable and if current user is allowed to remove itsearchUsersByContexts
(List<String> contexts, Integer limit, Integer offset, String searchCriteria, Boolean limitedToStoredUserData) Search for users in given contextssearchUsersByDirectory
(String userDirectoryId, String userPopulationId, Integer limit, Integer offset, String searchCriteria, Boolean limitedToStoredUserData) Search for users in given user directorysearchUsersByPopulation
(String userPopulationId, Integer limit, Integer offset, String searchCriteria, Boolean limitedToStoredUserData) Search for users in given user populationvoid
service
(ServiceManager smanager) Methods inherited from class org.apache.avalon.framework.logger.AbstractLogEnabled
enableLogging, getLogger, setupLogger, setupLogger, setupLogger
-
Field Details
-
ROLE
The avalon role -
_smanager
The service manager -
_userManager
The user manager -
_userPopulationDAO
The user population DAO -
_populationContextHelper
The population context helper -
_currentUserProvider
The current user provider. -
_context
The Avalon context -
_userHelper
The user helper -
_rightManager
The right manager -
_groupManager
The group manager
-
-
Constructor Details
-
UserDAO
public UserDAO()
-
-
Method Details
-
contextualize
- Specified by:
contextualize
in interfaceContextualizable
- Throws:
ContextException
-
service
- Specified by:
service
in interfaceServiceable
- Throws:
ServiceException
-
getUsersByUserIdentitiesAndContexts
public List<Map<String,Object>> getUsersByUserIdentitiesAndContexts(List<String> userIdentities, List<String> contexts, Boolean limitedToStoredUserData) Get the list of users for given user identities in given contexts- Parameters:
userIdentities
- The user identities to search forcontexts
- The contexts The context in which to find the users. Can be null. Defaults to the current context. If no contexts are found, the current user need to have admin rights.limitedToStoredUserData
-true
to only retrieve the data from stored user,false
to retrieve everything. Can be null. Defaults to "false"- Returns:
- a non-null list of users
-
searchUsersByContexts
public List<Map<String,Object>> searchUsersByContexts(List<String> contexts, Integer limit, Integer offset, String searchCriteria, Boolean limitedToStoredUserData) Search for users in given contexts- Parameters:
contexts
- The context in which to find the users. Cannot be null.limit
- The limit of results. Can be null. Defaults to value_DEFAULT_SEARCH_COUNT_VALUE
.offset
- The offset, where to start returning results (offset). Can be null. Defaults to value_DEFAULT_SEARCH_OFFSET_VALUE
searchCriteria
- The criteria (pattern) for the search. Can be null.limitedToStoredUserData
-true
to only retrieve the data from stored user,false
to retrieve everything. Can be null. Defaults to "false"- Returns:
- a non-null list of users
-
searchUsersByDirectory
public List<Map<String,Object>> searchUsersByDirectory(String userDirectoryId, String userPopulationId, Integer limit, Integer offset, String searchCriteria, Boolean limitedToStoredUserData) Search for users in given user directory- Parameters:
userDirectoryId
- The id of the user directory in which to find the users. Cannot be null.userPopulationId
- The id of the user population in which to find the users. Cannot be null.limit
- The limit of results. Can be null. Defaults to value_DEFAULT_SEARCH_COUNT_VALUE
.offset
- The offset, where to start returning results (offset). Can be null. Defaults to value_DEFAULT_SEARCH_OFFSET_VALUE
searchCriteria
- The criteria (pattern) for the search. Can be null.limitedToStoredUserData
-true
to only retrieve the data from stored user,false
to retrieve everything. Can be null. Defaults to "false"- Returns:
- a non-null list of users
-
searchUsersByPopulation
public List<Map<String,Object>> searchUsersByPopulation(String userPopulationId, Integer limit, Integer offset, String searchCriteria, Boolean limitedToStoredUserData) Search for users in given user population- Parameters:
userPopulationId
- The id of the user population in which to find the users. Cannot be null.limit
- The limit of results. Can be null. Defaults to value_DEFAULT_SEARCH_COUNT_VALUE
.offset
- The offset, where to start returning results (offset). Can be null. Defaults to value_DEFAULT_SEARCH_OFFSET_VALUE
searchCriteria
- The criteria (pattern) for the search. Can be null.limitedToStoredUserData
-true
to only retrieve the data from stored user,false
to retrieve everything. Can be null. Defaults to "false"- Returns:
- a non-null list of users
-
_getSearchParameters
Get the search parameters- Parameters:
searchCriteria
- The search pattern- Returns:
- the search parameters
-
getUser
Get user's information- Parameters:
login
- The user's loginpopulationId
- The id of the population- Returns:
- The user's information
-
getStoredUser
Get user's information- Parameters:
login
- The user's loginpopulationId
- The id of the population- Returns:
- The user's information
-
isModifiable
Checks if the user is modifiable and if current user is allowed to edit it- Parameters:
login
- The users's loginpopulationId
- The id of the population of the user- Returns:
- A map with the "isModifiable" at true if the user is modifiable
-
isRemovable
Checks if the user is removable and if current user is allowed to remove it- Parameters:
login
- The users's loginpopulationId
- The id of the population of the user- Returns:
- A map with the "isRemovable" at true if the user is removable
-
addUser
public Map<String,Object> addUser(String populationId, String userDirectoryId, Map<String, String> untypedValues) throws InvalidModificationExceptionCreates a User- Parameters:
populationId
- The id of the user populationuserDirectoryId
- The id of the user directoryuntypedValues
- The untyped user's parameters- Returns:
- The created user as JSON object
- Throws:
InvalidModificationException
- If modification is not possible
-
_canHandle
Check current user can handle the population of users- Parameters:
populationId
- the id of population- Returns:
- true if user is allowed to handle this population
-
editUser
public Map<String,Object> editUser(String populationId, Map<String, String> untypedValues) throws InvalidModificationExceptionEdits a User- Parameters:
populationId
- The id of the population of the user to edituntypedValues
- The untyped user's parameters- Returns:
- The update user as JSON object
- Throws:
InvalidModificationException
- If modification is not possible
-
deleteUsers
public Map<String,Object> deleteUsers(List<Map<String, String>> users) throws InvalidModificationExceptionDeletes users- Parameters:
users
- The users to delete- Returns:
- the result with deleted users and undeleted users
- Throws:
InvalidModificationException
- If modification is not possible
-
getEditionModelForUSer
public Map<String,Object> getEditionModelForUSer(String login, String populationId) throws InvalidModificationException Get the users edition model- Parameters:
login
- The user's login to editpopulationId
- The id of the population of the user to edit- Returns:
- The edition model as an object
- Throws:
InvalidModificationException
- If modification is not possible
-
getEditionModelForDirectory
public Map<String,Object> getEditionModelForDirectory(String populationId, String userDirectoryId) throws InvalidModificationException Get the users edition model- Parameters:
populationId
- The id of the population where to add a useruserDirectoryId
- The id of the user directory where to add a user- Returns:
- The edition model as an object
- Throws:
InvalidModificationException
- If modification is not possible
-
impersonate
public Map<String,String> impersonate(String login, String populationId) throws AccessDeniedException Impersonate the selected user- Parameters:
login
- the login of the user to impersonatepopulationId
- The id of the population- Returns:
- a map of information on the user
- Throws:
AccessDeniedException
- If the currently connected user has no right to do so
-
_getCurrentUser
Provides the login of the current user.- Returns:
- the login which cannot be
null
.
-