public class JdbcUserDirectory extends CachingComponent<String,User> implements ModifiableUserDirectory, Component, Serviceable, Contextualizable, PluginAware
Modifier and Type | Class and Description |
---|---|
protected class |
JdbcUserDirectory.AbstractJdbcQueryExecutor<T>
An internal query executor.
|
protected static class |
JdbcUserDirectory.JdbcParameterParser
AbstractParameterParser for parsing JdbcParameter . |
class |
JdbcUserDirectory.JdbcPredicate
Class representing a SQL predicate (to use in a WHERE or HAVING clause),
with optional string parameters.
|
protected class |
JdbcUserDirectory.SelectUserJdbcQueryExecutor<T>
Query executor in order to select an user
|
protected class |
JdbcUserDirectory.SelectUsersJdbcQueryExecutor<T>
Query executor in order to select users
|
Modifier and Type | Field and Description |
---|---|
private static String |
__COLUMN_EMAIL |
private static String |
__COLUMN_FIRSTNAME |
private static String |
__COLUMN_LASTNAME |
private static String |
__COLUMN_LOGIN |
private static String |
__COLUMN_PASSWORD |
private static String |
__COLUMN_SALT |
(package private) static String[] |
__COLUMNS |
private static String |
__DATASOURCE_PARAM_NAME
Name of the parameter holding the datasource id
|
private static String |
__USERS_TABLE_PARAM_NAME
Name of the parameter holding the table users' name
|
protected Context |
_context
The avalon context
|
private CurrentUserProvider |
_currentUserProvider |
protected String |
_dataSourceId
The identifier of data source
|
private ThreadSafeComponentManager<Enumerator> |
_enumeratorManager |
private String |
_id |
private String |
_label |
private boolean |
_lazyInitialized |
protected ServiceManager |
_manager
The avalon service manager
|
protected Map<String,JdbcParameter> |
_model
Model
|
private ObservationManager |
_observationManager |
private Map<String,Object> |
_paramValues |
protected String |
_pluginName
Plugin name
|
private String |
_populationId |
protected SourceResolver |
_sourceResolver
The cocoon source resolver
|
private String |
_udModelId |
protected String |
_userTableName
The name of users' SQL table
|
private ThreadSafeComponentManager<Validator> |
_validatorManager |
protected static String |
BASE_PLUGIN_NAME
The base plugin (for i18n key)
|
Constructor and Description |
---|
JdbcUserDirectory() |
Modifier and Type | Method and Description |
---|---|
protected JdbcParameter |
_configureParameter(JdbcUserDirectory.JdbcParameterParser jdbcParameterParser,
String id,
String column)
Configure the parameter (for special handling)
|
protected User |
_createUserFromResultSet(ResultSet rs)
Create the user implementation from the result set of the request
|
protected void |
_fillModifyStatement(PreparedStatement stmt,
Map<String,String> userInformation)
Fill the statement with the user informations
|
protected JdbcUserDirectory.JdbcPredicate |
_getMandatoryPredicate(String pattern)
Get the mandatory predicate to use when querying users by pattern.
|
protected String |
_getPatternToMatch(String pattern)
Get the pattern to match user login
|
protected User |
_getUserProcessResultSet(ResultSet rs,
String login)
Retrieve an user from a result set
|
protected List<User> |
_getUsersProcessResultSet(ResultSet rs)
Populate the user list with the result set
|
protected boolean |
_isMD5Encrypted(String password)
Determines if the password is encrypted with MD5 algorithm
|
protected void |
_updateToSSHAPassword(String login,
String password)
Generate a salt key and encrypt the password with the sha2 algorithm
|
void |
add(Map<String,String> userInformation)
Add a new user to the list.
|
boolean |
checkCredentials(String login,
String password)
Authenticate a user with its credentials
|
protected void |
configureModelParameters()
Configure the edition model parameters
|
void |
contextualize(Context context) |
protected PreparedStatement |
createAddStatement(Connection con,
Map<String,String> userInformation)
Create Add statement
|
protected PreparedStatement |
createModifyStatement(Connection con,
Map<String,String> userInformation)
Create statement to update database
|
void |
dispose() |
protected CurrentUserProvider |
getCurrentUserProvider()
Lazy lookup the
CurrentUserProvider |
String |
getId()
A unique identifier
|
String |
getLabel()
Get the label of the CredentialProvider
|
Collection<? extends Parameter<ParameterHelper.ParameterType>> |
getModel()
Get the user's edition model as a Collection of parameters.
|
protected ObservationManager |
getObservationManager()
Lazy lookup the
ObservationManager |
Map<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.
|
protected Connection |
getSQLConnection()
Get the connection to the database
|
User |
getUser(String login)
Get a particular user by his login.
|
String |
getUserDirectoryModelId()
Get the id of the
UserDirectoryModel extension point |
Collection<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 parameters
|
void |
init(String id,
String udModelId,
Map<String,Object> paramValues,
String label)
Initialize the user's directory with given parameters' values.
|
void |
remove(String login)
Remove an user from the list.
|
void |
service(ServiceManager manager) |
void |
setPluginInfo(String pluginName,
String featureName,
String id)
Sets the plugin info relative to the current component.
Note : The feature name may be null if the targeted component in declared at plugin level. |
void |
setPopulationId(String populationId)
Set the value of the id of the population this user directory belong to.
|
void |
update(Map<String,String> userInformation)
Modify informations about an user of the list.
|
Map<String,Errors> |
validate(Map<String,String> userInformation)
Validate user information.
|
addObjectInCache, clearCache, getObjectFromCache, initialize, isCacheEnabled, removeObjectFromCache
getLogger, setLogger
protected static final String BASE_PLUGIN_NAME
private static final String __DATASOURCE_PARAM_NAME
private static final String __USERS_TABLE_PARAM_NAME
private static final String __COLUMN_LOGIN
private static final String __COLUMN_PASSWORD
private static final String __COLUMN_FIRSTNAME
private static final String __COLUMN_LASTNAME
private static final String __COLUMN_EMAIL
private static final String __COLUMN_SALT
protected String _dataSourceId
protected String _userTableName
protected Map<String,JdbcParameter> _model
protected String _pluginName
protected ServiceManager _manager
protected SourceResolver _sourceResolver
private ThreadSafeComponentManager<Validator> _validatorManager
private ThreadSafeComponentManager<Enumerator> _enumeratorManager
private ObservationManager _observationManager
private CurrentUserProvider _currentUserProvider
private String _udModelId
private Map<String,Object> _paramValues
private String _populationId
private boolean _lazyInitialized
public JdbcUserDirectory()
public void setPluginInfo(String pluginName, String featureName, String id)
PluginAware
setPluginInfo
in interface PluginAware
pluginName
- Unique identifier for the plugin hosting the extensionfeatureName
- Unique feature identifier (unique for a given pluginName)id
- Unique identifier of this componentpublic void contextualize(Context context) throws ContextException
contextualize
in interface Contextualizable
ContextException
public void service(ServiceManager manager) throws ServiceException
service
in interface Serviceable
ServiceException
public void dispose()
dispose
in interface Disposable
dispose
in class CachingComponent<String,User>
public String getId()
UserDirectory
getId
in interface UserDirectory
public String getLabel()
UserDirectory
getLabel
in interface UserDirectory
public void init(String id, String udModelId, Map<String,Object> paramValues, String label)
UserDirectory
init
in interface UserDirectory
id
- The non-null and non-empty unique identifierudModelId
- The id of user directory extension pointparamValues
- The parameters' valueslabel
- The optional labelprotected ObservationManager getObservationManager()
ObservationManager
protected CurrentUserProvider getCurrentUserProvider()
CurrentUserProvider
protected Connection getSQLConnection()
public void setPopulationId(String populationId)
UserDirectory
setPopulationId
in interface UserDirectory
populationId
- The id of the population the user directory belongs to.public String getPopulationId()
UserDirectory
getPopulationId
in interface UserDirectory
public Map<String,Object> getParameterValues()
UserDirectory
getParameterValues
in interface UserDirectory
public String getUserDirectoryModelId()
UserDirectory
UserDirectoryModel
extension pointgetUserDirectoryModelId
in interface UserDirectory
public Collection<User> getUsers()
UserDirectory
getUsers
in interface UserDirectory
User
s, empty if a problem occurs.public List<User> getUsers(int count, int offset, Map<String,Object> parameters)
UserDirectory
getUsers
in interface UserDirectory
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.User
public User getUser(String login)
UserDirectory
getUser
in interface UserDirectory
login
- Login of the user to get. Cannot be null.User
instance or null if the user login does not exist.public boolean checkCredentials(String login, String password)
UserDirectory
checkCredentials
in interface UserDirectory
login
- The login to check. Cannot be null.password
- The password to check.public void add(Map<String,String> userInformation) throws InvalidModificationException
ModifiableUserDirectory
add
in interface ModifiableUserDirectory
userInformation
- Informations about the user, see implementation. Cannot be null.InvalidModificationException
- if the login exists yet or
if at least one of the parameter is invalid.public Map<String,Errors> validate(Map<String,String> userInformation)
ModifiableUserDirectory
validate
in interface ModifiableUserDirectory
userInformation
- Informations about the user, see implementation. Cannot be null.public void update(Map<String,String> userInformation) throws InvalidModificationException
ModifiableUserDirectory
update
in interface ModifiableUserDirectory
userInformation
- New informations about the user, see implementation. Cannot be null.InvalidModificationException
- if the login does not match
in the list or if at least one of the parameter is invalid.public void remove(String login) throws InvalidModificationException
ModifiableUserDirectory
remove
in interface ModifiableUserDirectory
login
- The user's login. Cannot be null.InvalidModificationException
- if the user cannot be removedpublic Collection<? extends Parameter<ParameterHelper.ParameterType>> getModel()
ModifiableUserDirectory
getModel
in interface ModifiableUserDirectory
protected void configureModelParameters()
protected JdbcParameter _configureParameter(JdbcUserDirectory.JdbcParameterParser jdbcParameterParser, String id, String column)
jdbcParameterParser
- the JdbcParameter
parser.id
- Id the of the parametercolumn
- Column name of the parameterprotected JdbcUserDirectory.JdbcPredicate _getMandatoryPredicate(String pattern)
pattern
- The pattern to match, can be null.JdbcUserDirectory.JdbcPredicate
, can be null.protected String _getPatternToMatch(String pattern)
pattern
- the patternprotected boolean _isMD5Encrypted(String password)
password
- The encrypted passwordprotected void _updateToSSHAPassword(String login, String password)
login
- The user loginpassword
- The user paswordprotected PreparedStatement createAddStatement(Connection con, Map<String,String> userInformation) throws SQLException
con
- The sql connectionuserInformation
- the user informationsSQLException
- if an error occurredprotected PreparedStatement createModifyStatement(Connection con, Map<String,String> userInformation) throws SQLException
con
- The sql connectionuserInformation
- The user informationSQLException
- if an error occurredprotected void _fillModifyStatement(PreparedStatement stmt, Map<String,String> userInformation) throws SQLException
stmt
- The statement of the sql requestuserInformation
- the user informationsSQLException
- if an error occurredprotected List<User> _getUsersProcessResultSet(ResultSet rs) throws SQLException
rs
- The result setSQLException
- If an SQL exception occursprotected User _createUserFromResultSet(ResultSet rs) throws SQLException
rs
- The result set where you can use get methodsSQLException
- if an error occurredprotected User _getUserProcessResultSet(ResultSet rs, String login) throws SQLException
rs
- The result setlogin
- The user loginSQLException
- If an SQL Exception occurs