All Implemented Interfaces:
Serializable , Principal
A user principal identified by a username or account name.
After successful authentication, a user Principal
can be associated with a particular 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
See Also:
Constructor Summary
Constructors
Method Summary
All Methods Instance Methods Concrete Methods
boolean
Compares this principal to the specified object.
Returns the name of this principal.
int
Returns a hash code for this principal.
Returns a string representation of this principal.
Constructor Details
UserPrincipal
public UserPrincipal (String name)
Creates a principal.
Parameters:
name - The principal's string name.
Throws:
NullPointerException - If the name is
null.
Method Details
equals
public boolean equals (Object object)
Compares this principal to the specified object.
Specified by:
equals in interface Principal
Overrides:
equals in class Object
Parameters:
object - The object to compare this principal against.
Returns:
true if they are equal; false otherwise.
See Also:
hashCode
public int hashCode ()
Returns a hash code for this principal.
Specified by:
hashCode in interface Principal
Overrides:
hashCode in class Object
Returns:
The principal's hash code.
See Also:
getName
Returns the name of this principal.
Specified by:
getName in interface Principal
Returns:
The principal's name.
toString
Returns a string representation of this principal.
Specified by:
toString in interface Principal
Overrides:
toString in class Object
Returns:
The principal's name.
Report a bug or suggest an enhancement For further API reference and developer documentation see the Java SE Documentation , which contains more detailed, developer-targeted descriptions with conceptual overviews, definitions of terms, workarounds, and working code examples. Other versions. Java is a trademark or registered trademark of Oracle and/or its affiliates in the US and other countries. Copyright © 1993, 2025, Oracle and/or its affiliates, 500 Oracle Parkway, Redwood Shores, CA 94065 USA. All rights reserved. Use is subject to license terms and the documentation redistribution policy . DRAFT 17.0.16-internal+0-adhoc..BuildJDK17x86-64linuxPersonal