public class UserDatabase extends DatabaseBacked implements Database
This class is backed by a LuceneDatabase where groups and users information are kept.
A user may be a member of some groups, and groups can be member of other groups.
SdxObject.ConfigurationNode| Modifier and Type | Field and Description |
|---|---|
static java.lang.String |
FIELD_EMAIL
The field for the email
|
static java.lang.String |
FIELD_FIRSTNAME
The field for the firstname
|
static java.lang.String |
FIELD_LASTNAME
The field for the lastname
|
static java.lang.String |
FIELD_LOCALE
The field for the preferred locale
|
static java.lang.String |
FIELD_PASSWORD
The field for the encoded password
|
_database, CLASS_NAME_SUFFIX, DATABASE_DIR_NAME, databaseConf, dbLocation, dbPath, DEFAULT_DATABASE_TYPE_configuration, _context, _description, _encoding, _id, _locale, _logger, _manager, _xmlizable_objects, _xmlLang, isToSaxInitializedCLASS_NAME_SUFFIX, DATABASE_DIR_PATH, PACKAGE_QUALNAME, SEARCH_MODE_AND, SEARCH_MODE_NOT, SEARCH_MODE_ORDEFAULT_ENCODINGALL_SAVE_ATTRIB, PATH_ATTRIB, SAVE_DIRECTORY_PARAM| Constructor and Description |
|---|
UserDatabase(java.lang.String id) |
| Modifier and Type | Method and Description |
|---|---|
void |
add(Identity identity,
java.lang.String password)
Adds an identity to this database.
|
void |
addMember(Group group,
java.lang.String id)
Adds a member to a group.
|
void |
addProperty(java.lang.String entityId,
java.lang.String propertyName,
java.lang.String propertyValue)
Adds a property with the provided name and value to the
EXISTING entity with the provided id
It is up to the implementation to determine proper
behavior if the entity with the provided id does not exist.
|
void |
backup(SaveParameters save_config)
Save the DocumentBase data objects
|
boolean |
changePassword(java.lang.String id,
java.lang.String oldPass,
java.lang.String newPass)
Checks if user login as "id" have the encoded password "password".
|
boolean |
checkPassword(java.lang.String id,
java.lang.String password)
Checks if user login as "id" have the encoded password "password".
|
void |
delete(DatabaseEntity ent)
Deletes an entity.
|
void |
delete(Identity identity)
Removes an identity from the database.
|
void |
deleteMembers(Group group)
Deletes all references to this group in members
|
void |
empty()
Empties the database.
|
boolean |
entityExists(java.lang.String id)
Checks whether an entity with the provided id exists within this database
|
boolean |
exists(java.lang.String id) |
protected java.lang.String |
getClassNameSuffix()
Sub classes should element this method to return their class name suffix for SAX output
|
DatabaseConnection |
getConnection() |
java.lang.String |
getDatabaseDirectoryName()
If the database is a directory based file system implemenation like lucene
this method should return a valid name for a directory which may be created to house
the database, or in the case of hsql it will return a valid table name
|
DatabaseEntity[] |
getEntities()
Returns the list of entities from the database.
|
DatabaseEntity |
getEntity(java.lang.String id)
Gets an entity from the database.
|
java.lang.String[] |
getMembers(java.lang.String groupName)
Gets an array of member ids for a group
|
java.util.Hashtable |
getParents(java.lang.String id)
Returns all the groups an identity belongs to.
|
Property[] |
getProperties(java.lang.String entityId)
Returns all properties from an entity in the database.
|
java.lang.String |
getPropertyValue(java.lang.String entityId,
java.lang.String name)
Returns a property value from an entity in the database.
|
java.lang.String[] |
getPropertyValues(java.lang.String entityId,
java.lang.String propertyName)
Returns a repeatable property from an entity in the database.
|
UserInformation |
getUserInformation(java.lang.String application,
java.lang.String username,
java.util.Locale locale,
java.lang.String adminGroup)
Returns basic information about a user.
|
java.lang.String |
getWildcardSearchToken()
Returns a String representing the
appropriate wildcard search token
for the implementation
|
protected boolean |
initToSax()
Init the LinkedHashMap _xmlizable_objects with the objects in order to describ them in XML
|
protected void |
initVolatileObjectsToSax()
Init the LinkedHashMap _xmlizable_volatile_objects with the objects in order to describ them in XML
Some objects need to be refresh each time a toSAX is called
|
boolean |
isMember(Identity identity,
java.lang.String groupName)
Tests whether a database entity indicates membership of a group.
|
void |
optimize()
Utility method for database maintenance,
normally used to optimize indices of Lucene based repositories
It is the responsibility of the Repository to ensure that
unnecessary optimizations are not performed when this method
is called.
|
void |
releaseConnection(DatabaseConnection conn) |
void |
removeProperty(java.lang.String propertyName,
java.lang.String propertyValue)
Removes a property with the provided name and value from the
and EXISTING entity having the name/value pair
It is up to the implementation to determine proper
behavior if the entity with the provided id does not exist.
|
void |
removeProperty(java.lang.String entityId,
java.lang.String propertyName,
java.lang.String propertyValue)
Removes a property with the provided name and value to the
EXISTING entity with the provided id
It is up to the implementation to determine proper
behavior if the entity with the provided id does not exist.
|
void |
restore(SaveParameters save_config)
restore the DocumentBase data objects
|
void |
save(DatabaseEntity ent)
Saves an entity.
|
java.lang.String[] |
search(org.apache.avalon.framework.parameters.Parameters params)
Returns an array of database entity ids based upon the
provided search parameters
One can used Database.getEntity(id) after retrieving a
list of ids with this method.
|
java.lang.String[] |
search(org.apache.avalon.framework.parameters.Parameters params,
int mode) |
long |
size()
Returns the number of entities within this database.
|
void |
update(DatabaseEntity ent)
Updates an entity.
|
configure, configure, getDatabase, initconfigureDescription, contextualize, enableLogging, getBaseAttributes, getConfiguration, getContext, getDescription, getEncoding, getId, getLocale, getLog, getServiceManager, getXmlLang, service, setDescription, setEncoding, setId, setLocale, setUpSdxObject, setUpSdxObject, setXmlLang, toSAX, verifyConfigurationResourcesclone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitgetId, setIdgetDescription, setDescriptiongetEncoding, setEncodinggetLocale, getXmlLang, setLocale, setXmlLangpublic static final java.lang.String FIELD_PASSWORD
public static final java.lang.String FIELD_FIRSTNAME
public static final java.lang.String FIELD_LASTNAME
public static final java.lang.String FIELD_EMAIL
public static final java.lang.String FIELD_LOCALE
public UserDatabase(java.lang.String id)
throws SDXException
SDXExceptionpublic void addMember(Group group, java.lang.String id) throws SDXException
group - The group.id - Id of an identity to add as a member.SDXExceptionpublic void deleteMembers(Group group) throws SDXException
group - The groupSDXExceptionpublic void delete(Identity identity) throws SDXException
For groups, all identities member of the group will have this membership removed also.
identity - The identity to delete.SDXExceptionpublic void add(Identity identity, java.lang.String password) throws SDXException
identity - The identity to add.password - The encoded password associated to this identity (may be null).SDXExceptionpublic java.lang.String[] getMembers(java.lang.String groupName)
throws SDXException
groupName - The name of the group for which the list is desiredSDXExceptionpublic java.util.Hashtable getParents(java.lang.String id)
throws SDXException
id - Name of the identity (group or user).SDXExceptionpublic boolean isMember(Identity identity, java.lang.String groupName) throws SDXException
identity - a group or a user to checkgroupName - the groupName to test membership inSDXExceptionpublic boolean checkPassword(java.lang.String id,
java.lang.String password)
throws SDXException
id - id of user (if null returns false).password - The password (may be null).SDXExceptionpublic boolean changePassword(java.lang.String id,
java.lang.String oldPass,
java.lang.String newPass)
throws SDXException
id - id of user (if null returns false).oldPass - The password (may be null).newPass - The password (may NOT be null).SDXExceptionpublic UserInformation getUserInformation(java.lang.String application, java.lang.String username, java.util.Locale locale, java.lang.String adminGroup) throws SDXException
application - id of the application where the user should be registeredusername - id of a user (if null, anonymous user is returned).locale - The default locale if the user's locale is not set.SDXExceptionpublic boolean exists(java.lang.String id)
throws SDXException
SDXExceptionpublic DatabaseEntity getEntity(java.lang.String id) throws SDXException
DatabasegetEntity in interface Databaseid - The needed entity's id.SDXExceptionpublic DatabaseEntity[] getEntities() throws SDXException
DatabasegetEntities in interface DatabaseSDXExceptionpublic java.lang.String getPropertyValue(java.lang.String entityId,
java.lang.String name)
throws SDXException
DatabasegetPropertyValue in interface DatabaseentityId - The needed entity's id.name - The needed property's name.null. If the property is
defined more than once, the first value is returned.SDXExceptionpublic java.lang.String[] getPropertyValues(java.lang.String entityId,
java.lang.String propertyName)
throws SDXException
DatabasegetPropertyValues in interface DatabaseentityId - The needed entity's name.propertyName - The needed property's name.null is this
property is not defined for this entity.SDXExceptionpublic Property[] getProperties(java.lang.String entityId) throws SDXException
DatabasegetProperties in interface DatabaseSDXExceptionpublic void save(DatabaseEntity ent) throws SDXException
Databasesave in interface DatabaseSDXExceptionpublic void delete(DatabaseEntity ent) throws SDXException
Databasedelete in interface DatabaseSDXExceptionpublic void update(DatabaseEntity ent) throws SDXException
Databaseupdate in interface DatabaseSDXExceptionpublic long size()
Databasepublic void empty()
throws SDXException
Databaseempty in interface DatabaseSDXExceptionpublic boolean entityExists(java.lang.String id)
DatabaseentityExists in interface Databaseid - _identifier of the entitypublic java.lang.String[] search(org.apache.avalon.framework.parameters.Parameters params)
throws SDXException
Databasesearch in interface Databaseparams - search paramsSDXExceptionpublic java.lang.String[] search(org.apache.avalon.framework.parameters.Parameters params,
int mode)
throws SDXException
search in interface DatabaseSDXExceptionpublic void optimize()
throws SDXException
Databaseoptimize in interface DatabaseSDXExceptionpublic java.lang.String getDatabaseDirectoryName()
DatabasegetDatabaseDirectoryName in interface Databasepublic DatabaseConnection getConnection() throws SDXException
getConnection in interface DatabaseSDXExceptionpublic void releaseConnection(DatabaseConnection conn) throws SDXException
releaseConnection in interface DatabaseSDXExceptionpublic void addProperty(java.lang.String entityId,
java.lang.String propertyName,
java.lang.String propertyValue)
throws SDXException
DatabaseaddProperty in interface DatabaseentityId - The entity to updatepropertyName - The property to addpropertyValue - The property valueSDXExceptionpublic void removeProperty(java.lang.String entityId,
java.lang.String propertyName,
java.lang.String propertyValue)
throws SDXException
DatabaseremoveProperty in interface DatabaseentityId - The entity to updatepropertyName - The property to removepropertyValue - The property valueSDXExceptionpublic void removeProperty(java.lang.String propertyName,
java.lang.String propertyValue)
throws SDXException
DatabaseremoveProperty in interface DatabasepropertyName - The property to removepropertyValue - The property valueSDXExceptionprotected java.lang.String getClassNameSuffix()
AbstractSdxObjectgetClassNameSuffix in class DatabaseBackedpublic java.lang.String getWildcardSearchToken()
DatabasegetWildcardSearchToken in interface Databaseprotected boolean initToSax()
AbstractSdxObjectinitToSax in class DatabaseBackedprotected void initVolatileObjectsToSax()
initVolatileObjectsToSax in class DatabaseBackedpublic void backup(SaveParameters save_config) throws SDXException
backup in interface SaveableSDXExceptionSaveable.backup(fr.gouv.culture.sdx.utils.save.SaveParameters)public void restore(SaveParameters save_config) throws SDXException
restore in interface SaveableSDXExceptionSaveable.restore(fr.gouv.culture.sdx.utils.save.SaveParameters)Copyright © 2000-2010 Ministere de la culture et de la communication / AJLSM. All Rights Reserved.