Class AdminUserHome
- java.lang.Object
-
- fr.paris.lutece.portal.business.user.AdminUserHome
-
public final class AdminUserHome extends java.lang.ObjectThis class provides instances management methods (create, find, ...) for AdminUser objects
-
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static intcheckAccessCodeAlreadyInUse(java.lang.String strAccessCode)Checks if a given login is already in usestatic intcheckEmailAlreadyInUse(java.lang.String strEmail)Checks if a given email is already in usestatic booleancheckRoleAttributed(java.lang.String strRoleKey)Checks wether the role is in use or notstatic intcountUserPasswordHistoryFromDate(java.sql.Timestamp minDate, int nUserId)Get the number of password change done by a user since the given date.static voidcreate(AdminUser user)static voidcreate(LuteceDefaultAdminUser user)static voidcreateRightForUser(int nUserId, java.lang.String strRightId)static voidcreateRoleForUser(int nUserId, java.lang.String strRightId)static java.util.List<java.lang.Integer>findAllExpiredUserId()Get the list of id of user with the expired status.static java.util.Collection<AdminUser>findByLevel(int nIdLevel)Get all users having a given levelstatic AdminUserfindByPrimaryKey(int nUserId)Get the user infos from user idstatic java.util.Collection<AdminUser>findByRight(java.lang.String strIdRight)Get all users having a given rightstatic java.util.Collection<AdminUser>findByRole(java.lang.String strRoleKey)Get all users having a given rolestatic LuteceDefaultAdminUserfindLuteceDefaultAdminUserByPrimaryKey(int nUserId)Get the user infos from user idstatic java.lang.StringfindUserByEmail(java.lang.String strEmail)Get the user access code from its email.static java.util.Collection<AdminUser>findUserByFilter(AdminUserFilter auFilter)Get all users by using a filter.static AdminUserfindUserByLogin(java.lang.String strUserLogin)Get the user infos from the access code.static <T extends AdminUser>
TfindUserByLogin(java.lang.String strUserLogin, T user)Get the user infos from the access code.static java.util.Collection<AdminUser>findUserList()static java.util.Map<java.lang.String,java.lang.Boolean>getAnonymizationStatusUserStaticField()Get a map of anonymization status of a user field.static java.util.List<java.lang.Integer>getIdUsersToSendFirstAlert(java.sql.Timestamp firstAlertMaxDate)Get the list of id of users that need to receive their first alertstatic java.util.List<java.lang.Integer>getIdUsersToSendOtherAlert(java.sql.Timestamp alertMaxDate, java.sql.Timestamp timeBetweenAlerts, int maxNumberAlerts)Get the list of id of users that need to receive their first alertstatic java.util.List<java.lang.Integer>getIdUsersWithExpiredLifeTimeList(java.sql.Timestamp currentTimestamp)Get the list of id of users that have an expired time life but not the expired statusstatic java.util.List<java.lang.Integer>getIdUsersWithExpiredPasswordsList(java.sql.Timestamp currentTimestamp)Get the list of id of users that have an expired password but not the change password flagstatic java.util.Map<java.lang.String,Right>getRightsListForUser(int nUserId)Get the right list associated to a given user idstatic java.util.Map<java.lang.String,RBACRole>getRolesListForUser(int nUserId)Get the role list associated to a given user idstatic java.lang.StringgetUserPasswordResetToken(int nIdUser, java.util.Date timestamp, java.lang.String strSessionId)Construct a password reset token.static java.util.List<AdminUser>getUsersWithLifeTimeToResync(java.sql.Timestamp maxValidDate)Get the users whose account life time may have to be resynchronized from their last login date : users with a not null account max valid date lower than the given date, and whose status is active, not active or expired.static booleanhasRight(AdminUser user, java.lang.String strIdRight)Check if the user has the given rightstatic booleanhasRole(AdminUser user, java.lang.String strRoleKey)Check if the user has the rolestatic voidinsertNewPasswordInHistory(IPassword password, int nUserId)Log a password change in the password historystatic voidremove(int nUserId)static voidremoveAllDelegatedRightsForUser(AdminUser user)static voidremoveAllOwnRightsForUser(AdminUser user)static voidremoveAllPasswordHistoryForUser(int nUserId)Remove every password saved in the password history for a user.static voidremoveAllRightsForUser(int nUserId)static voidremoveAllRolesForUser(int nUserId)static voidremoveRightForUser(int nUserId, java.lang.String strIdRight)Remove a right for an userstatic voidremoveRoleForUser(int nUserId, java.lang.String strRoleKey)Remove role for an userstatic java.util.List<IPassword>selectUserPasswordHistory(int nUserID)Gets the history of password of the given userstatic voidupdate(AdminUser user)static voidupdate(LuteceDefaultAdminUser user)static voidupdate(LuteceDefaultAdminUser user, PasswordUpdateMode passwordMode)static voidupdateAnonymizationStatusUserStaticField(java.lang.String strFieldName, boolean bAnonymizeFiled)Update the anonymization status of a user field.static voidupdateChangePassword(java.util.List<java.lang.Integer> listIdUser)Set the "change password" flag of users to truestatic voidupdateDateLastLogin(int nIdUser, java.sql.Timestamp dateLastLogin)Update the admin user last login date.static voidupdateNbAlert(java.util.List<java.lang.Integer> listIdUser)Increment the number of alert send to users by 1static voidupdateUserExpirationDate(int nIdUser, java.sql.Timestamp newExpirationDate)Update the admin user expiration date with the new values.static voidupdateUsersRole(java.lang.String strOldRoleKey, RBACRole role)Update role key if role key name has changestatic voidupdateUserStatus(java.util.List<java.lang.Integer> listIdUser, int nNewStatus)Update status of a list of user accounts
-
-
-
Method Detail
-
findUserByLogin
public static AdminUser findUserByLogin(java.lang.String strUserLogin)
Get the user infos from the access code.- Parameters:
strUserLogin- the login- Returns:
- user info
-
findUserByLogin
public static <T extends AdminUser> T findUserByLogin(java.lang.String strUserLogin, T user)
Get the user infos from the access code.- Parameters:
strUserLogin- the loginuser- the user to load- Returns:
- user info
-
findUserByEmail
public static java.lang.String findUserByEmail(java.lang.String strEmail)
Get the user access code from its email.- Parameters:
strEmail- The email- Returns:
- The access code of the user with the given email, or null if no user has been found
-
findByPrimaryKey
public static AdminUser findByPrimaryKey(int nUserId)
Get the user infos from user id- Parameters:
nUserId- the user identifier- Returns:
- The user
-
findUserList
public static java.util.Collection<AdminUser> findUserList()
- Returns:
- the user list
-
create
public static void create(AdminUser user)
- Parameters:
user- The AdminUser
-
update
public static void update(AdminUser user)
- Parameters:
user- The AdminUser
-
remove
public static void remove(int nUserId)
- Parameters:
nUserId- the user identifier
-
getRightsListForUser
public static java.util.Map<java.lang.String,Right> getRightsListForUser(int nUserId)
Get the right list associated to a given user id- Parameters:
nUserId- the id of the user to retrieve rights- Returns:
- the right list
-
createRightForUser
public static void createRightForUser(int nUserId, java.lang.String strRightId)- Parameters:
nUserId- The user identifierstrRightId- The right identifier
-
removeAllRightsForUser
public static void removeAllRightsForUser(int nUserId)
- Parameters:
nUserId- The user identifier
-
removeAllDelegatedRightsForUser
public static void removeAllDelegatedRightsForUser(AdminUser user)
- Parameters:
user- The Admin User object
-
removeAllOwnRightsForUser
public static void removeAllOwnRightsForUser(AdminUser user)
- Parameters:
user- The Admin User object
-
getRolesListForUser
public static java.util.Map<java.lang.String,RBACRole> getRolesListForUser(int nUserId)
Get the role list associated to a given user id- Parameters:
nUserId- the id of the user to retrieve rights- Returns:
- the role list
-
createRoleForUser
public static void createRoleForUser(int nUserId, java.lang.String strRightId)- Parameters:
nUserId- the id of the userstrRightId- the right identifier
-
removeAllRolesForUser
public static void removeAllRolesForUser(int nUserId)
- Parameters:
nUserId- the user identifier
-
checkRoleAttributed
public static boolean checkRoleAttributed(java.lang.String strRoleKey)
Checks wether the role is in use or not- Parameters:
strRoleKey- the role key to check- Returns:
- true if the role is attributed, false otherwise
-
checkAccessCodeAlreadyInUse
public static int checkAccessCodeAlreadyInUse(java.lang.String strAccessCode)
Checks if a given login is already in use- Parameters:
strAccessCode- The login- Returns:
- user ID if the access code is already used by another user, -1 otherwise
-
checkEmailAlreadyInUse
public static int checkEmailAlreadyInUse(java.lang.String strEmail)
Checks if a given email is already in use- Parameters:
strEmail- The email- Returns:
- user ID if the email is already used by another user, -1 otherwise
-
hasRole
public static boolean hasRole(AdminUser user, java.lang.String strRoleKey)
Check if the user has the role- Parameters:
user- The AdminUserstrRoleKey- The role Key- Returns:
- true if the user has the role
-
removeRoleForUser
public static void removeRoleForUser(int nUserId, java.lang.String strRoleKey)Remove role for an user- Parameters:
nUserId- The ID of the userstrRoleKey- The role key
-
create
public static void create(LuteceDefaultAdminUser user)
- Parameters:
user- the LuteceDefaultAdminUSer
-
update
public static void update(LuteceDefaultAdminUser user)
- Parameters:
user- the LuteceDefaultAdminUSer
-
update
public static void update(LuteceDefaultAdminUser user, PasswordUpdateMode passwordMode)
- Parameters:
user- the LuteceDefaultAdminUSerpasswordMode- should the password be updated or not
-
findLuteceDefaultAdminUserByPrimaryKey
public static LuteceDefaultAdminUser findLuteceDefaultAdminUserByPrimaryKey(int nUserId)
Get the user infos from user id- Parameters:
nUserId- the user identifier- Returns:
- the delfault admin user
-
findByRole
public static java.util.Collection<AdminUser> findByRole(java.lang.String strRoleKey)
Get all users having a given role- Parameters:
strRoleKey- The role key- Returns:
- A collection of AdminUser
-
findByLevel
public static java.util.Collection<AdminUser> findByLevel(int nIdLevel)
Get all users having a given level- Parameters:
nIdLevel- The level- Returns:
- A collection of AdminUser
-
updateUsersRole
public static void updateUsersRole(java.lang.String strOldRoleKey, RBACRole role)Update role key if role key name has change- Parameters:
strOldRoleKey- The old role key namerole- The new role
-
findUserByFilter
public static java.util.Collection<AdminUser> findUserByFilter(AdminUserFilter auFilter)
Get all users by using a filter.- Parameters:
auFilter- The filter- Returns:
- A collection of AdminUser
-
findByRight
public static java.util.Collection<AdminUser> findByRight(java.lang.String strIdRight)
Get all users having a given right- Parameters:
strIdRight- The ID right- Returns:
- A collection of AdminUser
-
hasRight
public static boolean hasRight(AdminUser user, java.lang.String strIdRight)
Check if the user has the given right- Parameters:
user- The Admin UserstrIdRight- The ID right- Returns:
- true if the user has the right
-
removeRightForUser
public static void removeRightForUser(int nUserId, java.lang.String strIdRight)Remove a right for an user- Parameters:
nUserId- The user IDstrIdRight- The right ID
-
selectUserPasswordHistory
public static java.util.List<IPassword> selectUserPasswordHistory(int nUserID)
Gets the history of password of the given user- Parameters:
nUserID- Id of the user- Returns:
- The collection of recent passwords used by the user.
-
countUserPasswordHistoryFromDate
public static int countUserPasswordHistoryFromDate(java.sql.Timestamp minDate, int nUserId)Get the number of password change done by a user since the given date.- Parameters:
minDate- Minimum date to consider.nUserId- Id of the user- Returns:
- The number of password change done by the user since the given date.
-
insertNewPasswordInHistory
public static void insertNewPasswordInHistory(IPassword password, int nUserId)
Log a password change in the password history- Parameters:
password- New password of the usernUserId- Id of the user
-
removeAllPasswordHistoryForUser
public static void removeAllPasswordHistoryForUser(int nUserId)
Remove every password saved in the password history for a user.- Parameters:
nUserId- Id of the user
-
getAnonymizationStatusUserStaticField
public static java.util.Map<java.lang.String,java.lang.Boolean> getAnonymizationStatusUserStaticField()
Get a map of anonymization status of a user field.- Returns:
- A map containing the associations of user field name and a boolean describing whether the field should be anonymized.
-
updateAnonymizationStatusUserStaticField
public static void updateAnonymizationStatusUserStaticField(java.lang.String strFieldName, boolean bAnonymizeFiled)Update the anonymization status of a user field.- Parameters:
strFieldName- Name of the field to updatebAnonymizeFiled- True if the field should be anonymize, false otherwise
-
findAllExpiredUserId
public static java.util.List<java.lang.Integer> findAllExpiredUserId()
Get the list of id of user with the expired status.- Returns:
- The list of if of user with the expired status.
-
getIdUsersWithExpiredLifeTimeList
public static java.util.List<java.lang.Integer> getIdUsersWithExpiredLifeTimeList(java.sql.Timestamp currentTimestamp)
Get the list of id of users that have an expired time life but not the expired status- Parameters:
currentTimestamp- Timestamp describing the current time.- Returns:
- the list of id of users with expired time life
-
getUsersWithLifeTimeToResync
public static java.util.List<AdminUser> getUsersWithLifeTimeToResync(java.sql.Timestamp maxValidDate)
Get the users whose account life time may have to be resynchronized from their last login date : users with a not null account max valid date lower than the given date, and whose status is active, not active or expired. Only the id, the status, the account max valid date and the last login date of the returned users are set.- Parameters:
maxValidDate- The maximum account valid date of the users to return- Returns:
- the list of users, with only their id, status, account max valid date and last login date set
-
getIdUsersToSendFirstAlert
public static java.util.List<java.lang.Integer> getIdUsersToSendFirstAlert(java.sql.Timestamp firstAlertMaxDate)
Get the list of id of users that need to receive their first alert- Parameters:
firstAlertMaxDate- The maximum expiration date to send first alert.- Returns:
- the list of id of users that need to receive their first alert
-
getIdUsersToSendOtherAlert
public static java.util.List<java.lang.Integer> getIdUsersToSendOtherAlert(java.sql.Timestamp alertMaxDate, java.sql.Timestamp timeBetweenAlerts, int maxNumberAlerts)Get the list of id of users that need to receive their first alert- Parameters:
alertMaxDate- The maximum date to send alerts.timeBetweenAlerts- Timestamp describing the time between two alerts.maxNumberAlerts- Maximum number of alerts to send to a user- Returns:
- the list of id of users that need to receive their first alert
-
getIdUsersWithExpiredPasswordsList
public static java.util.List<java.lang.Integer> getIdUsersWithExpiredPasswordsList(java.sql.Timestamp currentTimestamp)
Get the list of id of users that have an expired password but not the change password flag- Parameters:
currentTimestamp- Timestamp describing the current time.- Returns:
- the list of id of users with expired passwords
-
updateUserStatus
public static void updateUserStatus(java.util.List<java.lang.Integer> listIdUser, int nNewStatus)Update status of a list of user accounts- Parameters:
listIdUser- List of user accounts to updatenNewStatus- New status of the user
-
updateNbAlert
public static void updateNbAlert(java.util.List<java.lang.Integer> listIdUser)
Increment the number of alert send to users by 1- Parameters:
listIdUser- The list of users to update
-
updateChangePassword
public static void updateChangePassword(java.util.List<java.lang.Integer> listIdUser)
Set the "change password" flag of users to true- Parameters:
listIdUser- The list of users to update
-
updateUserExpirationDate
public static void updateUserExpirationDate(int nIdUser, java.sql.Timestamp newExpirationDate)Update the admin user expiration date with the new values. Also update his alert account to 0- Parameters:
nIdUser- Id of the admin user to updatenewExpirationDate- Id of the user to update
-
updateDateLastLogin
public static void updateDateLastLogin(int nIdUser, java.sql.Timestamp dateLastLogin)Update the admin user last login date.- Parameters:
nIdUser- Id of the admin user to updatedateLastLogin- New last login date of the user
-
getUserPasswordResetToken
public static java.lang.String getUserPasswordResetToken(int nIdUser, java.util.Date timestamp, java.lang.String strSessionId)Construct a password reset token. Use the numerical userId as it does not change. Use the stored password, so that the token is invalidated if the password is changed. Use a timestamp to allow limiting the validity of the token in time. Optionally bind the token to the user session. Finally return an HMAC of this info using the application crypto key.- Parameters:
nIdUser- the user IDtimestamp- the timestampstrSessionId- the session ID- Returns:
- the password reset token
-
-