Class DeviceResponseParser
- java.lang.Object
-
- com.android.identity.DeviceResponseParser
-
public final class DeviceResponseParser extends java.lang.Object
Helper class for parsing the bytes ofDeviceResponse
CBOR as specified in ISO/IEC 18013-5 section 8.3 Device Retrieval.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static class
DeviceResponseParser.DeviceResponse
An object used to represent data parsed fromDeviceResponse
CBOR as specified in ISO/IEC 18013-5 section 8.3 Device Retrieval.static class
DeviceResponseParser.Document
An object used to represent data parsed from theDocument
CBOR (part ofDeviceResponse
) as specified in ISO/IEC 18013-5 section 8.3 Device Retrieval.
-
Constructor Summary
Constructors Constructor Description DeviceResponseParser()
Constructs aDeviceResponseParser
.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description DeviceResponseParser.DeviceResponse
parse()
Parses the device response.DeviceResponseParser
setDeviceResponse(byte[] encodedDeviceResponse)
Sets the bytes of theDeviceResponse
CBOR.DeviceResponseParser
setEphemeralReaderKey(java.security.PrivateKey eReaderKey)
Sets the private part of the ephemeral key used in the session where theDeviceResponse
was obtained.DeviceResponseParser
setSessionTranscript(byte[] encodedSessionTranscript)
Sets the bytes of theSessionTranscript
CBOR.
-
-
-
Constructor Detail
-
DeviceResponseParser
public DeviceResponseParser()
Constructs aDeviceResponseParser
.
-
-
Method Detail
-
setDeviceResponse
@NonNull public DeviceResponseParser setDeviceResponse(@NonNull byte[] encodedDeviceResponse)
Sets the bytes of theDeviceResponse
CBOR.- Parameters:
encodedDeviceResponse
- the bytes ofDeviceResponse
.- Returns:
- the
DeviceResponseParser
.
-
setSessionTranscript
@NonNull public DeviceResponseParser setSessionTranscript(@NonNull byte[] encodedSessionTranscript)
Sets the bytes of theSessionTranscript
CBOR.- Parameters:
encodedSessionTranscript
- the bytes ofSessionTranscript
.- Returns:
- the
DeviceResponseParser
.
-
setEphemeralReaderKey
@NonNull public DeviceResponseParser setEphemeralReaderKey(@NonNull java.security.PrivateKey eReaderKey)
Sets the private part of the ephemeral key used in the session where theDeviceResponse
was obtained.This is only required if the
DeviceResponse
is using the MAC method for device authentication.- Parameters:
eReaderKey
- the private part of the reader ephemeral key.- Returns:
- the
DeviceResponseParser
.
-
parse
@NonNull public DeviceResponseParser.DeviceResponse parse()
Parses the device response.It's mandatory to call
setDeviceResponse(byte[])
,setSessionTranscript(byte[])
before this call. If the response is using MAC for device authentication,setEphemeralReaderKey(PrivateKey)
must also have been called.This parser will successfully parse responses where issuer-signed data elements fails the digest check against the MSO, where
DeviceSigned
authentication checks fail, and whereIssuerSigned
authentication checks fail. The methodsDeviceResponseParser.Document.getIssuerEntryDigestMatch(String, String)
,DeviceResponseParser.Document.getDeviceSignedAuthenticated()
, andDeviceResponseParser.Document.getIssuerSignedAuthenticated()
can be used to get additional information about this.- Returns:
- a
DeviceResponseParser.DeviceResponse
with the parsed data. - Throws:
java.lang.IllegalArgumentException
- if the given data isn't valid CBOR or not conforming to the CDDL for its type.java.lang.IllegalStateException
- if required data hasn't been set using the setter methods on this class.
-
-