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

# Builder

*** ** * ** ***

```
class Builder
```

|---|---|
| [kotlin.Any](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-any/index.html) ||
| ↳ | [android.security.identity.CredentialDataRequest.Builder](https://developer.android.com/reference/kotlin/android/security/identity/CredentialDataRequest.Builder#) |

*** ** * ** ***

> [!CAUTION]
> **This class was deprecated in API level 37.2.**
>
> Use `java.security.KeyStore` with the Android hardware-backed keystore instead.

A builder for `https://developer.android.com/reference/kotlin/android/security/identity/CredentialDataRequest`.

## Summary

| Public constructors ||
|---|---|
| `https://developer.android.com/reference/kotlin/android/security/identity/CredentialDataRequest.Builder#Builder()()` Creates a new builder. |

| Public methods ||
|---|---|
| [CredentialDataRequest](https://developer.android.com/reference/kotlin/android/security/identity/CredentialDataRequest) | `https://developer.android.com/reference/kotlin/android/security/identity/CredentialDataRequest.Builder#build()()` Finishes building a `https://developer.android.com/reference/kotlin/android/security/identity/CredentialDataRequest`. |
| [CredentialDataRequest.Builder](https://developer.android.com/reference/kotlin/android/security/identity/CredentialDataRequest.Builder#) | `https://developer.android.com/reference/kotlin/android/security/identity/CredentialDataRequest.Builder#setAllowUsingExhaustedKeys(kotlin.Boolean)(allowUsingExhaustedKeys: https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-boolean/index.html)` Sets whether to allow using an authentication key which use count has been exceeded. |
| [CredentialDataRequest.Builder](https://developer.android.com/reference/kotlin/android/security/identity/CredentialDataRequest.Builder#) | `https://developer.android.com/reference/kotlin/android/security/identity/CredentialDataRequest.Builder#setAllowUsingExpiredKeys(kotlin.Boolean)(allowUsingExpiredKeys: https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-boolean/index.html)` Sets whether to allow using an authentication key which is expired. |
| [CredentialDataRequest.Builder](https://developer.android.com/reference/kotlin/android/security/identity/CredentialDataRequest.Builder#) | `https://developer.android.com/reference/kotlin/android/security/identity/CredentialDataRequest.Builder#setDeviceSignedEntriesToRequest(kotlin.collections.MutableMap)(entriesToRequest: https://kotlinlang.org/api/latest/jvm/stdlib/kotlin.collections/-mutable-map/index.html<https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-string/index.html!, https://kotlinlang.org/api/latest/jvm/stdlib/kotlin.collections/-mutable-collection/index.html<https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-string/index.html!>!>)` Sets the device-signed entries to request. |
| [CredentialDataRequest.Builder](https://developer.android.com/reference/kotlin/android/security/identity/CredentialDataRequest.Builder#) | `https://developer.android.com/reference/kotlin/android/security/identity/CredentialDataRequest.Builder#setIncrementUseCount(kotlin.Boolean)(incrementUseCount: https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-boolean/index.html)` Sets whether to increment the use-count for the authentication key used. |
| [CredentialDataRequest.Builder](https://developer.android.com/reference/kotlin/android/security/identity/CredentialDataRequest.Builder#) | `https://developer.android.com/reference/kotlin/android/security/identity/CredentialDataRequest.Builder#setIssuerSignedEntriesToRequest(kotlin.collections.MutableMap)(entriesToRequest: https://kotlinlang.org/api/latest/jvm/stdlib/kotlin.collections/-mutable-map/index.html<https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-string/index.html!, https://kotlinlang.org/api/latest/jvm/stdlib/kotlin.collections/-mutable-collection/index.html<https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-string/index.html!>!>)` Sets the issuer-signed entries to request. |
| [CredentialDataRequest.Builder](https://developer.android.com/reference/kotlin/android/security/identity/CredentialDataRequest.Builder#) | `https://developer.android.com/reference/kotlin/android/security/identity/CredentialDataRequest.Builder#setReaderSignature(kotlin.ByteArray)(readerSignature: https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-byte-array/index.html)` Sets the reader signature. |
| [CredentialDataRequest.Builder](https://developer.android.com/reference/kotlin/android/security/identity/CredentialDataRequest.Builder#) | `https://developer.android.com/reference/kotlin/android/security/identity/CredentialDataRequest.Builder#setRequestMessage(kotlin.ByteArray)(requestMessage: https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-byte-array/index.html)` Sets the request message CBOR. |

## Public constructors

### Builder

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

```
Builder()
```

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

Creates a new builder.

## Public methods

### build

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

```
fun build(): CredentialDataRequest
```

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

Finishes building a `https://developer.android.com/reference/kotlin/android/security/identity/CredentialDataRequest`.

| Return ||
|---|---|
| `https://developer.android.com/reference/kotlin/android/security/identity/CredentialDataRequest` | the `https://developer.android.com/reference/kotlin/android/security/identity/CredentialDataRequest` object. This value cannot be `null`. |

### setAllowUsingExhaustedKeys

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

```
fun setAllowUsingExhaustedKeys(allowUsingExhaustedKeys: Boolean): CredentialDataRequest.Builder
```

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

Sets whether to allow using an authentication key which use count has been exceeded.

This is useful in situations where the application hasn't had a chance to renew authentication keys, for example if the device hasn't been connected to the Internet or if the issuing authority server has been down.

The reason this could be useful is that the privacy risk of reusing an authentication key for a credential presentation could be significantly smaller compared to the inconvenience of not being able to present the credential at all.

By default this is set to true.

| Parameters ||
|---|---|
| `allowUsingExhaustedKeys` | [Boolean](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-boolean/index.html): whether to allow using an authentication key which use count has been exceeded if no other key is available. |

| Return ||
|---|---|
| `https://developer.android.com/reference/kotlin/android/security/identity/CredentialDataRequest.Builder#` | the builder. This value cannot be `null`. |

### setAllowUsingExpiredKeys

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

```
fun setAllowUsingExpiredKeys(allowUsingExpiredKeys: Boolean): CredentialDataRequest.Builder
```

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

Sets whether to allow using an authentication key which is expired.

This is useful in situations where the application hasn't had a chance to renew authentication keys, for example if the device hasn't been connected to the Internet or if the issuing authority server has been down.

The reason this could be useful is that many verifiers are likely to accept a credential presentation using an expired authentication key (the credential itself wouldn't be expired) and it's likely better for the holder to be able to do this than not present their credential at all.

By default this is set to false.

| Parameters ||
|---|---|
| `allowUsingExpiredKeys` | [Boolean](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-boolean/index.html): whether to allow using an authentication key which is expired if no other key is available. |

| Return ||
|---|---|
| `https://developer.android.com/reference/kotlin/android/security/identity/CredentialDataRequest.Builder#` | the builder. This value cannot be `null`. |

### setDeviceSignedEntriesToRequest

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

```
fun setDeviceSignedEntriesToRequest(entriesToRequest: MutableMap<String!, MutableCollection<String!>!>): CredentialDataRequest.Builder
```

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

Sets the device-signed entries to request.

| Parameters ||
|---|---|
| `entriesToRequest` | [MutableMap](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin.collections/-mutable-map/index.html)\<[String](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-string/index.html)!, [MutableCollection](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin.collections/-mutable-collection/index.html)\<[String](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-string/index.html)!\>!\>: the device-signed entries to request. This value cannot be `null`. |

| Return ||
|---|---|
| `https://developer.android.com/reference/kotlin/android/security/identity/CredentialDataRequest.Builder#` | This value cannot be `null`. |

### setIncrementUseCount

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

```
fun setIncrementUseCount(incrementUseCount: Boolean): CredentialDataRequest.Builder
```

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

Sets whether to increment the use-count for the authentication key used.

Not incrementing the use-count for an authentication key is useful in situations where the authentication key is known with certainty to not be leaked. For example, consider an application doing a credential presentation for the sole purpose of displaying the credential data to the user (not for verification).

By default this is set to true.

| Parameters ||
|---|---|
| `incrementUseCount` | [Boolean](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-boolean/index.html): whether to increment the use count of the authentication key used. |

| Return ||
|---|---|
| `https://developer.android.com/reference/kotlin/android/security/identity/CredentialDataRequest.Builder#` | the builder. This value cannot be `null`. |

### setIssuerSignedEntriesToRequest

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

```
fun setIssuerSignedEntriesToRequest(entriesToRequest: MutableMap<String!, MutableCollection<String!>!>): CredentialDataRequest.Builder
```

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

Sets the issuer-signed entries to request.

| Parameters ||
|---|---|
| `entriesToRequest` | [MutableMap](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin.collections/-mutable-map/index.html)\<[String](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-string/index.html)!, [MutableCollection](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin.collections/-mutable-collection/index.html)\<[String](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-string/index.html)!\>!\>: the issuer-signed entries to request. This value cannot be `null`. |

| Return ||
|---|---|
| `https://developer.android.com/reference/kotlin/android/security/identity/CredentialDataRequest.Builder#` | the builder. This value cannot be `null`. |

### setReaderSignature

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

```
fun setReaderSignature(readerSignature: ByteArray): CredentialDataRequest.Builder
```

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

Sets the reader signature.

This data structure is described in the documentation for the `https://developer.android.com/reference/kotlin/android/security/identity/PresentationSession#getCredentialData(kotlin.String,%20android.security.identity.CredentialDataRequest)` method.

| Parameters ||
|---|---|
| `readerSignature` | [ByteArray](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-byte-array/index.html): a `COSE_Sign1` structure as described above. This value cannot be `null`. |

| Return ||
|---|---|
| `https://developer.android.com/reference/kotlin/android/security/identity/CredentialDataRequest.Builder#` | the builder. This value cannot be `null`. |

### setRequestMessage

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

```
fun setRequestMessage(requestMessage: ByteArray): CredentialDataRequest.Builder
```

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

Sets the request message CBOR.

This data structure is described in the documentation for the `https://developer.android.com/reference/kotlin/android/security/identity/PresentationSession#getCredentialData(kotlin.String,%20android.security.identity.CredentialDataRequest)` method.

| Parameters ||
|---|---|
| `requestMessage` | [ByteArray](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-byte-array/index.html): the request message CBOR as described above. This value cannot be `null`. |

| Return ||
|---|---|
| `https://developer.android.com/reference/kotlin/android/security/identity/CredentialDataRequest.Builder#` | the builder. This value cannot be `null`. |