Top Description Methods
java.security

public Interface Principal

Known Direct Subinterfaces
java.nio.file.attribute.UserPrincipal
Known Direct Implementers
javax.security.auth.x500.X500Principal, sun.security.provider.PolicyParser.PrincipalEntry, sun.security.x509.X500Name, java.security.Identity
Imports
javax.security.auth.Subject

This interface represents the abstract notion of a Principal, which can be used to represent any entity, such as an individual, a corporation, and a login id.
Author
Li Gong
Since
1.1
See Also
java.security.cert.X509Certificate

Method Summary

Modifier and TypeMethod and Description
public boolean

Returns:

true if the Principal passed in is the same as that encapsulated by this Principal, and false otherwise.
equals
(Object
Principal to compare with.
another
)

Compares this Principal to the specified object.

public String

Returns:

the name of this Principal.
getName
()

Returns the name of this Principal.

public int

Returns:

a hashcode for this Principal
hashCode
()

Returns a hashcode for this Principal.

public default boolean

Returns:

true if subject is non-null and is implied by this Principal, or false otherwise.
implies
(Subject
the Subject
subject
)

Returns true if the specified subject is implied by this Principal.

public String

Returns:

a string representation of this Principal.
toString
()

Returns a string representation of this Principal.

Method Detail

equalsback to summary
public boolean equals(Object another)

Compares this Principal to the specified object. Returns true if the object passed in matches the Principal represented by the implementation of this interface.

Parameters
another:Object

Principal to compare with.

Returns:boolean

true if the Principal passed in is the same as that encapsulated by this Principal, and false otherwise.

Annotations
@Override
getNameback to summary
public String getName()

Returns the name of this Principal.

Returns:String

the name of this Principal.

hashCodeback to summary
public int hashCode()

Returns a hashcode for this Principal.

Returns:int

a hashcode for this Principal

Annotations
@Override
impliesback to summary
public default boolean implies(Subject subject)

Returns true if the specified subject is implied by this Principal.

Implementation Specification

The default implementation of this method returns true if subject is non-null and contains at least one Principal that is equal to this Principal.

Subclasses may override this with a different implementation, if necessary.

Parameters
subject:Subject

the Subject

Returns:boolean

true if subject is non-null and is implied by this Principal, or false otherwise.

Since
1.8
toStringback to summary
public String toString()

Returns a string representation of this Principal.

Returns:String

a string representation of this Principal.