|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object fr.gouv.culture.sdx.utils.AbstractSdxObject fr.gouv.culture.sdx.utils.database.DatabaseBacked fr.gouv.culture.sdx.user.UserDatabase
public class UserDatabase
A database for keeping track of users and groups, and mainly of their membership relationships.
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.
Nested Class Summary |
---|
Nested classes/interfaces inherited from interface fr.gouv.culture.sdx.utils.SdxObject |
---|
SdxObject.ConfigurationNode |
Field Summary | |
---|---|
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 |
Fields inherited from class fr.gouv.culture.sdx.utils.database.DatabaseBacked |
---|
_database, CLASS_NAME_SUFFIX, DATABASE_DIR_NAME, databaseConf, dbLocation, dbPath, DEFAULT_DATABASE_TYPE |
Fields inherited from class fr.gouv.culture.sdx.utils.AbstractSdxObject |
---|
_configuration, _context, _description, _encoding, _id, _locale, _logger, _manager, _xmlizable_objects, _xmlLang, isToSaxInitialized |
Fields inherited from interface fr.gouv.culture.sdx.utils.database.Database |
---|
CLASS_NAME_SUFFIX, DATABASE_DIR_PATH, PACKAGE_QUALNAME, SEARCH_MODE_AND, SEARCH_MODE_NOT, SEARCH_MODE_OR |
Fields inherited from interface fr.gouv.culture.sdx.utils.Encodable |
---|
DEFAULT_ENCODING |
Fields inherited from interface fr.gouv.culture.sdx.utils.save.Saveable |
---|
ALL_SAVE_ATTRIB, PATH_ATTRIB, SAVE_DIRECTORY_PARAM |
Constructor Summary | |
---|---|
UserDatabase(java.lang.String id)
|
Method Summary | |
---|---|
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. |
Methods inherited from class fr.gouv.culture.sdx.utils.database.DatabaseBacked |
---|
configure, configure, getDatabase, init |
Methods inherited from class fr.gouv.culture.sdx.utils.AbstractSdxObject |
---|
configureDescription, contextualize, enableLogging, getBaseAttributes, getConfiguration, getContext, getDescription, getEncoding, getId, getLocale, getLog, getServiceManager, getXmlLang, service, setDescription, setEncoding, setId, setLocale, setUpSdxObject, setUpSdxObject, setXmlLang, toSAX, verifyConfigurationResources |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Methods inherited from interface fr.gouv.culture.sdx.utils.database.Database |
---|
init |
Methods inherited from interface fr.gouv.culture.sdx.utils.SdxObject |
---|
getLog |
Methods inherited from interface org.apache.avalon.framework.logger.LogEnabled |
---|
enableLogging |
Methods inherited from interface org.apache.avalon.framework.context.Contextualizable |
---|
contextualize |
Methods inherited from interface org.apache.avalon.framework.service.Serviceable |
---|
service |
Methods inherited from interface org.apache.avalon.framework.configuration.Configurable |
---|
configure |
Methods inherited from interface fr.gouv.culture.sdx.utils.Identifiable |
---|
getId, setId |
Methods inherited from interface fr.gouv.culture.sdx.utils.Describable |
---|
getDescription, setDescription |
Methods inherited from interface fr.gouv.culture.sdx.utils.Encodable |
---|
getEncoding, setEncoding |
Methods inherited from interface fr.gouv.culture.sdx.utils.Localizable |
---|
getLocale, getXmlLang, setLocale, setXmlLang |
Methods inherited from interface org.apache.excalibur.xml.sax.XMLizable |
---|
toSAX |
Field Detail |
---|
public 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
Constructor Detail |
---|
public UserDatabase(java.lang.String id) throws SDXException
SDXException
Method Detail |
---|
public void addMember(Group group, java.lang.String id) throws SDXException
group
- The group.id
- Id of an identity to add as a member.
SDXException
public void deleteMembers(Group group) throws SDXException
group
- The group
SDXException
public 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.
SDXException
public 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).
SDXException
public java.lang.String[] getMembers(java.lang.String groupName) throws SDXException
groupName
- The name of the group for which the list is desired
SDXException
public java.util.Hashtable getParents(java.lang.String id) throws SDXException
id
- Name of the identity (group or user).
SDXException
public boolean isMember(Identity identity, java.lang.String groupName) throws SDXException
identity
- a group or a user to checkgroupName
- the groupName to test membership in
SDXException
public 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).
SDXException
public 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).
SDXException
public 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.
SDXException
public boolean exists(java.lang.String id) throws SDXException
SDXException
public DatabaseEntity getEntity(java.lang.String id) throws SDXException
Database
getEntity
in interface Database
id
- The needed entity's id.
SDXException
public DatabaseEntity[] getEntities() throws SDXException
Database
getEntities
in interface Database
SDXException
public java.lang.String getPropertyValue(java.lang.String entityId, java.lang.String name) throws SDXException
Database
getPropertyValue
in interface Database
entityId
- 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.
SDXException
public java.lang.String[] getPropertyValues(java.lang.String entityId, java.lang.String propertyName) throws SDXException
Database
getPropertyValues
in interface Database
entityId
- The needed entity's name.propertyName
- The needed property's name.
null
is this
property is not defined for this entity.
SDXException
public Property[] getProperties(java.lang.String entityId) throws SDXException
Database
getProperties
in interface Database
SDXException
public void save(DatabaseEntity ent) throws SDXException
Database
save
in interface Database
SDXException
public void delete(DatabaseEntity ent) throws SDXException
Database
delete
in interface Database
SDXException
public void update(DatabaseEntity ent) throws SDXException
Database
update
in interface Database
SDXException
public long size()
Database
size
in interface Database
public void empty() throws SDXException
Database
empty
in interface Database
SDXException
public boolean entityExists(java.lang.String id)
Database
entityExists
in interface Database
id
- _identifier of the entitypublic java.lang.String[] search(org.apache.avalon.framework.parameters.Parameters params) throws SDXException
Database
search
in interface Database
params
- search params
SDXException
public java.lang.String[] search(org.apache.avalon.framework.parameters.Parameters params, int mode) throws SDXException
search
in interface Database
SDXException
public void optimize() throws SDXException
Database
optimize
in interface Database
SDXException
public java.lang.String getDatabaseDirectoryName()
Database
getDatabaseDirectoryName
in interface Database
public DatabaseConnection getConnection() throws SDXException
getConnection
in interface Database
SDXException
public void releaseConnection(DatabaseConnection conn) throws SDXException
releaseConnection
in interface Database
SDXException
public void addProperty(java.lang.String entityId, java.lang.String propertyName, java.lang.String propertyValue) throws SDXException
Database
addProperty
in interface Database
entityId
- The entity to updatepropertyName
- The property to addpropertyValue
- The property value
SDXException
public void removeProperty(java.lang.String entityId, java.lang.String propertyName, java.lang.String propertyValue) throws SDXException
Database
removeProperty
in interface Database
entityId
- The entity to updatepropertyName
- The property to removepropertyValue
- The property value
SDXException
public void removeProperty(java.lang.String propertyName, java.lang.String propertyValue) throws SDXException
Database
removeProperty
in interface Database
propertyName
- The property to removepropertyValue
- The property value
SDXException
protected java.lang.String getClassNameSuffix()
AbstractSdxObject
getClassNameSuffix
in class DatabaseBacked
public java.lang.String getWildcardSearchToken()
Database
getWildcardSearchToken
in interface Database
protected boolean initToSax()
AbstractSdxObject
initToSax
in class DatabaseBacked
protected void initVolatileObjectsToSax()
initVolatileObjectsToSax
in class DatabaseBacked
public void backup(SaveParameters save_config) throws SDXException
backup
in interface Saveable
SDXException
Saveable.backup(fr.gouv.culture.sdx.utils.save.SaveParameters)
public void restore(SaveParameters save_config) throws SDXException
restore
in interface Saveable
SDXException
Saveable.restore(fr.gouv.culture.sdx.utils.save.SaveParameters)
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |