Class User

java.lang.Object
com.ibm.security.access.user.User

public class User extends Object
Class represents a user. The validity of the boolean response methods that check on the state of the user depend on the result of previous method calls that have raised an exception. The error condition will be set when an error occurs and an exception is caught. Do not attempt to use these methods in isolation and clear the current error condition/message when possible. The authenticate / setPassword / changePassword or other update 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 Details

  • Constructor Details

    • User

      public User(RgyUser user)
  • Method Details

    • isAccountDisabled

      public boolean isAccountDisabled()
      Check the current error condition to see if the users account is currently disabled. This method should only be used after calling one of the methods that set or clear the error condition on completion. See description of each method. Use this method to find the reason why the previous method call failed.
      Returns:
      boolean True if error condition has been set and the condition is that the users account has been disabled.
    • isAccountLocked

      public boolean isAccountLocked()
      Check the current error condition to see if the users account is currently locked. This method should only be used after calling one of the methods that set or clear the error condition on completion. See description of each method. Use this method to find the reason why the previous method call failed.
      Returns:
      boolean True if error condition has been set and the condition is that the users account has been locked.
    • wasAccountJustLocked

      public boolean wasAccountJustLocked()
      Check the current error condition to see if the users account was locked as a result of the previous call. This method should only be used after calling one of the methods that set or clear the error condition on completion. See description of each method. Use this method to find the reason why the previous method call failed.
      Returns:
      boolean True if error condition has been set and the condition is that the users account was locked as a result of the previous method call.
    • wasAccountJustDisabled

      public boolean wasAccountJustDisabled()
      Check the current error condition to see if the users account was dsiabled as a result of the previous call. This method should only be used after calling one of the methods that set or clear the error condition on completion. See description of each method. Use this method to find the reason why the previous method call failed.
      Returns:
      boolean True if error condition has been set and the condition is that the users account was disabled as a result of the previous method call.
    • isCredentialsValid

      public boolean isCredentialsValid()
      Check the current error condition to see if invalid credentials were provided. This method should only be used after calling one of the methods that set or clear the error condition on completion. See description of each method. Use this method to find the reason why the previous method call failed.
      Returns:
      boolean True if error condition has been set and the condition is that provided credentials were invalid.
    • isAccountValid

      public boolean isAccountValid()
      Check the current error condition to see if the users account is not valid. This method should only be used after calling one of the methods that set or clear the error condition on completion. See description of each method. Use this method to find the reason why the previous method call failed.
      Returns:
      boolean True if error condition has been set and the condition is that the users account is not valid.
    • isPasswordValid

      public boolean isPasswordValid()
      Check the current error condition to see if the users password is not valid. This method should only be used after calling one of the methods that set or clear the error condition on completion. See description of each method. Use this method to find the reason why the previous method call failed.
      Returns:
      boolean True if error condition has been set and the condition is that the users password is not valid.
    • isValidTimeOfDayAccess

      public boolean isValidTimeOfDayAccess()
      Check the current error condition to see if the time of day is not valid. This method should only be used after calling one of the methods that set or clear the error condition on completion. See description of each method. Use this method to find the reason why the previous method call failed.
      Returns:
      boolean True if error condition has been set and the condition is that the time of day is not valid.
    • isPasswordExpiringSoon

      public boolean isPasswordExpiringSoon()
      Check the current error condition to see if the users password is about to expire. This method should only be used after calling one of the methods that set or clear the error condition on completion. See description of each method.
      Returns:
      boolean True if error condition has been set and the condition is that the users password is about to expire.
    • wasOldPasswordValid

      public boolean wasOldPasswordValid()
      Check the current error condition to see if the users old password is not valid. This method should only be used after calling one of the methods that set or clear the error condition on completion. See description of each method. Use this method to find the reason why the previous method call failed.
      Returns:
      boolean True if error condition has been set and the condition is that the users old password is not valid.
    • isPasswordCharsValid

      public boolean isPasswordCharsValid()
      Check the current error condition to see if the users password contains invalid characters. This method should only be used after calling one of the methods that set or clear the error condition on completion. See description of each method. Use this method to find the reason why the previous method call failed.
      Returns:
      boolean True if error condition has been set and the condition is that the users password contains invalid characters.
    • isPasswordContainsSpaces

      public boolean isPasswordContainsSpaces()
      Check the current error condition to see if the users password contains spaces. This method should only be used after calling one of the methods that set or clear the error condition on completion. See description of each method. Use this method to find the reason why the previous method call failed.
      Returns:
      boolean True if error condition has been set and the condition is that the users password contains spaces.
    • isPasswordContainsRepeatedChars

      public boolean isPasswordContainsRepeatedChars()
      Check the current error condition to see if the users password contains repeated characters. This method should only be used after calling one of the methods that set or clear the error condition on completion. See description of each method. Use this method to find the reason why the previous method call failed.
      Returns:
      boolean True if error condition has been set and the condition is that the users password contains repeated characters.
    • isPasswordTooShort

      public boolean isPasswordTooShort()
      Check the current error condition to see if the users password is too short. This method should only be used after calling one of the methods that set or clear the error condition on completion. See description of each method. Use this method to find the reason why the previous method call failed.
      Returns:
      boolean True if error condition has been set and the condition is that the users password is too short.
    • isPasswordMissingAlphaChars

      public boolean isPasswordMissingAlphaChars()
      Check the current error condition to see if the users password is missing required alphanumeric characters. This method should only be used after calling one of the methods that set or clear the error condition on completion. See description of each method. Use this method to find the reason why the previous method call failed.
      Returns:
      boolean True if error condition has been set and the condition is that the users password is missing required alphanumeric characters.
    • isPasswordMissingNonAlphaChars

      public boolean isPasswordMissingNonAlphaChars()
      Check the current error condition to see if the users password is missing required non-alphanumeric characters. This method should only be used after calling one of the methods that set or clear the error condition on completion. See description of each method. Use this method to find the reason why the previous method call failed.
      Returns:
      boolean True if error condition has been set and the condition is that the users password is missing required non-alphanumeric characters.
    • getErrMessage

      public 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(String password)
      Attempts to authenticate a user. Will clear or set the error condition of this user depending on whether or not the call was successful.
      Parameters:
      password - users password to check
      Returns:
      true if the user was successfully authenticated.
    • changePassword

      public boolean changePassword(String oldPassword, String newPassword)
      Attempt to change a password, requiring the old password. Will clear or set the error condition of this user depending on whether or not the update was 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(String newPassword)
      Attempt to set a new password, without the old password. Will clear or set the error condition of this user depending on whether or not the update was successful.
      Parameters:
      newPassword - new password
      Returns:
      true if no exception was raised.
    • getNativeId

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

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

      public String[] getGroups()
      Get the groups of this user. Will clear or set the error condition of this user depending on whether or not the lookup was successful.
      Returns:
      the groups, or empty array if not a member of any groups. null if an error occurs.
    • getNativeGroups

      public String[] getNativeGroups()
      Get the natvie groups of this user. Will clear or set the error condition of this user depending on whether or not the lookup was successful.
      Returns:
      the groups, or empty array if not a member of any groups. null if an error occurs.
    • attributeExists

      public boolean attributeExists(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 Object getAttribute(String attrName)
      Fetch a single attribute value. If this is a multivalued attribute, the value returned is undefined. Will clear or set the error condition of this user depending on whether or not the lookup was successful.
      Parameters:
      attrName -
      Returns:
    • getAttributes

      public Object[] getAttributes(String attrName)
      Fetch all attribute values. Will clear or set the error condition of this user depending on whether or not the lookup was successful.
      Parameters:
      attrName - Name of the attribute to retrieve.
      Returns:
      the attribute value as an array. Null if the attribute wasn't found.
    • getAttributeNames

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

      public boolean removeAttribute(String attrName)
      Remove an attribute from this user. Will clear or set the error condition of this user depending on whether or not the update was successful.
      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(String attrName, Object value)
      Set an attribute to a single value. Will append values to an existing attribute. Will clear or set the error condition of this user depending on whether or not the update was successful.
      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(String attrName, Object[] values)
      Set an attribute to the given values. Will append values to an existing attribute. Will clear or set the error condition of this user depending on whether or not the update was successful.
      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(String attrName, Object value)
      Set an attribute to a single value. Will replace values of an existing attribute. Will clear or set the error condition of this user depending on whether or not the update was successful.
      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(String attrName, Object[] values)
      Set an attribute to the given values. Will replace values of an existing attribute. Will clear or set the error condition of this user depending on whether or not the update was successful.
      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(String groupName)
      Add a user to the given group. If an error occurs doing the look up of the group then the error condition of the User will be set. If the group is not found then the error condition 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.
    • addToGroupWithDomain

      public boolean addToGroupWithDomain(String groupName, String domainName)
      Add a user to the given group, with domain If an error occurs doing the look up of the group then the error condition of the User will be set. If the group is not found then the error condition will not be set.
      Parameters:
      groupName - name of the group to add the user to
      domainName - name of the domain the group is in
      Returns:
      true if the user was added to the group / false if the user was not added to the group.
    • removeFromGroup

      public boolean removeFromGroup(String groupName)
      Remove a user from the given group. If an error occurs doing the look up of the group then the error condition of the User will be set. If the group is not found then the error condition 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.
    • removeFromGroupWithDomain

      public boolean removeFromGroupWithDomain(String groupName, String domainName)
      Remove a user from the given group with domain. If an error occurs doing the look up of the group then the error condition of the User will be set. If the group is not found then the error condition will not be set.
      Parameters:
      groupName - name of the group to remove the user from.
      domainName - name of the domain the group is in
      Returns:
      true if the user was removed from the group / false if the user was not removed from the group.