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: [Methods](https://developer.android.com/reference/android/security/identity/WritableIdentityCredential#pubmethods) \| [Inherited Methods](https://developer.android.com/reference/android/security/identity/WritableIdentityCredential#inhmethods)

# WritableIdentityCredential

*** ** * ** ***


`
public


abstract
class
WritableIdentityCredential
`


`

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


`

`


`

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

<br />

*** ** * ** ***


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

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

Class used to personalize a new identity credential.

Credentials cannot be updated or modified after creation; any changes require deletion and
re-creation.

Use `https://developer.android.com/reference/android/security/identity/IdentityCredentialStore#createCredential(java.lang.String,%20java.lang.String)` to create a new credential.

## Summary

| ### Public methods ||
|---|---|
| ` abstract https://developer.android.com/reference/java/util/Collection<https://developer.android.com/reference/java/security/cert/X509Certificate>` | ` https://developer.android.com/reference/android/security/identity/WritableIdentityCredential#getCredentialKeyCertificateChain(byte[])(byte[] challenge) ` *This method is deprecated. Use `java.security.KeyStore` with the Android hardware-backed keystore instead.* |
| ` abstract byte[]` | ` https://developer.android.com/reference/android/security/identity/WritableIdentityCredential#personalize(android.security.identity.PersonalizationData)(https://developer.android.com/reference/android/security/identity/PersonalizationData personalizationData) ` *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*.


## Public methods

### getCredentialKeyCertificateChain

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

```
public abstract Collection<X509Certificate> getCredentialKeyCertificateChain (byte[] challenge)
```


**This method is deprecated.**   

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

Generates and returns an X.509 certificate chain for the CredentialKey which identifies this
credential to the issuing authority. The certificate contains an
[Android Keystore](https://source.android.com/security/keystore/attestation)
attestation extension which describes the key and the security hardware in which it lives.

Additionally, the attestation extension will contain the tag Tag::IDENTITY_CREDENTIAL_KEY
which indicates it is an Identity Credential key (which can only sign/MAC very specific
messages) and not an Android Keystore key (which can be used to sign/MAC anything).

The issuer **MUST** carefully examine this certificate chain including (but not
limited to) checking that the root certificate is well-known, the tag
Tag::IDENTITY_CREDENTIAL_KEY present, the passed in challenge is present, the tag
Tag::ATTESTATION_APPLICATION_ID is set to the expected Android application, the device
has verified boot enabled, each certificate in the chain is signed by its successor,
none of the certificates have been revoked, and so on.

It is not strictly necessary to use this method to provision a credential if the issuing
authority doesn't care about the nature of the security hardware. If called, however, this
method must be called before `https://developer.android.com/reference/android/security/identity/WritableIdentityCredential#personalize(android.security.identity.PersonalizationData)`.

<br />

| Parameters ||
|---|---|
| `challenge` | `byte`: is a non-empty byte array whose contents should be unique, fresh and provided by the issuing authority. The value provided is embedded in the attestation extension and enables the issuing authority to verify that the attestation certificate is fresh. Implementations are required to support challenges at least 32 bytes of length. This value cannot be `null`. <br /> |

| Returns ||
|---|---|
| `https://developer.android.com/reference/java/util/Collection<https://developer.android.com/reference/java/security/cert/X509Certificate>` | the X.509 certificate for this credential's CredentialKey. This value cannot be `null`. <br /> |

### personalize

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

```
public abstract byte[] personalize (PersonalizationData personalizationData)
```


**This method is deprecated.**   

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

Stores all of the data in the credential, with the specified access control profiles.

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

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

     AccessControlProfile = {
         "id": uint,
         ? "readerCertificate" : bstr,
         ? (
              "userAuthenticationRequired" : bool,
              "timeoutMillis" : uint,
         )
     }

     ProvisionedData = {
         * Namespace => [ + Entry ]
     },

     Namespace = tstr

     Entry = {
         "name" : tstr,
         "value" : any,
         "accessControlProfiles" : [ * uint ],
     }
```

This data structure provides a guarantee to the issuer about the data which may be
returned in the CBOR returned by
`https://developer.android.com/reference/android/security/identity/ResultData#getAuthenticatedData()` during a credential
presentation.

<br />

| Parameters ||
|---|---|
| `personalizationData` | `PersonalizationData`: The data to provision, including access control profiles and data elements and their values, grouped into namespaces. This value cannot be `null`. <br /> |

| Returns ||
|---|---|
| `byte[]` | A COSE_Sign1 data structure, see above. This value cannot be `null`. <br /> |