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

# PresentationSession

*** ** * ** ***


`
public


abstract
class
PresentationSession
`


`

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


`

`


`

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

<br />

*** ** * ** ***


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

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

Class for presenting multiple documents to a remote verifier.

This should be used for all interactions with a remote verifier instead of the now deprecated
`https://developer.android.com/reference/android/security/identity/IdentityCredential#getEntries(byte[],%20java.util.Map<java.lang.String,java.util.Collection<java.lang.String>>,%20byte[],%20byte[])` method.

Use `https://developer.android.com/reference/android/security/identity/IdentityCredentialStore#createPresentationSession(int)` to create a `https://developer.android.com/reference/android/security/identity/PresentationSession` instance.

## Summary

| ### Public methods ||
|---|---|
| ` abstract https://developer.android.com/reference/android/security/identity/CredentialDataResult` | ` https://developer.android.com/reference/android/security/identity/PresentationSession#getCredentialData(java.lang.String,%20android.security.identity.CredentialDataRequest)(https://developer.android.com/reference/java/lang/String credentialName, https://developer.android.com/reference/android/security/identity/CredentialDataRequest request) ` *This method is deprecated. Use `java.security.KeyStore` with the Android hardware-backed keystore instead.* |
| ` abstract https://developer.android.com/reference/java/security/KeyPair` | ` https://developer.android.com/reference/android/security/identity/PresentationSession#getEphemeralKeyPair()() ` *This method is deprecated. Use `java.security.KeyStore` with the Android hardware-backed keystore instead.* |
| ` abstract void` | ` https://developer.android.com/reference/android/security/identity/PresentationSession#setReaderEphemeralPublicKey(java.security.PublicKey)(https://developer.android.com/reference/java/security/PublicKey readerEphemeralPublicKey) ` *This method is deprecated. Use `java.security.KeyStore` with the Android hardware-backed keystore instead.* |
| ` abstract void` | ` https://developer.android.com/reference/android/security/identity/PresentationSession#setSessionTranscript(byte[])(byte[] sessionTranscript) ` *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

### getCredentialData

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

```
public abstract CredentialDataResult getCredentialData (String credentialName, 
                CredentialDataRequest request)
```


**This method is deprecated.**   

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

Retrieves data from a named credential in the current presentation session.

If an access control check fails for one of the requested entries or if the entry
doesn't exist, the entry is simply not returned. The application can detect this
by using the `https://developer.android.com/reference/android/security/identity/CredentialDataResult.Entries#getStatus(java.lang.String,%20java.lang.String)` method on
each of the requested entries.

The application should not make any assumptions on whether user authentication is needed.
Instead, the application should request the data elements values first and then examine
the returned `https://developer.android.com/reference/android/security/identity/CredentialDataResult.Entries`. If
`https://developer.android.com/reference/android/security/identity/CredentialDataResult.Entries#STATUS_USER_AUTHENTICATION_FAILED` is returned the
application should get a
`https://developer.android.com/reference/android/hardware/biometrics/BiometricPrompt.CryptoObject` which references this
object and use it with a `https://developer.android.com/reference/android/hardware/biometrics/BiometricPrompt`. Upon successful
authentication the application may call
`https://developer.android.com/reference/android/security/identity/PresentationSession#getCredentialData(java.lang.String,%20android.security.identity.CredentialDataRequest)` again.

It is permissible to call this method multiple times using the same credential name.
If this is done the same auth-key will be used.

If the reader signature is set in the request parameter (via the
`https://developer.android.com/reference/android/security/identity/CredentialDataRequest.Builder#setReaderSignature(byte[])` method) it must contain
the bytes of a `COSE_Sign1` structure as defined in RFC 8152. For the payload
`nil` shall be used and the detached payload is the `ReaderAuthenticationBytes`
CBOR described below.

```
    ReaderAuthentication = [
      "ReaderAuthentication",
      SessionTranscript,
      ItemsRequestBytes
    ]

    ItemsRequestBytes = #6.24(bstr .cbor ItemsRequest)

    ReaderAuthenticationBytes = #6.24(bstr .cbor ReaderAuthentication)
```

where `ItemsRequestBytes` are the bytes of the request message set in
the request parameter (via the
`https://developer.android.com/reference/android/security/identity/CredentialDataRequest.Builder#setRequestMessage(byte[])` method).

The public key corresponding to the key used to make the signature, can be found in the
`x5chain` unprotected header element of the `COSE_Sign1` structure (as as
described in
[draft-ietf-cose-x509-08](https://tools.ietf.org/html/draft-ietf-cose-x509-08)).
There will be at least one certificate in said element and there may be more (and if so,
each certificate must be signed by its successor).

Data elements protected by reader authentication are returned if, and only if,
`requestMessage` is signed by the top-most certificate in the reader's certificate
chain, and the data element is configured with an `https://developer.android.com/reference/android/security/identity/AccessControlProfile` configured
with an X.509 certificate for a key which appear in the certificate chain.

Note that the request message CBOR is used only for enforcing reader authentication, it's
not used for determining which entries this API will return. The application is expected to
have parsed the request message and filtered it according to user preference and/or consent.

<br />

| Parameters ||
|---|---|
| `credentialName` | `String`: the name of the credential to retrieve. This value cannot be `null`. <br /> |
| `request` | `CredentialDataRequest`: the data to retrieve from the credential. This value cannot be `null`. <br /> |

| Returns ||
|---|---|
| `https://developer.android.com/reference/android/security/identity/CredentialDataResult` | If the credential wasn't found, returns null. Otherwise a `https://developer.android.com/reference/android/security/identity/CredentialDataResult` object containing entry data organized by namespace and a cryptographically authenticated representation of the same data, bound to the current session. <br /> |

| Throws ||
|---|---|
| `https://developer.android.com/reference/android/security/identity/EphemeralPublicKeyNotFoundException` | if the ephemeral public key was not found in the session transcript. |
| `https://developer.android.com/reference/android/security/identity/InvalidReaderSignatureException` | if the reader signature is invalid, or it doesn't contain a certificate chain, or if the signature failed to validate. |
| `https://developer.android.com/reference/android/security/identity/InvalidRequestMessageException` | if the requestMessage is malformed. |
| `https://developer.android.com/reference/android/security/identity/NoAuthenticationKeyAvailableException` | if authentication keys were never provisioned for the credential or if they are expired or exhausted their use-count. |

### getEphemeralKeyPair

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

```
public abstract KeyPair getEphemeralKeyPair ()
```


**This method is deprecated.**   

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

Gets the ephemeral key pair to use to establish a secure channel with the verifier.

Applications should use this key-pair for the communications channel with the verifier
using a protocol / cipher-suite appropriate for the application. One example of such a
protocol is the one used for Mobile Driving Licenses, see ISO 18013-5.

The ephemeral key pair is tied to the `https://developer.android.com/reference/android/security/identity/PresentationSession` instance so subsequent
calls to this method will return the same key-pair.

<br />

| Returns ||
|---|---|
| `https://developer.android.com/reference/java/security/KeyPair` | ephemeral key pair to use to establish a secure channel with a reader. This value cannot be `null`. <br /> |

### setReaderEphemeralPublicKey

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

```
public abstract void setReaderEphemeralPublicKey (PublicKey readerEphemeralPublicKey)
```


**This method is deprecated.**   

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

Set the ephemeral public key provided by the verifier.

If called, this must be called before any calls to
`https://developer.android.com/reference/android/security/identity/PresentationSession#getCredentialData(java.lang.String,%20android.security.identity.CredentialDataRequest)`.

This method can only be called once per `https://developer.android.com/reference/android/security/identity/PresentationSession` instance.

<br />

| Parameters ||
|---|---|
| `readerEphemeralPublicKey` | `PublicKey`: The ephemeral public key provided by the reader to establish a secure session. This value cannot be `null`. <br /> |

| Throws ||
|---|---|
| `https://developer.android.com/reference/java/security/InvalidKeyException` | if the given key is invalid. |

### setSessionTranscript

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

```
public abstract void setSessionTranscript (byte[] sessionTranscript)
```


**This method is deprecated.**   

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

Set the session transcript.

If called, this must be called before any calls to
`https://developer.android.com/reference/android/security/identity/PresentationSession#getCredentialData(java.lang.String,%20android.security.identity.CredentialDataRequest)`.

If mdoc session encryption is used (e.g. if `https://developer.android.com/reference/android/security/identity/PresentationSession#getEphemeralKeyPair()` has been
called) then the X and Y coordinates of the public part of the key-pair returned by `https://developer.android.com/reference/android/security/identity/PresentationSession#getEphemeralKeyPair()` must appear somewhere in the bytes of the passed in CBOR. Each of
these coordinates must appear encoded with the most significant bits first and use the exact
amount of bits indicated by the key size of the ephemeral keys. For example, if the
ephemeral key is using the P-256 curve then the 32 bytes for the X coordinate encoded with
the most significant bits first must appear somewhere and ditto for the 32 bytes for the Y
coordinate.

This method can only be called once per `https://developer.android.com/reference/android/security/identity/PresentationSession` instance.

<br />

| Parameters ||
|---|---|
| `sessionTranscript` | `byte`: the session transcript. This value cannot be `null`. <br /> |