APIdia Launch Partner
Top Description Fields Constructors Methods
com.sun.security.auth

public final Class UserPrincipal

extends Object
implements Principal, Serializable
Class Inheritance
All Implemented Interfaces
java.io.Serializable, java.security.Principal
Imports
java.io.IOException, .InvalidObjectException, .ObjectInputStream, java.security.Principal

A user principal identified by a username or account name.

After successful authentication, a user java.security.Principal can be associated with a particular 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

Field Summary

Modifier and TypeField and Description
private final String
name

The principal's name

private static final long

Constructor Summary

AccessConstructor and Description
public
UserPrincipal(String
The principal's string name.
name
)

Creates a principal.

Method Summary

Modifier and TypeMethod and Description
public boolean

Returns:

true if they are equal; false otherwise.
equals
(Object
The object to compare this principal against.
object
)

Overrides java.lang.Object.equals.

Implements java.security.Principal.equals.

Compares this principal to the specified object.

public String

Returns:

The principal's name.
getName
()

Implements java.security.Principal.getName.

Returns the name of this principal.

public int

Returns:

The principal's hash code.
hashCode
()

Overrides java.lang.Object.hashCode.

Implements java.security.Principal.hashCode.

Returns a hash code for this principal.

private void
readObject(ObjectInputStream
the ObjectInputStream from which data is read
stream
)

Restores the state of this object from the stream.

public String

Returns:

The principal's name.
toString
()

Overrides java.lang.Object.toString.

Implements java.security.Principal.toString.

Returns a string representation of this principal.

Inherited from java.lang.Object:
clonefinalizegetClassnotifynotifyAllwaitwaitwait

Field Detail

nameback to summary
private final String name

The principal's name

serialVersionUIDback to summary
private static final long serialVersionUID
Annotations
@Serial

Constructor Detail

UserPrincipalback to summary
public UserPrincipal(String name)

Creates a principal.

Parameters
name:String

The principal's string name.

Exceptions
NullPointerException:
If the name is null.

Method Detail

equalsback to summary
public boolean equals(Object object)

Overrides java.lang.Object.equals.

Implements java.security.Principal.equals.

Compares this principal to the specified object.

Parameters
object:Object

The object to compare this principal against.

Returns:boolean

true if they are equal; false otherwise.

getNameback to summary
public String getName()

Implements java.security.Principal.getName.

Returns the name of this principal.

Returns:String

The principal's name.

hashCodeback to summary
public int hashCode()

Overrides java.lang.Object.hashCode.

Implements java.security.Principal.hashCode.

Returns a hash code for this principal.

Returns:int

The principal's hash code.

readObjectback to summary
private void readObject(ObjectInputStream stream) throws IOException, ClassNotFoundException

Restores the state of this object from the stream.

Parameters
stream:ObjectInputStream

the ObjectInputStream from which data is read

Annotations
@Serial
Exceptions
IOException:
if an I/O error occurs
ClassNotFoundException:
if a serialized class cannot be loaded
toStringback to summary
public String toString()

Overrides java.lang.Object.toString.

Implements java.security.Principal.toString.

Returns a string representation of this principal.

Returns:String

The principal's name.