Class DefaultUserService

  • All Implemented Interfaces:
    UserService, java.io.Serializable, org.springframework.beans.factory.Aware, org.springframework.beans.factory.BeanNameAware, org.springframework.beans.factory.InitializingBean
    Direct Known Subclasses:
    SecureUserService

    public class DefaultUserService
    extends AbstractBusinessService
    implements UserService
    Default implementation of the user service interface.
    Since:
    4.0
    See Also:
    Serialized Form
    • Constructor Detail

      • DefaultUserService

        public DefaultUserService()
    • Method Detail

      • getUser

        @Deprecated
        public UserModel getUser​(java.lang.String uid)
        Deprecated.
        since 6.1.0
        Description copied from interface: UserService
        Returns the UserModel by the specified userId
        Specified by:
        getUser in interface UserService
        Parameters:
        uid - the specified userId
        Returns:
        the UserModel
      • getUserForUID

        public UserModel getUserForUID​(java.lang.String userId)
        Description copied from interface: UserService
        Returns the UserModel for the specified userId
        Specified by:
        getUserForUID in interface UserService
        Parameters:
        userId - the unique userId of the user
        Returns:
        the UserModel or a subtype of it.
      • getUserForUID

        public <T extends UserModel> T getUserForUID​(java.lang.String userId,
                                                     java.lang.Class<T> clazz)
        Description copied from interface: UserService
        Returns for the specified userId and the specified (result) class the found user in the specified class. Throws exception otherwise.
        Specified by:
        getUserForUID in interface UserService
        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.
      • isUserExisting

        public boolean isUserExisting​(java.lang.String uid)
        Description copied from interface: UserService
        Checks if for the specified uid a user exists in the system.
        Specified by:
        isUserExisting in interface UserService
        Parameters:
        uid - of the user
        Returns:
        true if a user exists, otherwise false
      • setPassword

        public void setPassword​(UserModel user,
                                java.lang.String plainPassword,
                                java.lang.String encoding)
        Description copied from interface: UserService
        Encodes the given plain text password with the given password encoding and set the encoded password to the given user.
        Specified by:
        setPassword in interface UserService
        Parameters:
        user - the encoded password is set to UserModel.setEncodedPassword(String)
        plainPassword - the plain text password for the user
        encoding - the password encidung, must exist
      • assurePasswordCompliance

        protected void assurePasswordCompliance​(UserModel user,
                                                java.lang.String plainPassword,
                                                java.lang.String encoding)
      • getRealEncoding

        protected java.lang.String getRealEncoding​(java.lang.String optionalEncoding)
      • setPassword

        public void setPassword​(java.lang.String userId,
                                java.lang.String password,
                                java.lang.String encoding)
                         throws PasswordEncoderNotFoundException
        Description copied from interface: UserService
        Sets the password according to the given encoding for the given user id.
        Specified by:
        setPassword in interface UserService
        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
      • getUserGroupForUID

        public <T extends UserGroupModel> T getUserGroupForUID​(java.lang.String uid,
                                                               java.lang.Class<T> clazz)
        Description copied from interface: UserService
        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.

        Specified by:
        getUserGroupForUID in interface UserService
        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
      • getAllUserGroupsForUser

        public <T extends UserGroupModel> java.util.Set<T> getAllUserGroupsForUser​(UserModel user,
                                                                                   java.lang.Class<T> clazz)
        Description copied from interface: UserService
        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 UserService.getUserGroupForUID(String) if all groups are needed.

        The Set of user groups is collected recursively.

        Specified by:
        getAllUserGroupsForUser in interface UserService
        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
      • getAllUserGroupsForUserGroup

        public <T extends UserGroupModel> java.util.Set<T> getAllUserGroupsForUserGroup​(UserGroupModel userGroup,
                                                                                        java.lang.Class<T> clazz)
        Description copied from interface: UserService
        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 UserService.getUserGroupForUID(String) if all groups are needed.

        The Set of user groups is collected recursively.

        Specified by:
        getAllUserGroupsForUserGroup in interface UserService
        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
      • getUserAudits

        public java.util.List<AbstractUserAuditModel> getUserAudits​(UserModel user)
        Description copied from interface: UserService
        Gets audit information about user previous password hashes. Can be used to implement password policy that does not allow to reuse previous passwords.
        Specified by:
        getUserAudits in interface UserService
        Returns:
      • isPasswordIdenticalToAudited

        public boolean isPasswordIdenticalToAudited​(UserModel user,
                                                    java.lang.String plainPassword,
                                                    UserPasswordChangeAuditModel audit)
        Description copied from interface: UserService
        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.
        Specified by:
        isPasswordIdenticalToAudited in interface UserService
        Returns:
        true if password is the same as audit, otherwise false
      • isMemberOfGroup

        public boolean isMemberOfGroup​(UserModel member,
                                       UserGroupModel groupToCheckFor)
        Description copied from interface: UserService
        Checks if the given user is a member of the specified groupToCheckFor or its super groups.

        The super groups are collected recursively.

        Specified by:
        isMemberOfGroup in interface UserService
        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
      • isMemberOfGroup

        public boolean isMemberOfGroup​(UserModel member,
                                       UserGroupModel groupToCheckFor,
                                       boolean includeSuperGroups)
        Description copied from interface: UserService
        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.

        Specified by:
        isMemberOfGroup in interface UserService
        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
      • isMemberOfGroup

        public boolean isMemberOfGroup​(UserGroupModel member,
                                       UserGroupModel groupToCheckFor)
        Description copied from interface: UserService
        Checks if the given user group is a member of the specified groupToCheckFor or its super groups.

        The super groups are collected recursively.

        Specified by:
        isMemberOfGroup in interface UserService
        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
      • isMemberOfGroup

        public boolean isMemberOfGroup​(UserGroupModel member,
                                       UserGroupModel groupToCheckFor,
                                       boolean includeSuperGroups)
        Description copied from interface: UserService
        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.

        Specified by:
        isMemberOfGroup in interface UserService
        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
      • isAdmin

        public boolean isAdmin​(UserModel user)
        Description copied from interface: UserService
        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 UserService.getAdminUserGroup()).

        Specified by:
        isAdmin in interface UserService
        Parameters:
        user - user to check
        Returns:
        true if the user is an admin, otherwise false
      • isAdminGroup

        public boolean isAdminGroup​(UserGroupModel userGroup)
        Description copied from interface: UserService
        Checks if the given user group or it's super groups have the admin role.

        Specified by:
        isAdminGroup in interface UserService
        Parameters:
        userGroup - user to check
        Returns:
        true if the user is an admin, otherwise false
      • isAdminEmployee

        public boolean isAdminEmployee​(UserModel user)
        Description copied from interface: UserService
        Checks if the given user has the is the admin employee.

        see UserService.getAdminUser()).

        Specified by:
        isAdminEmployee in interface UserService
        Parameters:
        user - user to check
        Returns:
        true if the user is an admin employee, otherwise false
      • isAnonymousUser

        public boolean isAnonymousUser​(UserModel user)
        Description copied from interface: UserService
        Checks if the given user is the anonymous customer.
        Specified by:
        isAnonymousUser in interface UserService
        Parameters:
        user - the user to check
        Returns:
        true if the user is the anonymous customer, otherwise false
      • setEncodedPassword

        public void setEncodedPassword​(UserModel user,
                                       java.lang.String encodedPassword)
        Description copied from interface: UserService
        Sets the encoded password to the given user.

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

        Specified by:
        setEncodedPassword in interface UserService
        Parameters:
        user - the encoded password is set to UserModel.setEncodedPassword(String)
        encodedPassword - encoded password for the user
      • setEncodedPassword

        public void setEncodedPassword​(UserModel user,
                                       java.lang.String encodedPassword,
                                       java.lang.String encoding)
        Description copied from interface: UserService
        Sets the encoded password to the given user.
        Specified by:
        setEncodedPassword in interface UserService
        Parameters:
        user - the encoded password is set to UserModel.setEncodedPassword(String)
        encodedPassword - encoded password for the user
        encoding - the password encoding
      • setUserDao

        public void setUserDao​(UserDao userDao)
      • setUserGroupDao

        public void setUserGroupDao​(UserGroupDao userGroupDao)
      • setTitleDao

        public void setTitleDao​(TitleDao titleDao)
      • setSearchRestrictionService

        public void setSearchRestrictionService​(SearchRestrictionService searchRestrictionService)
      • setEventService

        public void setEventService​(EventService eventService)
      • setPasswordEncoderService

        public void setPasswordEncoderService​(PasswordEncoderService passwordEncoderService)
      • getDefaultPasswordEncoding

        public java.lang.String getDefaultPasswordEncoding()
      • setDefaultPasswordEncoding

        public void setDefaultPasswordEncoding​(java.lang.String defaultPasswordEncoding)
      • setPasswordPolicyService

        public void setPasswordPolicyService​(PasswordPolicyService passwordPolicyService)
      • setUserAuditDao

        public void setUserAuditDao​(UserAuditDao userAuditDao)