Interface UserService

    • Method Detail

      • getUserForUID

        UserModel getUserForUID​(java.lang.String userId)
        Returns the UserModel for the specified userId
        Parameters:
        userId - the unique userId of the user
        Returns:
        the UserModel or a subtype of it.
        Throws:
        UnknownIdentifierException - if user was not found
        java.lang.IllegalArgumentException - if given userId was null
      • getUserForUID

        <T extends UserModel> T getUserForUID​(java.lang.String userId,
                                              java.lang.Class<T> clazz)
        Returns for the specified userId and the specified (result) class the found user in the specified class. Throws exception otherwise.
        Parameters:
        userId - The unique userId of the user to be searched for.
        clazz - The user must match the given class (employee, customer, ...). Can be a UserModel or any subtype of it.
        Throws:
        UnknownIdentifierException - if the user was not found
        java.lang.IllegalArgumentException - if given userId or given clazz was null
        ClassMismatchException - if a user was found by the given userId but did not match the provided clazz
      • isUserExisting

        boolean isUserExisting​(java.lang.String uid)
        Checks if for the specified uid a user exists in the system.
        Parameters:
        uid - of the user
        Returns:
        true if a user exists, otherwise false
      • getUserGroupForUID

        UserGroupModel getUserGroupForUID​(java.lang.String uid)
        Returns the UserGroupModel for the specified uid.
        Parameters:
        uid - the unique uid of the group
        Returns:
        the found UserGroupModel (or a subtype of it).
        Throws:
        UnknownIdentifierException - if user group was not found
        java.lang.IllegalArgumentException - if given uid was null
      • getUserGroupForUID

        <T extends UserGroupModel> T getUserGroupForUID​(java.lang.String uid,
                                                        java.lang.Class<T> clazz)
        Returns the UserGroupModel for the specified uid and the specified (result) class.

        The found user group must be an instance of the given class, otherwise an exception is thrown.

        Parameters:
        uid - The unique uid of the user group to be searched for.
        clazz - The user group must match the given class. Can be a UserGroupModel or any subtype of it.
        Returns:
        the found UserGroupModel
        Throws:
        UnknownIdentifierException - if user group was not found
        ClassMismatchException - if a user group was found by the given uid but did not match the provided clazz
        java.lang.IllegalArgumentException - if given uid or given clazz was null
      • getAllUserGroupsForUser

        java.util.Set<UserGroupModel> getAllUserGroupsForUser​(UserModel user)
        Gets all user groups for the given user.

        The Set of user groups is collected recursively.

        Parameters:
        user - the given user
        Returns:
        Set of user groups
        Throws:
        java.lang.IllegalArgumentException - if given user is null
      • getAllUserGroupsForUser

        <T extends UserGroupModel> java.util.Set<T> getAllUserGroupsForUser​(UserModel user,
                                                                            java.lang.Class<T> clazz)
        Gets all user groups for the given user and specified (result) class. If the user is in a user group which is not assignable from the given clazz then this group is not in the result set. Use getUserGroupForUID(String) if all groups are needed.

        The Set of user groups is collected recursively.

        Parameters:
        user - the given user
        clazz - the user group must match the given class. Can be a UserGroupModel or any subtype of it.
        Returns:
        Set of user groups which must be instances of the specified result class
        Throws:
        java.lang.IllegalArgumentException - if given user or given clazz are null
      • getUserAudits

        java.util.List<AbstractUserAuditModel> getUserAudits​(UserModel user)
        Gets audit information about user previous password hashes. Can be used to implement password policy that does not allow to reuse previous passwords.
        Parameters:
        user -
        Returns:
      • isPasswordIdenticalToAudited

        boolean isPasswordIdenticalToAudited​(UserModel user,
                                             java.lang.String plainPassword,
                                             UserPasswordChangeAuditModel audit)
        Checks if password is the same as the previous password. Password stored in audit information is hashed so this method hashes plain password and compares them.
        Parameters:
        plainPassword -
        audit -
        Returns:
        true if password is the same as audit, otherwise false
      • getAllUserGroupsForUserGroup

        <T extends UserGroupModel> java.util.Set<T> getAllUserGroupsForUserGroup​(UserGroupModel userGroup,
                                                                                 java.lang.Class<T> clazz)
        Gets all user groups for the given user group and specified (result) class. If the user is in a user group which is not assignable from the given clazz then this group is not in the result set. Use getUserGroupForUID(String) if all groups are needed.

        The Set of user groups is collected recursively.

        Parameters:
        userGroup - the given user group
        clazz - the user group must match the given class. Can be a UserGroupModel or any subtype of it.
        Returns:
        Set of user groups which must be instances of the specified result class
        Throws:
        java.lang.IllegalArgumentException - if given user group or given clazz are null
      • isMemberOfGroup

        boolean isMemberOfGroup​(UserModel member,
                                UserGroupModel groupToCheckFor)
        Checks if the given user is a member of the specified groupToCheckFor or its super groups.

        The super groups are collected recursively.

        Parameters:
        member - the user to check
        groupToCheckFor - the group(s) to be checked for
        Returns:
        true if the user is a member of this group, otherwise false
        Throws:
        java.lang.IllegalArgumentException - if the given user or the given groupToCheckFor are null
      • isMemberOfGroup

        boolean isMemberOfGroup​(UserModel member,
                                UserGroupModel groupToCheckFor,
                                boolean includeSuperGroups)
        Checks if the given user is a member of the specified groupToCheckFor or its super groups if includeSubGroups is set to true.

        The super groups are collected recursively.

        Parameters:
        member - the user to check
        groupToCheckFor - the group(s) to be checked for
        includeSuperGroups - should include super groups in search
        Returns:
        true if the user is a member of this group, otherwise false
        Throws:
        java.lang.IllegalArgumentException - if the given user or the given groupToCheckFor are null
      • isMemberOfGroup

        boolean isMemberOfGroup​(UserGroupModel member,
                                UserGroupModel groupToCheckFor)
        Checks if the given user group is a member of the specified groupToCheckFor or its super groups.

        The super groups are collected recursively.

        Parameters:
        member - the user group to check
        groupToCheckFor - the group(s) to be checked for
        Returns:
        true if the user group is a member of this group, otherwise false
        Throws:
        java.lang.IllegalArgumentException - if the given user group or the given groupToCheckFor are null
      • isMemberOfGroup

        boolean isMemberOfGroup​(UserGroupModel member,
                                UserGroupModel groupToCheckFor,
                                boolean includeSuperGroups)
        Checks if the given user group is a member of the specified groupToCheckFor or its super groups if includeSubGroups is set to true.

        The super groups are collected recursively.

        Parameters:
        member - the user group to check
        groupToCheckFor - the group(s) to be checked for
        includeSuperGroups - should include super groups in search
        Returns:
        true if the user group is a member of this group, otherwise false
        Throws:
        java.lang.IllegalArgumentException - if the given user group or the given groupToCheckFor are null
      • getAllTitles

        java.util.Collection<TitleModel> getAllTitles()
        Returns all TitleModels in the system.
        Returns:
        an empty collection if no TitleModel was found.
      • getAdminUser

        EmployeeModel getAdminUser()
        Returns always the admin user. Search restrictions are disabled for this call.
        Returns:
        the system admin user as EmployeeModel
      • getAdminUserGroup

        UserGroupModel getAdminUserGroup()
        Returns always the admin user group. Search restrictions are disabled for this call.
        Returns:
        the admin user group as UserGroupModel
      • isAdmin

        boolean isAdmin​(UserModel user)
        Checks if the given user has the admin role.

        The user is an admin if either the user is the admin employee or the user is a member of the admin user group (see getAdminUserGroup()).

        Parameters:
        user - user to check
        Returns:
        true if the user is an admin, otherwise false
        Throws:
        java.lang.IllegalArgumentException - if the given is null
      • isAdminGroup

        boolean isAdminGroup​(UserGroupModel userGroup)
        Checks if the given user group or it's super groups have the admin role.

        Parameters:
        userGroup - user to check
        Returns:
        true if the user is an admin, otherwise false
        Throws:
        java.lang.IllegalArgumentException - if the given is null
      • isAdminEmployee

        boolean isAdminEmployee​(UserModel user)
        Checks if the given user has the is the admin employee.

        see getAdminUser()).

        Parameters:
        user - user to check
        Returns:
        true if the user is an admin employee, otherwise false
        Throws:
        java.lang.IllegalArgumentException - if the given is null
      • getAnonymousUser

        CustomerModel getAnonymousUser()
        Returns always the anonymous user. Search restrictions are disabled for this call.
        Returns:
        the anonymous user as CustomerModel
      • isAnonymousUser

        boolean isAnonymousUser​(UserModel user)
        Checks if the given user is the anonymous customer.
        Parameters:
        user - the user to check
        Returns:
        true if the user is the anonymous customer, otherwise false
      • setPassword

        void setPassword​(java.lang.String userId,
                         java.lang.String password,
                         java.lang.String encoding)
                  throws PasswordEncoderNotFoundException
        Sets the password according to the given encoding for the given user id.
        Parameters:
        userId - the user ID
        password - the plain password
        encoding - the encoding to encode the given password
        Throws:
        PasswordEncoderNotFoundException - is thrown if given encoding does not match any password encoder in the system
      • setEncodedPassword

        void setEncodedPassword​(UserModel user,
                                java.lang.String encodedPassword)
        Sets the encoded password to the given user.

        The encoding is taken form user or if null the system default encoding is used.

        Parameters:
        user - the encoded password is set to UserModel.setEncodedPassword(String)
        encodedPassword - encoded password for the user
      • setEncodedPassword

        void setEncodedPassword​(UserModel user,
                                java.lang.String encodedPassword,
                                java.lang.String encoding)
        Sets the encoded password to the given user.
        Parameters:
        user - the encoded password is set to UserModel.setEncodedPassword(String)
        encodedPassword - encoded password for the user
        encoding - the password encoding