Class DeviceResponseParser
- java.lang.Object
-
- com.android.identity.DeviceResponseParser
-
public final class DeviceResponseParser extends java.lang.ObjectHelper class for parsing the bytes ofDeviceResponseCBOR as specified in ISO/IEC 18013-5 section 8.3 Device Retrieval.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static classDeviceResponseParser.DeviceResponseAn object used to represent data parsed fromDeviceResponseCBOR as specified in ISO/IEC 18013-5 section 8.3 Device Retrieval.static classDeviceResponseParser.DocumentAn object used to represent data parsed from theDocumentCBOR (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.DeviceResponseparse()Parses the device response.DeviceResponseParsersetDeviceResponse(byte[] encodedDeviceResponse)Sets the bytes of theDeviceResponseCBOR.DeviceResponseParsersetEphemeralReaderKey(java.security.PrivateKey eReaderKey)Sets the private part of the ephemeral key used in the session where theDeviceResponsewas obtained.DeviceResponseParsersetSessionTranscript(byte[] encodedSessionTranscript)Sets the bytes of theSessionTranscriptCBOR.
-
-
-
Constructor Detail
-
DeviceResponseParser
public DeviceResponseParser()
Constructs aDeviceResponseParser.
-
-
Method Detail
-
setDeviceResponse
@NonNull public DeviceResponseParser setDeviceResponse(@NonNull byte[] encodedDeviceResponse)
Sets the bytes of theDeviceResponseCBOR.- Parameters:
encodedDeviceResponse- the bytes ofDeviceResponse.- Returns:
- the
DeviceResponseParser.
-
setSessionTranscript
@NonNull public DeviceResponseParser setSessionTranscript(@NonNull byte[] encodedSessionTranscript)
Sets the bytes of theSessionTranscriptCBOR.- 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 theDeviceResponsewas obtained.This is only required if the
DeviceResponseis 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
DeviceSignedauthentication checks fail, and whereIssuerSignedauthentication 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.DeviceResponsewith 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.
-
-