public class UserPopulationDAO extends AbstractLogEnabled implements Component, Serviceable, Initializable, Disposable
UserPopulation
Modifier and Type | Field and Description |
---|---|
private static String |
__ADMIN_TABLENAME
The sql table for admin users
|
private static String |
__ID_REGEX
The regular expression for an id of a user population
|
private static File |
__USER_POPULATIONS_FILE
The path of the XML file containing the user populations
|
private UserPopulation |
_adminUserPopulation
The population admin
|
private CredentialProviderFactory |
_credentialProviderFactory
The credential providers factory
|
private CurrentUserProvider |
_currentUserProvider |
private I18nUtils |
_i18nutils |
private Set<String> |
_ignoredPopulations
The list of population ids which are declared in the user population file but were not instanciated since their configuration led to an error
|
private long |
_lastFileReading
The date (as a long) of the last time the
Populations file was read (last update) |
private Set<String> |
_misconfiguredUserPopulations
The misconfigured user populations
|
private ObservationManager |
_observationManager |
private PopulationConsumerExtensionPoint |
_populationConsumerEP
The extension point for population consumers
|
private UserDirectoryFactory |
_userDirectoryFactory
The user directories factory
|
private Map<String,UserPopulation> |
_userPopulations
The whole user populations of the application
|
static String |
ADMIN_POPULATION_ID
The id of the "admin" population
|
static String |
ROLE
Avalon Role
|
static UserIdentity |
SYSTEM_USER_IDENTITY
The id of the "user system" population
|
static String |
SYSTEM_USER_LOGIN
The id of the "user system" login
|
Constructor and Description |
---|
UserPopulationDAO() |
Modifier and Type | Method and Description |
---|---|
private List<CredentialProvider> |
_configureCredentialProviders(Configuration configuration,
String upId) |
private UserPopulation |
_configurePopulation(Configuration configuration,
Set<String> misconfiguredUserPopulations) |
private List<UserDirectory> |
_configureUserDirectories(Configuration configuration,
String upId,
Set<String> misconfiguredUserPopulations) |
private void |
_createPopulationsFile(File file) |
private void |
_fillUserPopulation(UserPopulation up,
I18nizableText label,
List<Map<String,String>> userDirectories,
List<Map<String,String>> credentialProviders) |
private Map<String,Object> |
_getCPParametersFromConfiguration(Configuration conf,
String modelId,
String populationId)
Get the typed parameters of a credential provider used by a population
|
private Map<String,Object> |
_getTypedCPParameters(Map<String,String> parameters,
String modelId) |
private Map<String,Object> |
_getTypedUDParameters(Map<String,String> parameters,
String modelId) |
private Map<String,Object> |
_getUDParametersFromConfiguration(Configuration conf,
String modelId,
String populationId)
Get the typed parameters of a user directory used by a population
|
private boolean |
_isCorrectId(String id) |
private void |
_keepExistingCredentialProviderPassword(UserPopulation up,
String modelId,
Map<String,Object> typedParamValues,
String id) |
private void |
_keepExistingUserDirectoryPassword(UserPopulation up,
String modelId,
Map<String,Object> typedParamValues,
String id) |
private void |
_readPopulations(boolean forceRead)
If needed, reads the config file representing the populations and then
reinitializes and updates the internal representation of the populations.
|
private void |
_saxUserPopulation(UserPopulation userPopulation,
TransformerHandler handler) |
private void |
_toSAX(TransformerHandler handler) |
private boolean |
_writePopulations()
Erases the config file representing the populations and rebuild it
from the internal representation of the populations.
|
Map<String,Object> |
add(String id,
String label,
List<Map<String,String>> userDirectories,
List<Map<String,String>> credentialProviders)
Adds a new population
|
Map<String,Object> |
canRemove(String populationId)
Determines if a population can be removed
|
void |
dispose() |
Map<String,Object> |
edit(String id,
String label,
List<Map<String,String>> userDirectories,
List<Map<String,String>> credentialProviders)
Edits the given population.
|
Map<String,Object> |
enable(String populationId,
boolean enabled)
Enables/Disables the given population
|
UserPopulation |
getAdminPopulation()
Gets the "admin" population
|
InputStream |
getConfigurationFile()
Return the stream of the configuration file
|
Map<String,Object> |
getEditionConfiguration()
Gets the configuration for creating/editing a user population.
|
List<UserPopulation> |
getEnabledUserPopulations(boolean withAdmin)
Gets all the enabled populations of this application
|
Set<String> |
getIgnoredPopulations()
Returns the id of population which have a fatal invalid configuration.
|
Set<String> |
getMisconfiguredPopulations()
Returns the id of population which have at least one user directory or one credential provider misconfigured
These populations can be used by application.
|
Map<String,Object> |
getPopulationParameterValues(String id)
Gets the values of the parameters of the given population
|
UserPopulation |
getUserPopulation(String id)
Gets a population with its id.
|
Map<String,Object> |
getUserPopulationAsJson(UserPopulation userPopulation)
Gets a population to JSON format
|
List<UserPopulation> |
getUserPopulations(boolean includeAdminPopulation)
Gets all the populations of this application
|
List<Object> |
getUserPopulationsAsJson(boolean withAdmin)
Gets all the populations to JSON format
|
List<String> |
getUserPopulationsIds()
Gets the list of the ids of all the population of the application
|
void |
initialize() |
Map<String,Object> |
isEnabled(String populationId)
Returns the enabled state of the given population
|
boolean |
isValid(String populationId)
Determines if a population has a valid configuration
|
Map<String,Object> |
remove(String id)
Removes the given population.
|
Map<String,Object> |
remove(String id,
boolean forceDeletion)
Removes the given population.
|
void |
service(ServiceManager manager) |
getLogger, setLogger
public static final String ADMIN_POPULATION_ID
public static final String SYSTEM_USER_LOGIN
public static final UserIdentity SYSTEM_USER_IDENTITY
private static final String __ADMIN_TABLENAME
private static final File __USER_POPULATIONS_FILE
private static final String __ID_REGEX
private long _lastFileReading
Populations file
was read (last update)private Map<String,UserPopulation> _userPopulations
private Set<String> _misconfiguredUserPopulations
private Set<String> _ignoredPopulations
private UserPopulation _adminUserPopulation
private UserDirectoryFactory _userDirectoryFactory
private CredentialProviderFactory _credentialProviderFactory
private PopulationConsumerExtensionPoint _populationConsumerEP
private ObservationManager _observationManager
private CurrentUserProvider _currentUserProvider
private I18nUtils _i18nutils
public UserPopulationDAO()
public void initialize()
initialize
in interface Initializable
public void service(ServiceManager manager) throws ServiceException
service
in interface Serviceable
ServiceException
public List<Object> getUserPopulationsAsJson(boolean withAdmin)
withAdmin
- True to include the "admin" populationUserPopulation
spublic Map<String,Object> getUserPopulationAsJson(UserPopulation userPopulation)
userPopulation
- The user population to getUserPopulation
public List<UserPopulation> getUserPopulations(boolean includeAdminPopulation)
includeAdminPopulation
- True to include the "admin" populationUserPopulation
public List<UserPopulation> getEnabledUserPopulations(boolean withAdmin)
withAdmin
- True to include the "admin" populationUserPopulation
public UserPopulation getUserPopulation(String id)
id
- The id of the populationUserPopulation
, or null if not foundpublic List<String> getUserPopulationsIds()
public Set<String> getIgnoredPopulations()
public Set<String> getMisconfiguredPopulations()
public InputStream getConfigurationFile()
public Map<String,Object> getEditionConfiguration() throws Exception
Exception
- If an error occurs.public Map<String,Object> getPopulationParameterValues(String id)
id
- The id of the populationpublic UserPopulation getAdminPopulation()
public Map<String,Object> add(String id, String label, List<Map<String,String>> userDirectories, List<Map<String,String>> credentialProviders)
id
- The unique id of the populationlabel
- The label of the populationuserDirectories
- A list of user directory parameterscredentialProviders
- A list of credential provider parametersprivate boolean _isCorrectId(String id)
public Map<String,Object> edit(String id, String label, List<Map<String,String>> userDirectories, List<Map<String,String>> credentialProviders)
id
- The id of the population to editlabel
- The label of the populationuserDirectories
- A list of user directory parameterscredentialProviders
- A list of credential provider parametersprivate void _fillUserPopulation(UserPopulation up, I18nizableText label, List<Map<String,String>> userDirectories, List<Map<String,String>> credentialProviders)
private void _keepExistingUserDirectoryPassword(UserPopulation up, String modelId, Map<String,Object> typedParamValues, String id)
private void _keepExistingCredentialProviderPassword(UserPopulation up, String modelId, Map<String,Object> typedParamValues, String id)
private Map<String,Object> _getTypedUDParameters(Map<String,String> parameters, String modelId)
private Map<String,Object> _getTypedCPParameters(Map<String,String> parameters, String modelId)
public Map<String,Object> remove(String id)
id
- The id of the population to removepublic Map<String,Object> remove(String id, boolean forceDeletion)
id
- The id of the population to removeforceDeletion
- Delete the population even if it is still in usepublic Map<String,Object> enable(String populationId, boolean enabled)
populationId
- The id of the population to enable/disableenabled
- True to enable the population, false to disable it.public boolean isValid(String populationId)
populationId
- The id of the population to retrieve statepublic Map<String,Object> isEnabled(String populationId)
populationId
- The id of the population to retrieve statepublic Map<String,Object> canRemove(String populationId)
populationId
- The id of the populationprivate void _readPopulations(boolean forceRead)
forceRead
- True to avoid the use of the cache and force the reading of the fileprivate void _createPopulationsFile(File file) throws IOException, TransformerConfigurationException, SAXException
private UserPopulation _configurePopulation(Configuration configuration, Set<String> misconfiguredUserPopulations) throws ConfigurationException
ConfigurationException
private List<UserDirectory> _configureUserDirectories(Configuration configuration, String upId, Set<String> misconfiguredUserPopulations) throws ConfigurationException
ConfigurationException
private List<CredentialProvider> _configureCredentialProviders(Configuration configuration, String upId) throws ConfigurationException
ConfigurationException
private Map<String,Object> _getUDParametersFromConfiguration(Configuration conf, String modelId, String populationId) throws ConfigurationException, IllegalArgumentException
conf
- The user directory's configuration.modelId
- The id of user directory modelpopulationId
- The id of populationIllegalArgumentException
- if the configured user directory references a non-existing user directory modelConfigurationException
- if a parameter is missingprivate Map<String,Object> _getCPParametersFromConfiguration(Configuration conf, String modelId, String populationId) throws ConfigurationException, IllegalArgumentException
conf
- The credential provider's configuration.modelId
- The id of credential provider modelpopulationId
- The id of populationIllegalArgumentException
- if the configured credential provider references a non-existing credential provider modelConfigurationException
- if a parameter is missingprivate boolean _writePopulations()
private void _toSAX(TransformerHandler handler)
private void _saxUserPopulation(UserPopulation userPopulation, TransformerHandler handler)
public void dispose()
dispose
in interface Disposable