Class AdminUserHome


  • public final class AdminUserHome
    extends java.lang.Object
    This class provides instances management methods (create, find, ...) for AdminUser objects
    • 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 login
        user - 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 identifier
        strRightId - 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 user
        strRightId - 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 AdminUser
        strRoleKey - 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 user
        strRoleKey - 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 LuteceDefaultAdminUSer
        passwordMode - 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 name
        role - 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 User
        strIdRight - 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 ID
        strIdRight - 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 user
        nUserId - 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 update
        bAnonymizeFiled - 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
      • 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 update
        nNewStatus - 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 update
        newExpirationDate - 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 update
        dateLastLogin - 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 ID
        timestamp - the timestamp
        strSessionId - the session ID
        Returns:
        the password reset token