Added in [API level 1](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)   
Deprecated in [API level
3](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels) Summary: [Ctors](https://developer.android.com/reference/java/security/IdentityScope#pubctors) \| [Protected Ctors](https://developer.android.com/reference/java/security/IdentityScope#proctors) \| [Methods](https://developer.android.com/reference/java/security/IdentityScope#pubmethods) \| [Protected Methods](https://developer.android.com/reference/java/security/IdentityScope#promethods) \| [Inherited Methods](https://developer.android.com/reference/java/security/IdentityScope#inhmethods)

# IdentityScope


`
public


abstract
class
IdentityScope
`


`


`

`

extends https://developer.android.com/reference/java/security/Identity


`

`


`

|---|---|---|
| [java.lang.Object](https://developer.android.com/reference/java/lang/Object) |||
| ↳ | [java.security.Identity](https://developer.android.com/reference/java/security/Identity) ||
|   | ↳ | java.security.IdentityScope |

<br />

*** ** * ** ***


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

<br />

This class represents a scope for identities. It is an Identity
itself, and therefore has a name and can have a scope. It can also
optionally have a public key and associated certificates.

An IdentityScope can contain Identity objects of all kinds, including
Signers. All types of Identity objects can be retrieved, added, and
removed using the same methods. Note that it is possible, and in fact
expected, that different types of identity scopes will
apply different policies for their various operations on the
various types of Identities.

There is a one-to-one mapping between keys and identities, and
there can only be one copy of one key per scope. For example, suppose
**Acme Software, Inc** is a software publisher known to a user.
Suppose it is an Identity, that is, it has a public key, and a set of
associated certificates. It is named in the scope using the name
"Acme Software". No other named Identity in the scope has the same
public key. Of course, none has the same name as well.
**See also:**

- `https://developer.android.com/reference/java/security/Identity`
- `https://developer.android.com/reference/java/security/Signer`
- `https://developer.android.com/reference/java/security/Principal`
- `https://developer.android.com/reference/java/security/Key`

## Summary

| ### Public constructors ||
|---|---|
| ` https://developer.android.com/reference/java/security/IdentityScope#IdentityScope(java.lang.String)(https://developer.android.com/reference/java/lang/String name) ` Constructs a new identity scope with the specified name. |
| ` https://developer.android.com/reference/java/security/IdentityScope#IdentityScope(java.lang.String,%20java.security.IdentityScope)(https://developer.android.com/reference/java/lang/String name, https://developer.android.com/reference/java/security/IdentityScope scope) ` Constructs a new identity scope with the specified name and scope. |

| ### Protected constructors ||
|---|---|
| ` https://developer.android.com/reference/java/security/IdentityScope#IdentityScope()() ` This constructor is used for serialization only and should not be used by subclasses. |

| ### Public methods ||
|---|---|
| ` abstract void` | ` https://developer.android.com/reference/java/security/IdentityScope#addIdentity(java.security.Identity)(https://developer.android.com/reference/java/security/Identity identity) ` Adds an identity to this identity scope. |
| ` abstract https://developer.android.com/reference/java/security/Identity` | ` https://developer.android.com/reference/java/security/IdentityScope#getIdentity(java.lang.String)(https://developer.android.com/reference/java/lang/String name) ` Returns the identity in this scope with the specified name (if any). |
| ` abstract https://developer.android.com/reference/java/security/Identity` | ` https://developer.android.com/reference/java/security/IdentityScope#getIdentity(java.security.PublicKey)(https://developer.android.com/reference/java/security/PublicKey key) ` Retrieves the identity with the specified public key. |
| ` https://developer.android.com/reference/java/security/Identity` | ` https://developer.android.com/reference/java/security/IdentityScope#getIdentity(java.security.Principal)(https://developer.android.com/reference/java/security/Principal principal) ` Retrieves the identity whose name is the same as that of the specified principal. |
| ` static https://developer.android.com/reference/java/security/IdentityScope` | ` https://developer.android.com/reference/java/security/IdentityScope#getSystemScope()() ` Returns the system's identity scope. |
| ` abstract https://developer.android.com/reference/java/util/Enumeration<https://developer.android.com/reference/java/security/Identity>` | ` https://developer.android.com/reference/java/security/IdentityScope#identities()() ` Returns an enumeration of all identities in this identity scope. |
| ` abstract void` | ` https://developer.android.com/reference/java/security/IdentityScope#removeIdentity(java.security.Identity)(https://developer.android.com/reference/java/security/Identity identity) ` Removes an identity from this identity scope. |
| ` abstract int` | ` https://developer.android.com/reference/java/security/IdentityScope#size()() ` Returns the number of identities within this identity scope. |
| ` https://developer.android.com/reference/java/lang/String` | ` https://developer.android.com/reference/java/security/IdentityScope#toString()() ` Returns a string representation of this identity scope, including its name, its scope name, and the number of identities in this identity scope. |

| ### Protected methods ||
|---|---|
| ` static void` | ` https://developer.android.com/reference/java/security/IdentityScope#setSystemScope(java.security.IdentityScope)(https://developer.android.com/reference/java/security/IdentityScope scope) ` Sets the system's identity scope. |

| ### Inherited methods |
|---|---|
| From class ` https://developer.android.com/reference/java/security/Identity ` |---|---| | ` void` | ` https://developer.android.com/reference/java/security/Identity#addCertificate(java.security.Certificate)(https://developer.android.com/reference/java/security/Certificate certificate) ` Adds a certificate for this identity. | | ` https://developer.android.com/reference/java/security/Certificate` | ` https://developer.android.com/reference/java/security/Identity#certificates()() ` Returns a copy of all the certificates for this identity. | | ` final boolean` | ` https://developer.android.com/reference/java/security/Identity#equals(java.lang.Object)(https://developer.android.com/reference/java/lang/Object identity) ` Tests for equality between the specified object and this identity. | | ` https://developer.android.com/reference/java/lang/String` | ` https://developer.android.com/reference/java/security/Identity#getInfo()() ` Returns general information previously specified for this identity. | | ` final https://developer.android.com/reference/java/lang/String` | ` https://developer.android.com/reference/java/security/Identity#getName()() ` Returns this identity's name. | | ` https://developer.android.com/reference/java/security/PublicKey` | ` https://developer.android.com/reference/java/security/Identity#getPublicKey()() ` Returns this identity's public key. | | ` final https://developer.android.com/reference/java/security/IdentityScope` | ` https://developer.android.com/reference/java/security/Identity#getScope()() ` Returns this identity's scope. | | ` int` | ` https://developer.android.com/reference/java/security/Identity#hashCode()() ` Returns a hashcode for this identity. | | ` boolean` | ` https://developer.android.com/reference/java/security/Identity#identityEquals(java.security.Identity)(https://developer.android.com/reference/java/security/Identity identity) ` Tests for equality between the specified identity and this identity. | | ` void` | ` https://developer.android.com/reference/java/security/Identity#removeCertificate(java.security.Certificate)(https://developer.android.com/reference/java/security/Certificate certificate) ` Removes a certificate from this identity. | | ` void` | ` https://developer.android.com/reference/java/security/Identity#setInfo(java.lang.String)(https://developer.android.com/reference/java/lang/String info) ` Specifies a general information string for this identity. | | ` void` | ` https://developer.android.com/reference/java/security/Identity#setPublicKey(java.security.PublicKey)(https://developer.android.com/reference/java/security/PublicKey key) ` Sets this identity's public key. | | ` https://developer.android.com/reference/java/lang/String` | ` https://developer.android.com/reference/java/security/Identity#toString()() ` Returns a short string describing this identity, telling its name and its scope (if any). | | ` https://developer.android.com/reference/java/lang/String` | ` https://developer.android.com/reference/java/security/Identity#toString(boolean)(boolean detailed) ` Returns a string representation of this identity, with optionally more details than that provided by the `toString` method without any arguments. | ||
| From class ` https://developer.android.com/reference/java/lang/Object ` |---|---| | ` https://developer.android.com/reference/java/lang/Object` | ` https://developer.android.com/reference/java/lang/Object#clone()() ` Creates and returns a copy of this object. | | ` boolean` | ` https://developer.android.com/reference/java/lang/Object#equals(java.lang.Object)(https://developer.android.com/reference/java/lang/Object obj) ` Indicates whether some other object is "equal to" this one. | | ` void` | ` https://developer.android.com/reference/java/lang/Object#finalize()() ` Called by the garbage collector on an object when garbage collection determines that there are no more references to the object. | | ` final https://developer.android.com/reference/java/lang/Class<?>` | ` https://developer.android.com/reference/java/lang/Object#getClass()() ` Returns the runtime class of this `Object`. | | ` int` | ` https://developer.android.com/reference/java/lang/Object#hashCode()() ` Returns a hash code value for the object. | | ` final void` | ` https://developer.android.com/reference/java/lang/Object#notify()() ` Wakes up a single thread that is waiting on this object's monitor. | | ` final void` | ` https://developer.android.com/reference/java/lang/Object#notifyAll()() ` Wakes up all threads that are waiting on this object's monitor. | | ` https://developer.android.com/reference/java/lang/String` | ` https://developer.android.com/reference/java/lang/Object#toString()() ` Returns a string representation of the object. | | ` final void` | ` https://developer.android.com/reference/java/lang/Object#wait(long,%20int)(long timeoutMillis, int nanos) ` Causes the current thread to wait until it is awakened, typically by being *notified* or *interrupted*, or until a certain amount of real time has elapsed. | | ` final void` | ` https://developer.android.com/reference/java/lang/Object#wait(long)(long timeoutMillis) ` Causes the current thread to wait until it is awakened, typically by being *notified* or *interrupted*, or until a certain amount of real time has elapsed. | | ` final void` | ` https://developer.android.com/reference/java/lang/Object#wait()() ` Causes the current thread to wait until it is awakened, typically by being *notified* or *interrupted*. | ||
| From interface ` https://developer.android.com/reference/java/security/Principal ` |---|---| | ` 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 constructors

### IdentityScope

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

```
public IdentityScope (String name)
```

Constructs a new identity scope with the specified name.

<br />

| Parameters ||
|---|---|
| `name` | `String`: the scope name. <br /> |

### IdentityScope

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

```
public IdentityScope (String name, 
                IdentityScope scope)
```

Constructs a new identity scope with the specified name and scope.

<br />

| Parameters ||
|---|---|
| `name` | `String`: the scope name. <br /> |
| `scope` | `IdentityScope`: the scope for the new identity scope. <br /> |

| Throws ||
|---|---|
| `https://developer.android.com/reference/java/security/KeyManagementException` | if there is already an identity with the same name in the scope. |

## Protected constructors

### IdentityScope

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

```
protected IdentityScope ()
```

This constructor is used for serialization only and should not
be used by subclasses.

<br />

## Public methods

### addIdentity

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

```
public abstract void addIdentity (Identity identity)
```

Adds an identity to this identity scope.

<br />

| Parameters ||
|---|---|
| `identity` | `Identity`: the identity to be added. <br /> |

| Throws ||
|---|---|
| `https://developer.android.com/reference/java/security/KeyManagementException` | if the identity is not valid, a name conflict occurs, another identity has the same public key as the identity being added, or another exception occurs. |

### getIdentity

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

```
public abstract Identity getIdentity (String name)
```

Returns the identity in this scope with the specified name (if any).

<br />

| Parameters ||
|---|---|
| `name` | `String`: the name of the identity to be retrieved. <br /> |

| Returns ||
|---|---|
| `https://developer.android.com/reference/java/security/Identity` | the identity named `name`, or null if there are no identities named `name` in this scope. <br /> |

### getIdentity

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

```
public abstract Identity getIdentity (PublicKey key)
```

Retrieves the identity with the specified public key.

<br />

| Parameters ||
|---|---|
| `key` | `PublicKey`: the public key for the identity to be returned. <br /> |

| Returns ||
|---|---|
| `https://developer.android.com/reference/java/security/Identity` | the identity with the given key, or null if there are no identities in this scope with that key. <br /> |

### getIdentity

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

```
public Identity getIdentity (Principal principal)
```

Retrieves the identity whose name is the same as that of the
specified principal. (Note: Identity implements Principal.)

<br />

| Parameters ||
|---|---|
| `principal` | `Principal`: the principal corresponding to the identity to be retrieved. <br /> |

| Returns ||
|---|---|
| `https://developer.android.com/reference/java/security/Identity` | the identity whose name is the same as that of the principal, or null if there are no identities of the same name in this scope. <br /> |

### getSystemScope

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

```
public static IdentityScope getSystemScope ()
```

Returns the system's identity scope.

<br />

| Returns ||
|---|---|
| `https://developer.android.com/reference/java/security/IdentityScope` | the system's identity scope, or `null` if none has been set. <br /> |

**See also:**

- `https://developer.android.com/reference/java/security/IdentityScope#setSystemScope(java.security.IdentityScope)`

### identities

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

```
public abstract Enumeration<Identity> identities ()
```

Returns an enumeration of all identities in this identity scope.

<br />

| Returns ||
|---|---|
| `https://developer.android.com/reference/java/util/Enumeration<https://developer.android.com/reference/java/security/Identity>` | an enumeration of all identities in this identity scope. <br /> |

### removeIdentity

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

```
public abstract void removeIdentity (Identity identity)
```

Removes an identity from this identity scope.

<br />

| Parameters ||
|---|---|
| `identity` | `Identity`: the identity to be removed. <br /> |

| Throws ||
|---|---|
| `https://developer.android.com/reference/java/security/KeyManagementException` | if the identity is missing, or another exception occurs. |

### size

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

```
public abstract int size ()
```

Returns the number of identities within this identity scope.

<br />

| Returns ||
|---|---|
| `int` | the number of identities within this identity scope. <br /> |

### toString

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

```
public String toString ()
```

Returns a string representation of this identity scope, including
its name, its scope name, and the number of identities in this
identity scope.

<br />

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

## Protected methods

### setSystemScope

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

```
protected static void setSystemScope (IdentityScope scope)
```

Sets the system's identity scope.

First, if there is a security manager, its
`checkSecurityAccess`
method is called with `"setSystemScope"`
as its argument to see if it's ok to set the identity scope.

<br />

| Parameters ||
|---|---|
| `scope` | `IdentityScope`: the scope to set. <br /> |

| Throws ||
|---|---|
| `https://developer.android.com/reference/java/lang/SecurityException` | if a security manager exists and its `checkSecurityAccess` method doesn't allow setting the identity scope. |

**See also:**

- `https://developer.android.com/reference/java/security/IdentityScope#getSystemScope()`
- `https://developer.android.com/reference/java/lang/SecurityManager#checkSecurityAccess(java.lang.String)`