Class User


  • public class User
    extends java.lang.Object
    A user. The boolean checks on the state of the user hinge off the last exception raised. The exception will be set when an error occurs. The authenticate / setPassword / changePassword methods will cause the boolean state of the objects to change. Other internal / unexpected errors will only populate the error message available via getErrMessage().
    Since:
    9.0.2.1
    • Field Detail

      • User_java_sourceCodeID

        public static final java.lang.String User_java_sourceCodeID
        See Also:
        Constant Field Values
      • User_java_copyright

        public static final java.lang.String User_java_copyright
    • Constructor Detail

      • User

        public User​(RgyUser user)
    • Method Detail

      • isAccountDisabled

        public boolean isAccountDisabled()
      • isAccountLocked

        public boolean isAccountLocked()
      • wasAccountJustLocked

        public boolean wasAccountJustLocked()
      • wasAccountJustDisabled

        public boolean wasAccountJustDisabled()
      • isCredentialsValid

        public boolean isCredentialsValid()
      • isAccountValid

        public boolean isAccountValid()
      • isPasswordValid

        public boolean isPasswordValid()
      • isValidTimeOfDayAccess

        public boolean isValidTimeOfDayAccess()
      • isPasswordExpiringSoon

        public boolean isPasswordExpiringSoon()
      • wasOldPasswordValid

        public boolean wasOldPasswordValid()
      • isPasswordCharsValid

        public boolean isPasswordCharsValid()
      • isPasswordContainsSpaces

        public boolean isPasswordContainsSpaces()
      • isPasswordContainsRepeatedChars

        public boolean isPasswordContainsRepeatedChars()
      • isPasswordTooShort

        public boolean isPasswordTooShort()
      • isPasswordMissingAlphaChars

        public boolean isPasswordMissingAlphaChars()
      • isPasswordMissingNonAlphaChars

        public boolean isPasswordMissingNonAlphaChars()
      • getErrMessage

        public java.lang.String getErrMessage()
        Get the error message of the last operation.
        Returns:
        String of the last caught exception. Null if not exception was caught.
      • clearError

        public void clearError()
        Remove the error state of this object
      • authenticate

        public boolean authenticate​(java.lang.String password)
        Attempts to authenticate a user. Will clear the error message of this user if successful.
        Parameters:
        password - users password to check
        Returns:
        true if the user was successfully authenticated.
      • changePassword

        public boolean changePassword​(java.lang.String oldPassword,
                                      java.lang.String newPassword)
        Attempt to change a password, requiring the old password Will clear the error message of this user if successful.
        Parameters:
        oldPassword - the users valid old password
        newPassword - the new password to use if the old password validates successfully.
        Returns:
        true if no exception was raised and the password was changed
      • setPassword

        public boolean setPassword​(java.lang.String newPassword)
        Will clear the error message of this user if successful. Attempt to change a password, without the old password. Will clear the error message of this user if successful.
        Parameters:
        newPassword - new password
        Returns:
        true if no exception was raised.
      • getNativeId

        public java.lang.String getNativeId()
        Get the users native ID.
        Returns:
        this users ldap DN
      • getId

        public java.lang.String getId()
        Get the users ID.
        Returns:
        this users username.
      • getGroups

        public java.lang.String[] getGroups()
        Get the groups of this user Will clear the error message of this user if successful.
        Returns:
        the groups, or empty array if not a member of any groups. null if an error occurs.
      • getNativeGroups

        public java.lang.String[] getNativeGroups()
        Get the natvie groups of this user Will clear the error message of this user if successful.
        Returns:
        the groups, or empty array if not a member of any groups. null if an error occurs.
      • attributeExists

        public boolean attributeExists​(java.lang.String attrName)
        check if a user has an attribute
        Parameters:
        attrName - name of the attribute to check for
        Returns:
        true if the user has the attribute, false if they do not.
      • getAttribute

        public java.lang.Object getAttribute​(java.lang.String attrName)
        Parameters:
        attrName -
        Returns:
      • getAttributes

        public java.lang.Object[] getAttributes​(java.lang.String attrName)
        Fetch a single attribute value. If this is a multivalued attribute, the value returned is undefined.
        Parameters:
        attrName - Name of the attribute to retrieve.
        Returns:
        the attribute value. Null if the attribute wasn't found.
      • getAttributeNames

        public java.lang.String[] getAttributeNames()
        Fetch all values for an attribute.
        Parameters:
        attrName - Name of the attributes to retrieve
        Returns:
        the attribute values. Null if the attribute wasn't found.
      • removeAttribute

        public boolean removeAttribute​(java.lang.String attrName)
        Remove an attribute from this user
        Parameters:
        attrName - name of the attribute to remove
        Returns:
        true if the attribute was removed. False if the attribute was not removed.
      • addAttribute

        public boolean addAttribute​(java.lang.String attrName,
                                    java.lang.Object value)
        Set an attribute to a single value. Will append values to an existing attribute
        Parameters:
        attrName - Name of the attribute to set.
        value - name of the value to set.
        Returns:
        true if the attribute was successfully set. False if it was not.
      • addAttribute

        public boolean addAttribute​(java.lang.String attrName,
                                    java.lang.Object[] values)
        Set an attribute to the given values. Will append values to an existing attribute
        Parameters:
        attrName - Name of the attribute to set.
        values - name of the values to set.
        Returns:
        true if the attribute was successfully set. False if it was not.
      • replaceAttribute

        public boolean replaceAttribute​(java.lang.String attrName,
                                        java.lang.Object value)
        Set an attribute to a single value. Will replace values of an existing attribute
        Parameters:
        attrName - Name of the attribute to set.
        value - name of the value to set.
        Returns:
        true if the attribute was successfully set. False if it was not.
      • replaceAttribute

        public boolean replaceAttribute​(java.lang.String attrName,
                                        java.lang.Object[] values)
        Set an attribute to the given values. Will replace values of anexisting attribute
        Parameters:
        attrName - Name of the attribute to set.
        values - name of the values to set.
        Returns:
        true if the attribute was successfully set. False if it was not.
      • addToGroup

        public boolean addToGroup​(java.lang.String groupName)
        Add a user to the given group. If an error occurs doing the look up of the group then the error message of the User will be set. If the group is not found then the message will not be set.
        Parameters:
        groupName - name of the group to add the user to
        Returns:
        true if the user was added to the group / false if the user was not added to the group.
      • removeFromGroup

        public boolean removeFromGroup​(java.lang.String groupName)
        Remove a user from the given group. If an error occurs doing the look up of the group then the error message of the User will be set. If the group is not found then the message will not be set.
        Parameters:
        groupName - name of the group to remove the user from.
        Returns:
        true if the user was removed from the group / false if the user was not removed from the group.