Class UserIdentifier

  • Direct Known Subclasses:
    SessionUserIdentifier

    public class UserIdentifier
    extends java.lang.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 Summary

      Constructors 
      ConstructorDescription
      UserIdentifier​(java.lang.String userID, java.lang.String password)
      Constructor.
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and TypeMethodDescription
      SessionUserIdentifiercreateSessionUserIdentifier​(java.lang.String sessionID)
      Creates a SessionUserIdentifier from this instance.
      booleanequals​(java.lang.Object o)
      Checks if another UserIdentifier equals this one.
      javax.security.auth.login.LoginContextgetLoginContext​(java.lang.String name, java.util.ArrayList<javax.security.auth.callback.TextOutputCallback> output)
      Gets the login context for the user.
      java.lang.StringgetPassword()
      Gets the password specified in the user session.
      java.lang.StringgetUserID()
      Gets the User ID.
      inthashCode()
      Hash code, unique for each user identifier.
      protected java.lang.StringparamString()
      Formats the value as a string to add to paramString.
      java.lang.StringtoString()
      Returns a string representation of this user identifier and its values.
      voidupdatePassword​(java.lang.String password)
      Updates the password for the user.
      • Methods inherited from class java.lang.Object

        clone, finalize, getClass, notify, notifyAll, wait, wait, wait
    • Constructor Detail

      • UserIdentifier

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

      • createSessionUserIdentifier

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

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

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

        public java.lang.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​(java.lang.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 java.lang.Object
        Parameters:
        o - An Object.
        Returns:
        Equals flag.
      • hashCode

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

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

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

        public javax.security.auth.login.LoginContext getLoginContext​(java.lang.String name,
                                                                      java.util.ArrayList<javax.security.auth.callback.TextOutputCallback> output)
                                                               throws javax.security.auth.login.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:
        javax.security.auth.login.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.
        java.lang.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").