# Signer

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/Signer#pubctors)\|[Protected Ctors](https://developer.android.com/reference/java/security/Signer#proctors)\|[Methods](https://developer.android.com/reference/java/security/Signer#pubmethods)\|[Inherited Methods](https://developer.android.com/reference/java/security/Signer#inhmethods)  

# Signer

`
public


abstract
class
Signer
`  
`


``

extends `[Identity](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.Signer |

<br />

*** ** * ** ***

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

This class is used to represent an Identity that can also digitally sign data.

The management of a signer's private keys is an important and sensitive issue that should be handled by subclasses as appropriate to their intended use.  
**See also:**

- [Identity](https://developer.android.com/reference/java/security/Identity)

## Summary

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

|                                          ### Protected constructors                                          ||
|-----------------------------------------------------------------------------------------------------------|---|
| ` `[Signer](https://developer.android.com/reference/java/security/Signer#Signer())`() ` Creates a signer. |

|                                                                                                                                                                   ### Public methods                                                                                                                                                                   ||
|-----------------------------------------------------------------------------------|---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| ` `[PrivateKey](https://developer.android.com/reference/java/security/PrivateKey) | ` `[getPrivateKey](https://developer.android.com/reference/java/security/Signer#getPrivateKey())`() ` Returns this signer's private key.                                                                                                                            |
| ` final void`                                                                     | ` `[setKeyPair](https://developer.android.com/reference/java/security/Signer#setKeyPair(java.security.KeyPair))`(`[KeyPair](https://developer.android.com/reference/java/security/KeyPair)` pair) ` Sets the key pair (public key and private key) for this signer. |
| ` `[String](https://developer.android.com/reference/java/lang/String)             | ` `[toString](https://developer.android.com/reference/java/security/Signer#toString())`() ` Returns a string of information about the signer.                                                                                                                       |

| ### Inherited methods |
|-----------------------|---|
| From class` `[java.security.Identity](https://developer.android.com/reference/java/security/Identity)` ` |-----------------------------------------------------------------------------------------------|-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------| | ` void`                                                                                       | ` `[addCertificate](https://developer.android.com/reference/java/security/Identity#addCertificate(java.security.Certificate))`(`[Certificate](https://developer.android.com/reference/java/security/Certificate)` certificate) ` Adds a certificate for this identity.                    | | ` `[Certificate[]](https://developer.android.com/reference/java/security/Certificate)         | ` `[certificates](https://developer.android.com/reference/java/security/Identity#certificates())`() ` Returns a copy of all the certificates for this identity.                                                                                                                           | | ` final boolean`                                                                              | ` `[equals](https://developer.android.com/reference/java/security/Identity#equals(java.lang.Object))`(`[Object](https://developer.android.com/reference/java/lang/Object)` identity) ` Tests for equality between the specified object and this identity.                                 | | ` `[String](https://developer.android.com/reference/java/lang/String)                         | ` `[getInfo](https://developer.android.com/reference/java/security/Identity#getInfo())`() ` Returns general information previously specified for this identity.                                                                                                                           | | ` final `[String](https://developer.android.com/reference/java/lang/String)                   | ` `[getName](https://developer.android.com/reference/java/security/Identity#getName())`() ` Returns this identity's name.                                                                                                                                                                 | | ` `[PublicKey](https://developer.android.com/reference/java/security/PublicKey)               | ` `[getPublicKey](https://developer.android.com/reference/java/security/Identity#getPublicKey())`() ` Returns this identity's public key.                                                                                                                                                 | | ` final `[IdentityScope](https://developer.android.com/reference/java/security/IdentityScope) | ` `[getScope](https://developer.android.com/reference/java/security/Identity#getScope())`() ` Returns this identity's scope.                                                                                                                                                              | | ` int`                                                                                        | ` `[hashCode](https://developer.android.com/reference/java/security/Identity#hashCode())`() ` Returns a hashcode for this identity.                                                                                                                                                       | | ` boolean`                                                                                    | ` `[identityEquals](https://developer.android.com/reference/java/security/Identity#identityEquals(java.security.Identity))`(`[Identity](https://developer.android.com/reference/java/security/Identity)` identity) ` Tests for equality between the specified identity and this identity. | | ` void`                                                                                       | ` `[removeCertificate](https://developer.android.com/reference/java/security/Identity#removeCertificate(java.security.Certificate))`(`[Certificate](https://developer.android.com/reference/java/security/Certificate)` certificate) ` Removes a certificate from this identity.          | | ` void`                                                                                       | ` `[setInfo](https://developer.android.com/reference/java/security/Identity#setInfo(java.lang.String))`(`[String](https://developer.android.com/reference/java/lang/String)` info) ` Specifies a general information string for this identity.                                            | | ` void`                                                                                       | ` `[setPublicKey](https://developer.android.com/reference/java/security/Identity#setPublicKey(java.security.PublicKey))`(`[PublicKey](https://developer.android.com/reference/java/security/PublicKey)` key) ` Sets this identity's public key.                                           | | ` `[String](https://developer.android.com/reference/java/lang/String)                         | ` `[toString](https://developer.android.com/reference/java/security/Identity#toString())`() ` Returns a short string describing this identity, telling its name and its scope (if any).                                                                                                   | | ` `[String](https://developer.android.com/reference/java/lang/String)                         | ` `[toString](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` `[java.lang.Object](https://developer.android.com/reference/java/lang/Object)` ` |--------------------------------------------------------------------------------|-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------| | ` `[Object](https://developer.android.com/reference/java/lang/Object)          | ` `[clone](https://developer.android.com/reference/java/lang/Object#clone())`() ` Creates and returns a copy of this object.                                                                                                                                                      | | ` boolean`                                                                     | ` `[equals](https://developer.android.com/reference/java/lang/Object#equals(java.lang.Object))`(`[Object](https://developer.android.com/reference/java/lang/Object)` obj) ` Indicates whether some other object is "equal to" this one.                                           | | ` void`                                                                        | ` `[finalize](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 `[Class](https://developer.android.com/reference/java/lang/Class)`<?>` | ` `[getClass](https://developer.android.com/reference/java/lang/Object#getClass())`() ` Returns the runtime class of this`Object`.                                                                                                                                                | | ` int`                                                                         | ` `[hashCode](https://developer.android.com/reference/java/lang/Object#hashCode())`() ` Returns a hash code value for the object.                                                                                                                                                 | | ` final void`                                                                  | ` `[notify](https://developer.android.com/reference/java/lang/Object#notify())`() ` Wakes up a single thread that is waiting on this object's monitor.                                                                                                                            | | ` final void`                                                                  | ` `[notifyAll](https://developer.android.com/reference/java/lang/Object#notifyAll())`() ` Wakes up all threads that are waiting on this object's monitor.                                                                                                                         | | ` `[String](https://developer.android.com/reference/java/lang/String)          | ` `[toString](https://developer.android.com/reference/java/lang/Object#toString())`() ` Returns a string representation of the object.                                                                                                                                            | | ` final void`                                                                  | ` `[wait](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`                                                                  | ` `[wait](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`                                                                  | ` `[wait](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` `[java.security.Principal](https://developer.android.com/reference/java/security/Principal)` ` |--------------------------------------------------------------------------------|-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------| | ` abstract boolean`                                                            | ` `[equals](https://developer.android.com/reference/java/security/Principal#equals(java.lang.Object))`(`[Object](https://developer.android.com/reference/java/lang/Object)` another) ` Compares this principal to the specified object.                                             | | ` abstract `[String](https://developer.android.com/reference/java/lang/String) | ` `[getName](https://developer.android.com/reference/java/security/Principal#getName())`() ` Returns the name of this principal.                                                                                                                                                    | | ` abstract int`                                                                | ` `[hashCode](https://developer.android.com/reference/java/security/Principal#hashCode())`() ` Returns a hashcode for this principal.                                                                                                                                               | | ` default boolean`                                                             | ` `[implies](https://developer.android.com/reference/java/security/Principal#implies(javax.security.auth.Subject))`(`[Subject](https://developer.android.com/reference/javax/security/auth/Subject)` subject) ` Returns true if the specified subject is implied by this principal. | | ` abstract `[String](https://developer.android.com/reference/java/lang/String) | ` `[toString](https://developer.android.com/reference/java/security/Principal#toString())`() ` Returns a string representation of this principal.                                                                                                                                   | ||

## Public constructors

### Signer

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

```
public Signer (String name)
```

Creates a signer with the specified identity name.

<br />

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

### Signer

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

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

Creates a signer with the specified identity name and scope.

<br />

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

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

## Protected constructors

### Signer

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

```
protected Signer ()
```

Creates a signer. This constructor should only be used for serialization.

<br />

## Public methods

### getPrivateKey

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

```
public PrivateKey getPrivateKey ()
```

Returns this signer's private key.

First, if there is a security manager, its`checkSecurityAccess`method is called with`"getSignerPrivateKey"`as its argument to see if it's ok to return the private key.

<br />

|                                                                              Returns                                                                               ||
|--------------------------------------------------------------------------------|------------------------------------------------------------------------------------|
| [PrivateKey](https://developer.android.com/reference/java/security/PrivateKey) | this signer's private key, or null if the private key has not yet been set. <br /> |

|                                                                                               Throws                                                                                               ||
|------------------------------------------------------------------------------------------|----------------------------------------------------------------------------------------------------------|
| [SecurityException](https://developer.android.com/reference/java/lang/SecurityException) | if a security manager exists and its`checkSecurityAccess`method doesn't allow returning the private key. |

**See also:**

- [SecurityManager.checkSecurityAccess(String)](https://developer.android.com/reference/java/lang/SecurityManager#checkSecurityAccess(java.lang.String))  

### setKeyPair

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

```
public final void setKeyPair (KeyPair pair)
```

Sets the key pair (public key and private key) for this signer.

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

<br />

|                     Parameters                     ||
|--------|--------------------------------------------|
| `pair` | `KeyPair`: an initialized key pair. <br /> |

|                                                                                                      Throws                                                                                                       ||
|--------------------------------------------------------------------------------------------------------------|-----------------------------------------------------------------------------------------------------|
| [InvalidParameterException](https://developer.android.com/reference/java/security/InvalidParameterException) | if the key pair is not properly initialized.                                                        |
| [KeyException](https://developer.android.com/reference/java/security/KeyException)                           | if the key pair cannot be set for any other reason.                                                 |
| [SecurityException](https://developer.android.com/reference/java/lang/SecurityException)                     | if a security manager exists and its`checkSecurityAccess`method doesn't allow setting the key pair. |

**See also:**

- [SecurityManager.checkSecurityAccess(String)](https://developer.android.com/reference/java/lang/SecurityManager#checkSecurityAccess(java.lang.String))  

### toString

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

```
public String toString ()
```

Returns a string of information about the signer.

<br />

|                                                       Returns                                                        ||
|--------------------------------------------------------------------|--------------------------------------------------|
| [String](https://developer.android.com/reference/java/lang/String) | a string of information about the signer. <br /> |