Added in API level 1

Principal

public interface Principal

java.security.Principal
Group This interface was deprecated in API level 33. This class is deprecated and subject to removal in a future version of Java SE. It has been replaced by java.security.Policy and related classes since 1.2. 
GroupPrincipal A UserPrincipal representing a group identity, used to determine access rights to objects in a file system. 
Identity This class was deprecated in API level 3. This class is deprecated and subject to removal in a future version of Java SE. It has been replaced by java.security.KeyStore, the java.security.cert package, and java.security.Principal. 
IdentityScope This class was deprecated in API level 3. This class is deprecated and subject to removal in a future version of Java SE. It has been replaced by java.security.KeyStore, the java.security.cert package, and java.security.Principal. 
Signer This class was deprecated in API level 3. This class is deprecated and subject to removal in a future version of Java SE. It has been replaced by java.security.KeyStore, the java.security.cert package, and java.security.Principal. 
UserPrincipal A Principal representing an identity used to determine access rights to objects in a file system. 
X500Principal

This class represents an X.500 Principal



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.

See also:

Summary

Public methods

abstract boolean equals(Object another)

Compares this principal to the specified object.

abstract String getName()

Returns the name of this principal.

abstract int hashCode()

Returns a hashcode for this principal.

default boolean implies(Subject subject)

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

abstract String toString()

Returns a string representation of this principal.

Public methods

equals

Added in API level 1
public abstract 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.

getName

Added in API level 1
public abstract String getName ()

Returns the name of this principal.

Returns
String the name of this principal.

hashCode

Added in API level 1
public abstract int hashCode ()

Returns a hashcode for this principal.

Returns
int a hashcode for this principal.

implies

Added in API level 26
public boolean implies (Subject subject)

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

Implementation Requirements:
  • 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.

toString

Added in API level 1
public abstract String toString ()

Returns a string representation of this principal.

Returns
String a string representation of this principal.