FileDocCategorySizeDatePackage
UserPrincipal.javaAPI DocJava SE 6 API2236Tue Jun 10 00:23:22 BST 2008com.sun.security.auth

UserPrincipal

public final class UserPrincipal extends Object implements Principal, Serializable
A user principal identified by a username or account name.

After successful authentication, a user {@link java.security.Principal} can be associated with a particular {@link javax.security.auth.Subject} to augment that Subject with an additional identity. Authorization decisions can then be based upon the Principals that are associated with a Subject.

This class is immutable.

since
1.6

Fields Summary
private static final long
serialVersionUID
private final String
name
The principal's name
Constructors Summary
public UserPrincipal(String name)
Creates a principal.

param
name The principal's string name.
exception
NullPointerException If the name is null.


                          
       
	if (name == null) {
	    throw new NullPointerException("null name is illegal");
	}
	this.name = name;
    
Methods Summary
public booleanequals(java.lang.Object object)
Compares this principal to the specified object.

param
object The object to compare this principal against.
return
true if they are equal; false otherwise.

	if (this == object) {
	    return true;
	}
	if (object instanceof UserPrincipal) {
	    return name.equals(((UserPrincipal)object).getName());
	}
	return false;
    
public java.lang.StringgetName()
Returns the name of this principal.

return
The principal's name.

	return name;
    
public inthashCode()
Returns a hash code for this principal.

return
The principal's hash code.

	return name.hashCode();
    
public java.lang.StringtoString()
Returns a string representation of this principal.

return
The principal's name.

	return name;