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.
|
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 |
__CACKE_KEY_PREFIX_FOR_EMAIL |
private static String |
__CACKE_KEY_PREFIX_FOR_LOGIN |
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
|
(package private) static String[] |
__ORDERBY_COLUMNS |
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 String |
_id |
private JdbcParameterTypeExtensionPoint |
_jdbcParameterTypeExtensionPoint |
private String |
_label |
private boolean |
_lazyInitialized |
protected ServiceManager |
_manager
The avalon service manager
|
protected Map<String,ElementDefinition> |
_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 View |
_view |
protected static String |
BASE_PLUGIN_NAME
The base plugin (for i18n key)
|
Constructor and Description |
---|
JdbcUserDirectory() |
Modifier and Type | Method and Description |
---|---|
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,
String cachePrefix)
Retrieve an user from a result set
|
protected List<User> |
_getUsersProcessResultSet(ResultSet rs,
String cachePrefix)
Populate the user list with the result set
|
private void |
_initModelParameter(String name,
String parameterType,
String labelKey,
String descriptionKey,
Validator validator) |
private void |
_initModelParameters() |
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
|
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
|
protected CurrentUserProvider |
getCurrentUserProvider()
Lazy lookup the
CurrentUserProvider |
String |
getFamilyId()
Retrieves the Family Id (for example the extension point)
Each model Id have to be unique in it's family Id
|
String |
getId()
A unique identifier
|
String |
getLabel()
Get the label of the CredentialProvider
|
Collection<? extends ModelItem> |
getModelItems()
Retrieves all the model items of this container
|
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.
|
User |
getUserByEmail(String email)
Get a particular user by his email.
|
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
|
View |
getView()
Retrieve the view of the Model
|
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, dispose, getObjectFromCache, initialize, isCacheEnabled, removeObjectFromCache
getLogger, setLogger
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
getChild, getModelItem, hasModelItem
protected static final String BASE_PLUGIN_NAME
static final String[] __ORDERBY_COLUMNS
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
private static final String __CACKE_KEY_PREFIX_FOR_LOGIN
private static final String __CACKE_KEY_PREFIX_FOR_EMAIL
protected String _dataSourceId
protected String _userTableName
protected Map<String,ElementDefinition> _model
protected String _pluginName
protected ServiceManager _manager
protected SourceResolver _sourceResolver
private ObservationManager _observationManager
private CurrentUserProvider _currentUserProvider
private String _udModelId
private Map<String,Object> _paramValues
private String _populationId
private boolean _lazyInitialized
private JdbcParameterTypeExtensionPoint _jdbcParameterTypeExtensionPoint
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 String getId()
UserDirectory
getId
in interface UserDirectory
getId
in interface Model
public String getFamilyId()
Model
getFamilyId
in interface Model
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 labelprivate void _initModelParameters()
private void _initModelParameter(String name, String parameterType, String labelKey, String descriptionKey, Validator validator)
protected 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 User getUserByEmail(String email) throws NotUniqueUserException
UserDirectory
getUserByEmail
in interface UserDirectory
email
- Email of the user to get. Cannot be null.User
instance or null if the user email does not exist.NotUniqueUserException
- If many users match this emailpublic 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 ModelItem> getModelItems()
ModelItemContainer
getModelItems
in interface ModelItemContainer
protected 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, String cachePrefix) throws SQLException
rs
- The result setcachePrefix
- the prefix to use for cacheSQLException
- 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, String cachePrefix) throws SQLException
rs
- The result setlogin
- The user logincachePrefix
- the prefix to use for cacheSQLException
- If an SQL Exception occurspublic View getView()
ModifiableUserDirectory
getView
in interface ModifiableUserDirectory