Class StaticUserDirectory
- java.lang.Object
-
- org.ametys.runtime.plugin.component.AbstractLogEnabled
-
- org.ametys.plugins.core.impl.user.directory.StaticUserDirectory
-
- All Implemented Interfaces:
UserDirectory
,LogEnabled
,Component
public class StaticUserDirectory extends AbstractLogEnabled implements UserDirectory, Component
This implementation only uses predefined users
-
-
Field Summary
Fields Modifier and Type Field Description private static String
__PARAM_USERS
private boolean
_grantAllCredentials
private String
_id
private String
_label
private Map<String,Object>
_paramValues
private String
_populationId
private Map<String,User>
_staticUsers
private String
_udModelId
-
Constructor Summary
Constructors Constructor Description StaticUserDirectory()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description private User
_createUser(String userLine)
private boolean
_isLike(User user, String pattern)
boolean
checkCredentials(String login, String password)
Authenticate a user with its credentialsString
getId()
A unique identifierString
getLabel()
Get the label of the CredentialProviderMap<String,Object>
getParameterValues()
Get the values of parameters (from user directory model)String
getPopulationId()
Get the id of the population this user directory belongs to.User
getUser(String login)
Get a particular user by his login.User
getUserByEmail(String email)
Get a particular user by his email.String
getUserDirectoryModelId()
Get the id of theUserDirectoryModel
extension pointCollection<User>
getUsers()
Get the list of all users of one directory.List<User>
getUsers(int count, int offset, Map<String,Object> parameters)
Get a list of users from a directory given the parametersvoid
init(String id, String udModelId, Map<String,Object> paramValues, String label)
Initialize the user's directory with given parameters' values.void
setGrantAllCredentials(boolean grantAllCredentials)
Set to false to disallow any user to be authenticated by its credentialsvoid
setPopulationId(String populationId)
Set the value of the id of the population this user directory belong to.-
Methods inherited from class org.ametys.runtime.plugin.component.AbstractLogEnabled
getLogger, setLogger
-
-
-
-
Field Detail
-
__PARAM_USERS
private static final String __PARAM_USERS
- See Also:
- Constant Field Values
-
_staticUsers
private Map<String,User> _staticUsers
-
_udModelId
private String _udModelId
-
_paramValues
private Map<String,Object> _paramValues
-
_populationId
private String _populationId
-
_grantAllCredentials
private boolean _grantAllCredentials
-
-
Constructor Detail
-
StaticUserDirectory
public StaticUserDirectory()
-
-
Method Detail
-
getId
public String getId()
Description copied from interface:UserDirectory
A unique identifier- Specified by:
getId
in interfaceUserDirectory
- Returns:
- The non-null and non-empty identifier
-
getLabel
public String getLabel()
Description copied from interface:UserDirectory
Get the label of the CredentialProvider- Specified by:
getLabel
in interfaceUserDirectory
- Returns:
- The optionnal label
-
init
public void init(String id, String udModelId, Map<String,Object> paramValues, String label)
Description copied from interface:UserDirectory
Initialize the user's directory with given parameters' values.- Specified by:
init
in interfaceUserDirectory
- Parameters:
id
- The non-null and non-empty unique identifierudModelId
- The id of user directory extension pointparamValues
- The parameters' valueslabel
- The optional label
-
setPopulationId
public void setPopulationId(String populationId)
Description copied from interface:UserDirectory
Set the value of the id of the population this user directory belong to.- Specified by:
setPopulationId
in interfaceUserDirectory
- Parameters:
populationId
- The id of the population the user directory belongs to.
-
getPopulationId
public String getPopulationId()
Description copied from interface:UserDirectory
Get the id of the population this user directory belongs to.- Specified by:
getPopulationId
in interfaceUserDirectory
- Returns:
- The id of the population
-
getParameterValues
public Map<String,Object> getParameterValues()
Description copied from interface:UserDirectory
Get the values of parameters (from user directory model)- Specified by:
getParameterValues
in interfaceUserDirectory
- Returns:
- the parameters' values
-
setGrantAllCredentials
public void setGrantAllCredentials(boolean grantAllCredentials)
Set to false to disallow any user to be authenticated by its credentials- Parameters:
grantAllCredentials
- true if the directory should grant all call to checkCredentials
-
getUserDirectoryModelId
public String getUserDirectoryModelId()
Description copied from interface:UserDirectory
Get the id of theUserDirectoryModel
extension point- Specified by:
getUserDirectoryModelId
in interfaceUserDirectory
- Returns:
- the id of extension point
-
getUsers
public Collection<User> getUsers()
Description copied from interface:UserDirectory
Get the list of all users of one directory.- Specified by:
getUsers
in interfaceUserDirectory
- Returns:
- list of users as Collection of
User
s, empty if a problem occurs.
-
getUsers
public List<User> getUsers(int count, int offset, Map<String,Object> parameters)
Description copied from interface:UserDirectory
Get a list of users from a directory given the parameters- Specified by:
getUsers
in interfaceUserDirectory
- Parameters:
count
- The limit of users to retrieveoffset
- The number of result to ignore before starting to collect users.parameters
- A map of additional parameters, see implementation.- Returns:
- The list of retrieved
User
-
getUser
public User getUser(String login)
Description copied from interface:UserDirectory
Get a particular user by his login.- Specified by:
getUser
in interfaceUserDirectory
- Parameters:
login
- Login of the user to get. Cannot be null.- Returns:
- User's information as a
User
instance or null if the user login does not exist.
-
getUserByEmail
public User getUserByEmail(String email) throws NotUniqueUserException
Description copied from interface:UserDirectory
Get a particular user by his email.- Specified by:
getUserByEmail
in interfaceUserDirectory
- Parameters:
email
- Email of the user to get. Cannot be null.- Returns:
- User's information as a
User
instance or null if the user email does not exist. - Throws:
NotUniqueUserException
- If many users match this email
-
checkCredentials
public boolean checkCredentials(String login, String password)
Description copied from interface:UserDirectory
Authenticate a user with its credentials- Specified by:
checkCredentials
in interfaceUserDirectory
- Parameters:
login
- The login to check. Cannot be null.password
- The password to check.- Returns:
- true if the user is authenticated, false otherwise.
-
_createUser
private User _createUser(String userLine)
-
-