Class AdminUserService
java.lang.Object
fr.paris.lutece.portal.service.admin.AdminUserService
This service provides features concerning the administration users
-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final Stringstatic final Stringstatic final Stringstatic final Stringstatic final Stringstatic final Stringstatic final Stringstatic final Stringstatic final Stringstatic final Stringstatic final Stringstatic final Stringstatic final Stringstatic final Stringstatic final Stringstatic final Stringstatic final Stringstatic final Stringstatic final Stringstatic final Stringstatic final Stringstatic final Stringstatic final Stringstatic final Stringstatic final Stringstatic final Stringstatic final Stringstatic final Stringstatic final String -
Method Summary
Modifier and TypeMethodDescriptionstatic voidanonymizeUser(int nAdminUserId, Locale locale) Anonymize user data from his id.static booleancheckEmail(String strEmail) Check if the given email is valid or not.static StringcheckPassword(jakarta.servlet.http.HttpServletRequest request, String strPassword, int nUserId) Check that the password respect user parametersstatic StringcheckPassword(jakarta.servlet.http.HttpServletRequest request, String strPassword, int nUserId, boolean bSkipHistoryCheck) Check that the password respect user parametersstatic voiddoInsertRegularExpression(int nRegularExpressionId) Do insert a regular expressionstatic voiddoModifyEmailPattern(String strEmailPattern, boolean bIsSetManually) Do modify the email patternstatic voiddoRemoveRegularExpression(int nRegularExpressionId) Do remove a regular expressionstatic voidReset the email pattern by putting the default email pattern that is set in the lutece.properties.static IPasswordencryptPassword(String strPassword) Encrypt a passwordstatic TimestampCompute the maximum valid date of an account with the current time and the parameters in the database.static TimestampgetAccountMaxValidDate(Timestamp dateFrom) Compute the maximum valid date of an account from a given date and the parameters in the database.static AdminUsergetAdminUser(jakarta.servlet.http.HttpServletRequest request) Get the user in sessionstatic ReferenceListGet the available rugalar expressionsstatic booleangetBooleanSecurityParameter(String strParameterkey) Get a boolean user parameter from its key.static StringgetEmailErrorMessageUrl(jakarta.servlet.http.HttpServletRequest request) Get the email error message url.Get the list of id of expired usersstatic AdminUserWrappergetExportUser(AdminUser user, boolean bIncludeRoles, boolean bIncludeRights, boolean bIncludeWorkgroups, boolean bIncludeAttributes, List<IAttribute> listAttributes) getFilteredUsersInterface(Collection<AdminUser> listUsers, jakarta.servlet.http.HttpServletRequest request, Map<String, Object> model, UrlItem url) Get the filtered list of admin usersstatic intgetIntegerSecurityParameter(String strParameterkey) Get an integer user parameter from its key.static StringgetLargeSecurityParameter(String strParameterKey) Get a user parameter from its key.static LocalegetLocale(jakarta.servlet.http.HttpServletRequest request) Get the locale for the current requestBuild the advanced parameters managementstatic TimestampCompute the maximum valid date of a password with the current time and the parameters in the database.static StringgetSecurityParameter(String strParameterkey) Get a user parameter from its key.static List<RegularExpression>Get the list of selected regular expressionstatic StringgetUserPasswordResetToken(AdminUser user, Date timestamp, jakarta.servlet.http.HttpServletRequest request) Get a user reset password tokenstatic StringGenerate a new random passwordstatic voidnotifyUser(String strBaseUrl, AdminUser user, String strPropertyEmailSubject, String strTemplate) Notify an user by emailstatic voidnotifyUser(String strBaseUrl, AdminUser user, String strPassword, String strPropertyEmailSubject, String strTemplate) Notify an user by emailstatic voidDisable advances security parametersstatic voidupdateDateLastLogin(int nIdUser) Update the date of last login of an admin userstatic voidupdateLargeSecurityParameter(String strParameterKey, String strValue) Update a security parameter value.static voidupdateSecurityParameter(String strParameterKey, String strValue) Update a security parameter value.static voidUpdate the user expiration date with new values, and notify him with an email if his account was close to expire.static voidEnable advanced security parameters
-
Field Details
-
DSKEY_ACCOUNT_REACTIVATED_MAIL_SENDER
- See Also:
-
DSKEY_ACCOUNT_REACTIVATED_MAIL_SUBJECT
- See Also:
-
DSKEY_ACCOUNT_REACTIVATED_MAIL_BODY
- See Also:
-
DSKEY_PASSWORD_DURATION
- See Also:
-
DSKEY_MAXIMUM_NUMBER_PASSWORD_CHANGE
- See Also:
-
DSKEY_PASSWORD_HISTORY_SIZE
- See Also:
-
DSKEY_TSW_SIZE_PASSWORD_CHANGE
- See Also:
-
DSKEY_NOTIFY_USER_PASSWORD_EXPIRED
- See Also:
-
DSKEY_BANNED_DOMAIN_NAMES
- See Also:
-
DSKEY_ACCOUNT_LIFE_TIME
- See Also:
-
DSKEY_TIME_BEFORE_ALERT_ACCOUNT
- See Also:
-
DSKEY_NB_ALERT_ACCOUNT
- See Also:
-
DSKEY_TIME_BETWEEN_ALERTS_ACCOUNT
- See Also:
-
DSKEY_ACCES_FAILURES_MAX
- See Also:
-
DSKEY_ACCES_FAILURES_INTERVAL
- See Also:
-
DSKEY_EMAIL_PATTERN
- See Also:
-
DSKEY_EMAIL_PATTERN_VERIFY_BY
- See Also:
-
DSKEY_PASSWORD_FORMAT_SPECIAL_CHARACTERS
- See Also:
-
DSKEY_PASSWORD_FORMAT_NUMERO
- See Also:
-
DSKEY_PASSWORD_FORMAT_UPPER_LOWER_CASE
- See Also:
-
DSKEY_FORCE_CHANGE_PASSWORD_REINIT
- See Also:
-
DSKEY_PASSWORD_MINIMUM_LENGTH
- See Also:
-
DSKEY_DEFAULT_USER_STATUS
- See Also:
-
DSKEY_DEFAULT_USER_LANGUAGE
- See Also:
-
DSKEY_DEFAULT_USER_NOTIFICATION
- See Also:
-
DSKEY_DEFAULT_USER_LEVEL
- See Also:
-
DSKEY_USE_ADVANCED_SECURITY_PARAMETERS
- See Also:
-
DSKEY_RESET_TOKEN_VALIDITY
- See Also:
-
DSKEY_LOCK_RESET_TOKEN_TO_SESSION
- See Also:
-
-
Method Details
-
getAdminUser
Get the user in session- Parameters:
request- The HTTP request- Returns:
- the user in session
-
getLocale
Get the locale for the current request- Parameters:
request- The HTTP request- Returns:
- the locale to use with this request
-
getFilteredUsersInterface
public static List<AdminUser> getFilteredUsersInterface(Collection<AdminUser> listUsers, jakarta.servlet.http.HttpServletRequest request, Map<String, Object> model, UrlItem url) Get the filtered list of admin users- Parameters:
listUsers- the initial list of usersrequest- HttpServletRequestmodel- mapurl- URL of the current interface- Returns:
- The filtered list of admin users
-
getManageAdvancedParameters
Build the advanced parameters management- Parameters:
user- The AdminUser object- Returns:
- The model for the advanced parameters
-
checkEmail
Check if the given email is valid or not.
The given email is compared to the value of the parameter 'core_user_parameter.email_pattern'.- Parameters:
strEmail- the str email- Returns:
- true, if successful
-
doModifyEmailPattern
Do modify the email pattern- Parameters:
strEmailPattern- the email patternbIsSetManually- true if it is know set manually, false otherwise
-
doResetEmailPattern
public static void doResetEmailPattern()Reset the email pattern by putting the default email pattern that is set in the lutece.properties. -
getEmailErrorMessageUrl
Get the email error message url.- Parameters:
request- the request- Returns:
- the error message
-
doInsertRegularExpression
public static void doInsertRegularExpression(int nRegularExpressionId) Do insert a regular expression- Parameters:
nRegularExpressionId- the ID of the regular expression
-
doRemoveRegularExpression
public static void doRemoveRegularExpression(int nRegularExpressionId) Do remove a regular expression- Parameters:
nRegularExpressionId- the ID of the regularexpresion
-
getAvailableRegularExpressions
Get the available rugalar expressions- Returns:
- a list of
ReferenceList
-
getSelectedRegularExpressions
Get the list of selected regular expression- Returns:
- a list of
RegularExpression
-
getIntegerSecurityParameter
Get an integer user parameter from its key.- Parameters:
strParameterkey- Key of the parameter- Returns:
- The value of the user parameter, or 0 if there is no value or an non integer value.
-
getBooleanSecurityParameter
Get a boolean user parameter from its key.- Parameters:
strParameterkey- Key of the parameter- Returns:
- The value of the user parameter, or false if there is no value or an non boolean value.
-
getSecurityParameter
Get a user parameter from its key.- Parameters:
strParameterkey- Key of the parameter- Returns:
- The value of the user parameter.
-
getLargeSecurityParameter
Get a user parameter from its key.- Parameters:
strParameterKey- Key of the parameter- Returns:
- The value of the user parameter.
-
updateSecurityParameter
Update a security parameter value.- Parameters:
strParameterKey- The key of the parameterstrValue- The new value
-
updateLargeSecurityParameter
Update a security parameter value.- Parameters:
strParameterKey- The key of the parameterstrValue- The new value
-
checkPassword
public static String checkPassword(jakarta.servlet.http.HttpServletRequest request, String strPassword, int nUserId) Check that the password respect user parameters- Parameters:
request- The requeststrPassword- The password to checknUserId- The id of the modified user- Returns:
- Null if the password is correct, or the url of an admin message describing the error
-
checkPassword
public static String checkPassword(jakarta.servlet.http.HttpServletRequest request, String strPassword, int nUserId, boolean bSkipHistoryCheck) Check that the password respect user parameters- Parameters:
request- The requeststrPassword- The password to checknUserId- The id of the modified userbSkipHistoryCheck- Indicates if the password history should be checked or not.- Returns:
- Null if the password is correct, or the url of an admin message describing the error
-
makePassword
Generate a new random password- Returns:
- the new password
-
encryptPassword
Encrypt a password- Parameters:
strPassword- The password to encrypt- Returns:
- The given password encrypted
-
useAdvancedSecurityParameters
public static void useAdvancedSecurityParameters()Enable advanced security parameters -
removeAdvancedSecurityParameters
public static void removeAdvancedSecurityParameters()Disable advances security parameters -
getPasswordMaxValidDate
Compute the maximum valid date of a password with the current time and the parameters in the database.- Returns:
- The maximum valid date of a password
-
getAccountMaxValidDate
Compute the maximum valid date of an account with the current time and the parameters in the database.- Returns:
- The maximum valid date of an account
-
getAccountMaxValidDate
Compute the maximum valid date of an account from a given date and the parameters in the database.- Parameters:
dateFrom- The date from which the account life time is counted (for example the last login date of the user)- Returns:
- The maximum valid date of an account, or null if the account life time is not set or if dateFrom is null
-
anonymizeUser
Anonymize user data from his id. His rights, roles and his passwords history are also deleted.- Parameters:
nAdminUserId- Id of the user to anonymizelocale- The locale
-
getExpiredUserIdList
Get the list of id of expired users- Returns:
- the list of id of expired users
-
updateUserExpirationDate
Update the user expiration date with new values, and notify him with an email if his account was close to expire.- Parameters:
user- The user to update
-
updateDateLastLogin
public static void updateDateLastLogin(int nIdUser) Update the date of last login of an admin user- Parameters:
nIdUser- Id of the user to update
-
notifyUser
public static void notifyUser(String strBaseUrl, AdminUser user, String strPropertyEmailSubject, String strTemplate) Notify an user by email- Parameters:
strBaseUrl- The base URL of the webappuser- The admin user to notifystrPropertyEmailSubject- the property of the subject emailstrTemplate- the URL of the HTML Template
-
notifyUser
public static void notifyUser(String strBaseUrl, AdminUser user, String strPassword, String strPropertyEmailSubject, String strTemplate) Notify an user by email- Parameters:
strBaseUrl- The base URL of the webappuser- The admin user to notifystrPassword- the user password in cleartextstrPropertyEmailSubject- the property of the subject emailstrTemplate- the URL of the HTML Template
-
getExportUser
public static AdminUserWrapper getExportUser(AdminUser user, boolean bIncludeRoles, boolean bIncludeRights, boolean bIncludeWorkgroups, boolean bIncludeAttributes, List<IAttribute> listAttributes) - Parameters:
user- The usebIncludeRoles- True to include roles of the userbIncludeRights- True to include rights of the userbIncludeWorkgroups- True to include workgroups of the userbIncludeAttributes- True to include attributes of the userlistAttributes- The list of attributes to include in the user- Returns:
- A AdminUserExport
-
getUserPasswordResetToken
public static String getUserPasswordResetToken(AdminUser user, Date timestamp, jakarta.servlet.http.HttpServletRequest request) Get a user reset password token- Parameters:
user- the usertimestamp- the timestamp of the tokenrequest- he request- Returns:
- the reset password token
-