Added in [API level 30](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)   
Deprecated in [API level
37.2](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels) Summary: [Constants](https://developer.android.com/reference/android/security/identity/IdentityCredentialStore#constants) \| [Methods](https://developer.android.com/reference/android/security/identity/IdentityCredentialStore#pubmethods) \| [Inherited Methods](https://developer.android.com/reference/android/security/identity/IdentityCredentialStore#inhmethods)

# IdentityCredentialStore

*** ** * ** ***


`
public


abstract
class
IdentityCredentialStore
`


`

extends https://developer.android.com/reference/java/lang/Object


`

`


`

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

<br />

*** ** * ** ***


**This class was deprecated
in API level 37.2.**   

Use `java.security.KeyStore` with the Android hardware-backed keystore instead.

An interface to a secure store for user identity documents.

This interface is deliberately fairly general and abstract. To the extent possible,
specification of the message formats and semantics of communication with credential
verification devices and issuing authorities (IAs) is out of scope. It provides the
interface with secure storage but a credential-specific Android application will be
required to implement the presentation and verification protocols and processes
appropriate for the specific credential type.

Multiple credentials can be created. Each credential comprises:

- A document type, which is a string.
- A set of namespaces, which serve to disambiguate value names. It is recommended that namespaces be structured as reverse domain names so that IANA effectively serves as the namespace registrar.
- For each namespace, a set of name/value pairs, each with an associated set of access control profile IDs. Names are strings and values are typed and can be any value supported by [CBOR](http://cbor.io/).
- A set of access control profiles (up to 32), each with a profile ID and a specification of the conditions which satisfy the profile's requirements.
- An asymmetric key pair which is used to authenticate the credential to the Issuing Authority, called the *CredentialKey*.
- A set of zero or more named reader authentication public keys, which are used to authenticate an authorized reader to the credential.
- A set of named signing keys, which are used to sign collections of values and session transcripts.

Implementing support for user identity documents in secure storage requires dedicated
hardware-backed support and may not always be available.

Two different credential stores exist - the *default* store and the
*direct access* store. Most often credentials will be accessed through the default
store but that requires that the Android device be powered up and fully functional.
It is desirable to allow identity credential usage when the Android device's battery is too
low to boot the Android operating system, so direct access to the secure hardware via NFC
may allow data retrieval, if the secure hardware chooses to implement it.

Credentials provisioned to the direct access store should **always** use reader
authentication to protect data elements. The reason for this is user authentication or user
approval of data release is not possible when the device is off.

The Identity Credential API is designed to be able to evolve and change over time
but still provide 100% backwards compatibility. This is complicated by the fact that
there may be a version skew between the API used by the application and the version
implemented in secure hardware. To solve this problem, the API provides for a way
for the application to query which feature version the hardware implements (if any
at all) using
`https://developer.android.com/reference/android/content/pm/package-summary` and
`https://developer.android.com/reference/android/content/pm/package-summary`.
Methods which only work on certain feature versions are clearly documented as
such.

## Summary

| ### Constants ||
|---|---|
| `int` | `https://developer.android.com/reference/android/security/identity/IdentityCredentialStore#CIPHERSUITE_ECDHE_HKDF_ECDSA_WITH_AES_256_GCM_SHA256` *This constant is deprecated. Use `java.security.KeyStore` with the Android hardware-backed keystore instead.* |

| ### Public methods ||
|---|---|
| ` abstract https://developer.android.com/reference/android/security/identity/WritableIdentityCredential` | ` https://developer.android.com/reference/android/security/identity/IdentityCredentialStore#createCredential(java.lang.String,%20java.lang.String)(https://developer.android.com/reference/java/lang/String credentialName, https://developer.android.com/reference/java/lang/String docType) ` *This method is deprecated. Use `java.security.KeyStore` with the Android hardware-backed keystore instead.* |
| ` https://developer.android.com/reference/android/security/identity/PresentationSession` | ` https://developer.android.com/reference/android/security/identity/IdentityCredentialStore#createPresentationSession(int)(int cipherSuite) ` *This method was deprecated in API level 37.2. Use `java.security.KeyStore` with the Android hardware-backed keystore instead.* |
| ` abstract byte[]` | ` https://developer.android.com/reference/android/security/identity/IdentityCredentialStore#deleteCredentialByName(java.lang.String)(https://developer.android.com/reference/java/lang/String credentialName) ` *This method was deprecated in API level 31. Use `https://developer.android.com/reference/android/security/identity/IdentityCredential#delete(byte[])` instead.* |
| ` abstract https://developer.android.com/reference/android/security/identity/IdentityCredential` | ` https://developer.android.com/reference/android/security/identity/IdentityCredentialStore#getCredentialByName(java.lang.String,%20int)(https://developer.android.com/reference/java/lang/String credentialName, int cipherSuite) ` *This method is deprecated. Use `java.security.KeyStore` with the Android hardware-backed keystore instead.* |
| ` static https://developer.android.com/reference/android/security/identity/IdentityCredentialStore` | ` https://developer.android.com/reference/android/security/identity/IdentityCredentialStore#getDirectAccessInstance(android.content.Context)(https://developer.android.com/reference/android/content/Context context) ` *This method is deprecated. Use `java.security.KeyStore` with the Android hardware-backed keystore instead.* |
| ` static https://developer.android.com/reference/android/security/identity/IdentityCredentialStore` | ` https://developer.android.com/reference/android/security/identity/IdentityCredentialStore#getInstance(android.content.Context)(https://developer.android.com/reference/android/content/Context context) ` *This method is deprecated. Use `java.security.KeyStore` with the Android hardware-backed keystore instead.* |
| ` abstract https://developer.android.com/reference/java/lang/String` | ` https://developer.android.com/reference/android/security/identity/IdentityCredentialStore#getSupportedDocTypes()() ` *This method is deprecated. Use `java.security.KeyStore` with the Android hardware-backed keystore instead.* |

### Inherited methods

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


## Constants

### CIPHERSUITE_ECDHE_HKDF_ECDSA_WITH_AES_256_GCM_SHA256

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

```
public static final int CIPHERSUITE_ECDHE_HKDF_ECDSA_WITH_AES_256_GCM_SHA256
```


**This constant is deprecated.**   

Use `java.security.KeyStore` with the Android hardware-backed keystore
instead.

Specifies that the cipher suite that will be used to secure communications between the reader
and the prover is using the following primitives

- ECKA-DH (Elliptic Curve Key Agreement Algorithm - Diffie-Hellman, see BSI TR-03111).
- HKDF-SHA-256 (see RFC 5869).
- AES-256-GCM (see NIST SP 800-38D).
- HMAC-SHA-256 (see RFC 2104).

The exact way these primitives are combined to derive the session key is specified in
section 9.2.1.4 of ISO/IEC 18013-5 (see description of cipher suite '1').


At present this is the only supported cipher suite.

<br />

Constant Value:

1
(0x00000001)


## Public methods

### createCredential

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

```
public abstract WritableIdentityCredential createCredential (String credentialName, 
                String docType)
```


**This method is deprecated.**   

Use `java.security.KeyStore` with the Android hardware-backed keystore
instead.

Creates a new credential.

When a credential is created, a cryptographic key-pair - CredentialKey - is created which
is used to authenticate the store to the Issuing Authority. The private part of this
key-pair never leaves secure hardware and the public part can be obtained using
`https://developer.android.com/reference/android/security/identity/WritableIdentityCredential#getCredentialKeyCertificateChain(byte[])` on the
returned object.

In addition, all of the Credential data content is imported and a certificate for the
CredentialKey and a signature produced with the CredentialKey are created. These latter
values may be checked by an issuing authority to verify that the data was imported into
secure hardware and that it was imported unmodified.

<br />

| Parameters ||
|---|---|
| `credentialName` | `String`: The name used to identify the credential. This value cannot be `null`. <br /> |
| `docType` | `String`: The document type for the credential. This value cannot be `null`. <br /> |

| Returns ||
|---|---|
| `https://developer.android.com/reference/android/security/identity/WritableIdentityCredential` | A `https://developer.android.com/reference/android/security/identity/WritableIdentityCredential` that can be used to create a new credential. This value cannot be `null`. <br /> |

| Throws ||
|---|---|
| `https://developer.android.com/reference/android/security/identity/AlreadyPersonalizedException` | if a credential with the given name already exists. |
| `https://developer.android.com/reference/android/security/identity/DocTypeNotSupportedException` | if the given document type isn't supported by the store. |

### createPresentationSession

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

```
public PresentationSession createPresentationSession (int cipherSuite)
```


**This method was deprecated
in API level 37.2.**   

Use `java.security.KeyStore` with the Android hardware-backed keystore
instead.

Creates a new presentation session.

This method gets an object to be used for interaction with a remote verifier for
presentation of one or more credentials.

This is only implemented in feature version 202201 or later. If not implemented, the call
fails with `https://developer.android.com/reference/java/lang/UnsupportedOperationException`. See
`https://developer.android.com/reference/android/content/pm/PackageManager#FEATURE_IDENTITY_CREDENTIAL_HARDWARE` for known
feature versions.

<br />

| Parameters ||
|---|---|
| `cipherSuite` | `int`: the cipher suite to use for communicating with the verifier. Value is one of the following: - `https://developer.android.com/reference/android/security/identity/IdentityCredentialStore#CIPHERSUITE_ECDHE_HKDF_ECDSA_WITH_AES_256_GCM_SHA256` |

| Returns ||
|---|---|
| `https://developer.android.com/reference/android/security/identity/PresentationSession` | The presentation session. This value cannot be `null`. <br /> |

| Throws ||
|---|---|
| `https://developer.android.com/reference/android/security/identity/CipherSuiteNotSupportedException` |   |

### deleteCredentialByName

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

```
public abstract byte[] deleteCredentialByName (String credentialName)
```


**This method was deprecated
in API level 31.**   

Use `https://developer.android.com/reference/android/security/identity/IdentityCredential#delete(byte[])` instead.

Delete a named credential.

This method returns a COSE_Sign1 data structure signed by the CredentialKey
with payload set to `ProofOfDeletion` as defined below:

```
    ProofOfDeletion = [
         "ProofOfDeletion",            ; tstr
         tstr,                         ; DocType
         bool                          ; true if this is a test credential, should
                                       ; always be false.
     ]
```

<br />

<br />

| Parameters ||
|---|---|
| `credentialName` | `String`: the name of the credential to delete. This value cannot be `null`. <br /> |

| Returns ||
|---|---|
| `byte[]` | `null` if the credential was not found, the COSE_Sign1 data structure above if the credential was found and deleted. <br /> |

### getCredentialByName

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

```
public abstract IdentityCredential getCredentialByName (String credentialName, 
                int cipherSuite)
```


**This method is deprecated.**   

Use `java.security.KeyStore` with the Android hardware-backed keystore
instead.

Retrieve a named credential.

The cipher suite used to communicate with the remote verifier must also be specified.
Currently only a single cipher-suite is supported. Support for other cipher suites may be
added in a future version of this API.

<br />

| Parameters ||
|---|---|
| `credentialName` | `String`: the name of the credential to retrieve. This value cannot be `null`. <br /> |
| `cipherSuite` | `int`: the cipher suite to use for communicating with the verifier. Value is one of the following: - `https://developer.android.com/reference/android/security/identity/IdentityCredentialStore#CIPHERSUITE_ECDHE_HKDF_ECDSA_WITH_AES_256_GCM_SHA256` |

| Returns ||
|---|---|
| `https://developer.android.com/reference/android/security/identity/IdentityCredential` | The named credential, or null if not found. <br /> |

| Throws ||
|---|---|
| `https://developer.android.com/reference/android/security/identity/CipherSuiteNotSupportedException` |   |

### getDirectAccessInstance

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

```
public static IdentityCredentialStore getDirectAccessInstance (Context context)
```


**This method is deprecated.**   

Use `java.security.KeyStore` with the Android hardware-backed keystore
instead.

Gets the `https://developer.android.com/reference/android/security/identity/IdentityCredentialStore` for direct access.

Direct access requires specialized NFC hardware and may not be supported on all
devices even if default store is available. Credentials provisioned to the direct
access store should **always** use reader authentication to protect
data elements.

<br />

| Parameters ||
|---|---|
| `context` | `Context`: the application context. This value cannot be `null`. <br /> |

| Returns ||
|---|---|
| `https://developer.android.com/reference/android/security/identity/IdentityCredentialStore` | the `https://developer.android.com/reference/android/security/identity/IdentityCredentialStore` or `null` if direct access is not supported on this device. <br /> |

### getInstance

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

```
public static IdentityCredentialStore getInstance (Context context)
```


**This method is deprecated.**   

Use `java.security.KeyStore` with the Android hardware-backed keystore
instead.

Gets the default `https://developer.android.com/reference/android/security/identity/IdentityCredentialStore`.

<br />

| Parameters ||
|---|---|
| `context` | `Context`: the application context. This value cannot be `null`. <br /> |

| Returns ||
|---|---|
| `https://developer.android.com/reference/android/security/identity/IdentityCredentialStore` | the `https://developer.android.com/reference/android/security/identity/IdentityCredentialStore` or `null` if the device doesn't have hardware-backed support for secure storage of user identity documents. <br /> |

### getSupportedDocTypes

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

```
public abstract String[] getSupportedDocTypes ()
```


**This method is deprecated.**   

Use `java.security.KeyStore` with the Android hardware-backed keystore
instead.

Gets a list of supported document types.

Only the direct-access store may restrict the kind of document types that can be used for
credentials. The default store always supports any document type.

<br />

| Returns ||
|---|---|
| `https://developer.android.com/reference/java/lang/String` | The supported document types or the empty array if any document type is supported. This value cannot be `null`. <br /> |