Added in [API level 1](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels) Summary: [Methods](https://developer.android.com/reference/java/security/Principal#pubmethods)

# Principal

` public interface Principal `   
` `

|---|
| java.security.Principal |

Known indirect subclasses [Group](https://developer.android.com/reference/java/security/acl/Group), [GroupPrincipal](https://developer.android.com/reference/java/nio/file/attribute/GroupPrincipal), [Identity](https://developer.android.com/reference/java/security/Identity), [IdentityScope](https://developer.android.com/reference/java/security/IdentityScope), [Signer](https://developer.android.com/reference/java/security/Signer), [UserPrincipal](https://developer.android.com/reference/java/nio/file/attribute/UserPrincipal), [X500Principal](https://developer.android.com/reference/javax/security/auth/x500/X500Principal) [Group](https://developer.android.com/reference/java/security/acl/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](https://developer.android.com/reference/java/nio/file/attribute/GroupPrincipal) A `UserPrincipal` representing a *group identity*, used to determine access rights to objects in a file system. [Identity](https://developer.android.com/reference/java/security/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](https://developer.android.com/reference/java/security/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](https://developer.android.com/reference/java/security/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](https://developer.android.com/reference/java/nio/file/attribute/UserPrincipal) A `Principal` representing an identity used to determine access rights to objects in a file system. [X500Principal](https://developer.android.com/reference/javax/security/auth/x500/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:**

- `https://developer.android.com/reference/java/security/cert/X509Certificate`

## Summary

| ### Public methods ||
|---|---|
| ` abstract boolean` | ` https://developer.android.com/reference/java/security/Principal#equals(java.lang.Object)(https://developer.android.com/reference/java/lang/Object another) ` Compares this principal to the specified object. |
| ` abstract https://developer.android.com/reference/java/lang/String` | ` https://developer.android.com/reference/java/security/Principal#getName()() ` Returns the name of this principal. |
| ` abstract int` | ` https://developer.android.com/reference/java/security/Principal#hashCode()() ` Returns a hashcode for this principal. |
| ` default boolean` | ` https://developer.android.com/reference/java/security/Principal#implies(javax.security.auth.Subject)(https://developer.android.com/reference/javax/security/auth/Subject subject) ` Returns true if the specified subject is implied by this principal. |
| ` abstract https://developer.android.com/reference/java/lang/String` | ` https://developer.android.com/reference/java/security/Principal#toString()() ` Returns a string representation of this principal. |

## Public methods

### equals

Added in [API level 1](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
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.

<br />

| Parameters ||
|---|---|
| `another` | `Object`: principal to compare with. <br /> |

| Returns ||
|---|---|
| `boolean` | true if the principal passed in is the same as that encapsulated by this principal, and false otherwise. <br /> |

### getName

Added in [API level 1](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public abstract String getName ()
```

Returns the name of this principal.

<br />

| Returns ||
|---|---|
| `https://developer.android.com/reference/java/lang/String` | the name of this principal. <br /> |

### hashCode

Added in [API level 1](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public abstract int hashCode ()
```

Returns a hashcode for this principal.

<br />

| Returns ||
|---|---|
| `int` | a hashcode for this principal. <br /> |

### implies

Added in [API level 26](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public boolean implies (Subject subject)
```

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

<br />

##### 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` <br /> |

| Returns ||
|---|---|
| `boolean` | true if `subject` is non-null and is implied by this principal, or false otherwise. <br /> |

### toString

Added in [API level 1](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public abstract String toString ()
```

Returns a string representation of this principal.

<br />

| Returns ||
|---|---|
| `https://developer.android.com/reference/java/lang/String` | a string representation of this principal. <br /> |