Class UserIdentifier

java.lang.Object
com.iizix.user.UserIdentifier
Direct Known Subclasses:
SessionUserIdentifier

public class UserIdentifier extends Object
The User identifier class holds the information about a user or a returning user. The User may, if the application allows it, run several individual session or the same virtual session in parallel. This is configurable, and allows the same user to run different independent sessions by assigning a session ID. In this case, the class SessionUserIdentifier is used.
Author:
Christopher Mindus
  • Constructor Details

    • UserIdentifier

      public UserIdentifier(String userID, String password)
      Constructor.
      Parameters:
      userID - User ID, non-empty, not null.
      password - The password, non-empty, not null.
      Throws:
      NullPointerException - If any parameter is null.
      IllegalArgumentException - If any parameter is empty.
  • Method Details

    • createSessionUserIdentifier

      public SessionUserIdentifier createSessionUserIdentifier(String sessionID)
      Creates a SessionUserIdentifier from this instance.
      Parameters:
      sessionID - The session ID, non-empty, not null.
      Throws:
      NullPointerException - If any parameter is null.
      IllegalArgumentException - If any parameter is empty.
    • getUserID

      public final String getUserID()
      Gets the User ID.
    • updatePassword

      public void updatePassword(String password)
      Updates the password for the user.
      Parameters:
      password - The updated password.
      Throws:
      NullPointerException - If password is null.
      IllegalArgumentException - If any parameter is empty.
    • getPassword

      public String getPassword()
      Gets the password specified in the user session. Once retrieved by the authentication system, the password is cleared and no longer available.
      Returns:
      The password, null if already retrieved.
    • equals

      public boolean equals(Object o)
      Checks if another UserIdentifier equals this one.

      Comparison includes the Session ID.

      Password is excluded in the verification as it is not available once checked.

      Overrides:
      equals in class Object
      Parameters:
      o - An Object.
      Returns:
      Equals flag.
    • hashCode

      public final int hashCode()
      Hash code, unique for each user identifier.
      Overrides:
      hashCode in class Object
    • paramString

      protected String paramString()
      Formats the value as a string to add to paramString.
    • toString

      public String toString()
      Returns a string representation of this user identifier and its values.
      Overrides:
      toString in class Object
      Returns:
      a string representation.
    • getLoginContext

      public LoginContext getLoginContext(String name, ArrayList<TextOutputCallback> output) throws LoginException
      Gets the login context for the user.
      Parameters:
      name - The name of the configuration entry.
      output - The array that is filled with output texts during login.
      Returns:
      The login context.
      Throws:
      LoginException - if the caller-specified name does not appear in the Configuration and there is no Configuration entry for "other", or if the caller-specified callbackHandler is null.
      SecurityException - if a SecurityManager is set and the caller does not have AuthPermission("createLoginContext.name"), or if a configuration entry for name does not exist and the caller does not additionally have AuthPermission("createLoginContext.other").