Package com.iizix.user
Class UserIdentifier
- java.lang.Object
- com.iizix.user.UserIdentifier
- Direct Known Subclasses:
SessionUserIdentifier
public class UserIdentifier extends java.lang.ObjectThe 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 classSessionUserIdentifieris used.- Author:
- Christopher Mindus
Constructor Summary
Constructors Constructor Description UserIdentifier(java.lang.String userID, java.lang.String password)Constructor.
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description 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 toparamString.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.
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:
equalsin classjava.lang.Object- Parameters:
o- An Object.- Returns:
- Equals flag.
hashCode
public final int hashCode()
Hash code, unique for each user identifier.- Overrides:
hashCodein classjava.lang.Object
paramString
protected java.lang.String paramString()
Formats the value as a string to add toparamString.
toString
public java.lang.String toString()
Returns a string representation of this user identifier and its values.- Overrides:
toStringin classjava.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.LoginExceptionGets 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-specifiednamedoes not appear in theConfigurationand there is noConfigurationentry for "other", or if the caller-specifiedcallbackHandlerisnull.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").