@ThreadSafe public class UserManager extends AbstractSimpleDAO implements IUserManager, IReloadableDAO
IDAO.EMode| Modifier and Type | Field and Description |
|---|---|
static boolean |
DEFAULT_CREATE_DEFAULTS |
DEFAULT_AUTO_SAVE_ENABLED, m_aRWLock| Constructor and Description |
|---|
UserManager(String sFilename) |
| Modifier and Type | Method and Description |
|---|---|
boolean |
areUserIDAndPasswordValid(String sUserID,
String sPlainTextPassword)
Check if the passed combination of user ID and password matches.
|
boolean |
containsUserWithID(String sUserID)
Check if a user with the specified ID is present.
|
IUser |
createNewUser(String sLoginName,
String sEmailAddress,
String sPlainTextPassword,
String sFirstName,
String sLastName,
String sDescription,
Locale aDesiredLocale,
Map<String,?> aCustomAttrs,
boolean bDisabled)
Create a new user.
|
IUser |
createPredefinedUser(String sID,
String sLoginName,
String sEmailAddress,
String sPlainTextPassword,
String sFirstName,
String sLastName,
String sDescription,
Locale aDesiredLocale,
Map<String,?> aCustomAttrs,
boolean bDisabled)
Create a predefined user.
|
protected com.helger.commons.microdom.IMicroDocument |
createWriteData()
Create the XML document that should be saved to the file.
|
com.helger.commons.state.EChange |
deleteUser(String sUserID)
Delete the user with the specified ID.
|
com.helger.commons.state.EChange |
disableUser(String sUserID)
disable the user with the specified ID.
|
com.helger.commons.state.EChange |
enableUser(String sUserID)
Enable the user with the specified ID.
|
List<User> |
getAllActiveUsers() |
List<User> |
getAllDeletedUsers() |
List<User> |
getAllDisabledUsers() |
List<User> |
getAllNotDeletedUsers() |
List<User> |
getAllUsers() |
com.helger.commons.callback.CallbackList<IUserModificationCallback> |
getUserModificationCallbacks() |
IUser |
getUserOfEmailAddress(String sEmailAddress)
Get the user with the specified email address
|
User |
getUserOfID(String sUserID)
Get the user with the specified ID.
|
IUser |
getUserOfLoginName(String sLoginName)
Get the user with the specified login name
|
static boolean |
isCreateDefaults() |
protected com.helger.commons.state.EChange |
onInit()
Custom initialization routine.
|
protected com.helger.commons.state.EChange |
onRead(com.helger.commons.microdom.IMicroDocument aDoc)
Fill the internal structures with from the passed XML document.
|
void |
reload()
Call this method to reload the content from the original source.
|
static void |
setCreateDefaults(boolean bCreateDefaults) |
com.helger.commons.state.EChange |
setUserData(String sUserID,
String sNewLoginName,
String sNewEmailAddress,
String sNewFirstName,
String sNewLastName,
String sNewDescription,
Locale aNewDesiredLocale,
Map<String,?> aNewCustomAttrs,
boolean bNewDisabled)
Change the modifiable data of a user
|
com.helger.commons.state.EChange |
setUserPassword(String sUserID,
String sNewPlainTextPassword)
Change the modifiable data of a user
|
com.helger.commons.state.EChange |
undeleteUser(String sUserID)
Undelete the user with the specified ID.
|
com.helger.commons.state.EChange |
updateUserLastFailedLogin(String sUserID) |
com.helger.commons.state.EChange |
updateUserLastLogin(String sUserID) |
beforeWriteToFile, getDAOIO, getFilenameProvider, getInitCount, getLastFilename, getLastInitDateTime, getLastReadDateTime, getLastWriteDateTime, getReadCount, getSafeFile, getWriteCount, getXMLWriterSettings, initialRead, markAsChanged, modifyWriteData, onFilenameChange, toString, triggerExceptionHandlersRead, triggerExceptionHandlersWrite, writeToFileOnPendingChangesbeginWithoutAutoSave, endWithoutAutoSave, getExceptionHandlersRead, getExceptionHandlersWrite, hasPendingChanges, internalHasPendingChanges, internalIsAutoSaveEnabled, internalSetPendingChanges, isAutoSaveEnabled, performWithoutAutoSave, performWithoutAutoSave, performWithoutAutoSave, performWithoutAutoSaveclone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, waitgetInitCount, getLastInitDateTime, getLastReadDateTime, getLastWriteDateTime, getReadCount, getWriteCount, writeToFileOnPendingChangeshasPendingChangesbeginWithoutAutoSave, endWithoutAutoSave, isAutoSaveEnabled, performWithoutAutoSave, performWithoutAutoSavepublic static final boolean DEFAULT_CREATE_DEFAULTS
public UserManager(@Nonnull@Nonempty String sFilename) throws DAOException
DAOExceptionpublic static boolean isCreateDefaults()
public static void setCreateDefaults(boolean bCreateDefaults)
public void reload()
throws DAOException
IReloadableDAOreload in interface IReloadableDAODAOException - in case reloading fails@Nonnull protected com.helger.commons.state.EChange onInit()
AbstractSimpleDAOonInit in class AbstractSimpleDAOEChange.CHANGED if something was modified inside this
method@Nonnull protected com.helger.commons.state.EChange onRead(@Nonnull com.helger.commons.microdom.IMicroDocument aDoc)
AbstractSimpleDAOonRead in class AbstractSimpleDAOaDoc - The XML document to read from. Never null.EChange.CHANGED if reading the data changed something in
the internal structures that requires a writing.@Nonnull protected com.helger.commons.microdom.IMicroDocument createWriteData()
AbstractSimpleDAOcreateWriteData in class AbstractSimpleDAOnull document to write to the file.@Nonnull @ReturnsMutableObject(reason="design") public com.helger.commons.callback.CallbackList<IUserModificationCallback> getUserModificationCallbacks()
getUserModificationCallbacks in interface IUserManagernull.@Nullable public IUser createNewUser(@Nonnull@Nonempty String sLoginName, @Nullable String sEmailAddress, @Nonnull String sPlainTextPassword, @Nullable String sFirstName, @Nullable String sLastName, @Nullable String sDescription, @Nullable Locale aDesiredLocale, @Nullable Map<String,?> aCustomAttrs, boolean bDisabled)
IUserManagercreateNewUser in interface IUserManagersLoginName - Login name of the user. May neither be null nor
empty.This login name must be unique over all existing users.sEmailAddress - The email address. May be null.sPlainTextPassword - The plain text password to be used. May neither be null
nor empty.sFirstName - The users first name. May be null.sLastName - The users last name. May be null.sDescription - Optional description for the user. May be null.aDesiredLocale - The users default locale. May be null.aCustomAttrs - Custom attributes. May be null.bDisabled - true if the user is disablednull if another user with the same
email address is already present.@Nullable public IUser createPredefinedUser(@Nonnull@Nonempty String sID, @Nonnull@Nonempty String sLoginName, @Nullable String sEmailAddress, @Nonnull String sPlainTextPassword, @Nullable String sFirstName, @Nullable String sLastName, @Nullable String sDescription, @Nullable Locale aDesiredLocale, @Nullable Map<String,?> aCustomAttrs, boolean bDisabled)
IUserManagercreatePredefinedUser in interface IUserManagersID - The ID to usesLoginName - Login name of the user. May neither be null nor empty.
This login name must be unique over all existing users.sEmailAddress - The email address. May be null.sPlainTextPassword - The plain text password to be used. May neither be null
nor empty.sFirstName - The users first name. May be null.sLastName - The users last name. May be null.sDescription - Optional description for the user. May be null.aDesiredLocale - The users default locale. May be null.aCustomAttrs - Custom attributes. May be null.bDisabled - true if the user is disablednull if another user with the same
email address is already present.public boolean containsUserWithID(@Nullable String sUserID)
IUserManagercontainsUserWithID in interface IUserManagersUserID - The user ID to resolve. May be null.true if such user exists, false
otherwise.@Nullable public User getUserOfID(@Nullable String sUserID)
IUserManagergetUserOfID in interface IUserManagersUserID - The user ID to resolve. May be null.null if no such user exists@Nullable public IUser getUserOfLoginName(@Nullable String sLoginName)
IUserManagergetUserOfLoginName in interface IUserManagersLoginName - The login name to be checked. May be null.null if no such user exists@Nullable public IUser getUserOfEmailAddress(@Nullable String sEmailAddress)
IUserManagergetUserOfEmailAddress in interface IUserManagersEmailAddress - The email address to be checked. May be null.null if no such user exists@Nonnull @ReturnsMutableCopy public List<User> getAllUsers()
getAllUsers in interface IUserManagernull collection of all contained users
(enabled+disabled and deleted+not-deleted)@Nonnull @ReturnsMutableCopy public List<User> getAllActiveUsers()
getAllActiveUsers in interface IUserManagernull collection of all contained enabled and
not-deleted users@Nonnull @ReturnsMutableCopy public List<User> getAllDisabledUsers()
getAllDisabledUsers in interface IUserManagernull collection of all contained disabled and
not-deleted users@Nonnull @ReturnsMutableCopy public List<User> getAllNotDeletedUsers()
getAllNotDeletedUsers in interface IUserManagernull collection of all contained not deleted
users@Nonnull @ReturnsMutableCopy public List<User> getAllDeletedUsers()
getAllDeletedUsers in interface IUserManagernull collection of all contained deleted users@Nonnull public com.helger.commons.state.EChange setUserData(@Nullable String sUserID, @Nonnull@Nonempty String sNewLoginName, @Nullable String sNewEmailAddress, @Nullable String sNewFirstName, @Nullable String sNewLastName, @Nullable String sNewDescription, @Nullable Locale aNewDesiredLocale, @Nullable Map<String,?> aNewCustomAttrs, boolean bNewDisabled)
IUserManagersetUserData in interface IUserManagersUserID - The ID of the user to be modified. May be null.sNewLoginName - The new login name. May not be null.sNewEmailAddress - The new email address. May be null.sNewFirstName - The new first name. May be null.sNewLastName - The new last name. May be null.sNewDescription - Optional new description for the user. May be null.aNewDesiredLocale - The new desired locale. May be null.aNewCustomAttrs - Custom attributes. May be null.bNewDisabled - true if the user is disabledEChange@Nonnull public com.helger.commons.state.EChange setUserPassword(@Nullable String sUserID, @Nonnull String sNewPlainTextPassword)
IUserManagersetUserPassword in interface IUserManagersUserID - The ID of the user to be modified. May be null.sNewPlainTextPassword - The new password in plain text. May not be null.EChange@Nonnull public com.helger.commons.state.EChange updateUserLastLogin(@Nullable String sUserID)
@Nonnull public com.helger.commons.state.EChange updateUserLastFailedLogin(@Nullable String sUserID)
@Nonnull public com.helger.commons.state.EChange deleteUser(@Nullable String sUserID)
IUserManagerdeleteUser in interface IUserManagersUserID - The ID of the user to deleteEChange.CHANGED if the user was deleted,
EChange.UNCHANGED otherwise.@Nonnull public com.helger.commons.state.EChange undeleteUser(@Nullable String sUserID)
IUserManagerundeleteUser in interface IUserManagersUserID - The ID of the user to undeleteEChange.CHANGED if the user was undeleted,
EChange.UNCHANGED otherwise.@Nonnull public com.helger.commons.state.EChange disableUser(@Nullable String sUserID)
IUserManagerdisableUser in interface IUserManagersUserID - The ID of the user to disableEChange.CHANGED if the user was disabled,
EChange.UNCHANGED otherwise.@Nonnull public com.helger.commons.state.EChange enableUser(@Nullable String sUserID)
IUserManagerenableUser in interface IUserManagersUserID - The ID of the user to enableEChange.CHANGED if the user was enabled,
EChange.UNCHANGED otherwise.public boolean areUserIDAndPasswordValid(@Nullable String sUserID, @Nullable String sPlainTextPassword)
IUserManagerareUserIDAndPasswordValid in interface IUserManagersUserID - The ID of the usersPlainTextPassword - The plan text password to validate.true if the password hash matches the stored hash for
the specified user, false otherwise.Copyright © 2014–2015 Philip Helger. All rights reserved.