Package com.android.identity
Class DeviceRequestParser
- java.lang.Object
-
- com.android.identity.DeviceRequestParser
-
public final class DeviceRequestParser extends java.lang.Object
Helper class for parsing the bytes ofDeviceRequest
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
DeviceRequestParser.DeviceRequest
An object used to represent data parsed fromDeviceRequest
CBOR as specified in ISO/IEC 18013-5 section 8.3 Device Retrieval.static class
DeviceRequestParser.DocumentRequest
An object used to represent data parsed from theDocRequest
CBOR (part ofDeviceRequest
) as specified in ISO/IEC 18013-5 section 8.3 Device Retrieval.
-
Constructor Summary
Constructors Constructor Description DeviceRequestParser()
Constructs aDeviceRequestParser
.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description DeviceRequestParser.DeviceRequest
parse()
Parses the device request.DeviceRequestParser
setDeviceRequest(byte[] encodedDeviceRequest)
Sets the bytes of theDeviceRequest
CBOR.DeviceRequestParser
setSessionTranscript(byte[] encodedSessionTranscript)
Sets the bytes of theSessionTranscript
CBOR.DeviceRequestParser
setSkipReaderAuthParseAndCheck(boolean skipReaderAuthParseAndCheck)
Sets a flag to skip force skip parsing the reader auth structure.
-
-
-
Constructor Detail
-
DeviceRequestParser
public DeviceRequestParser()
Constructs aDeviceRequestParser
.
-
-
Method Detail
-
setDeviceRequest
@NonNull public DeviceRequestParser setDeviceRequest(@NonNull byte[] encodedDeviceRequest)
Sets the bytes of theDeviceRequest
CBOR.- Parameters:
encodedDeviceRequest
- the bytes of theDeviceRequest
CBOR.- Returns:
- the
DeviceRequestParser
.
-
setSessionTranscript
@NonNull public DeviceRequestParser setSessionTranscript(@NonNull byte[] encodedSessionTranscript)
Sets the bytes of theSessionTranscript
CBOR.- Parameters:
encodedSessionTranscript
- the bytes ofSessionTranscript
.- Returns:
- the
DeviceRequestParser
.
-
setSkipReaderAuthParseAndCheck
@NonNull public DeviceRequestParser setSkipReaderAuthParseAndCheck(boolean skipReaderAuthParseAndCheck)
Sets a flag to skip force skip parsing the reader auth structure. This flag is useful when the user knows that:- they will ignore the reader auth result (optional in 18013-5)
- and explicitly don't want to parse it
- Parameters:
skipReaderAuthParseAndCheck
- a flag to skip force skip parsing the reader auth structure.- Returns:
- the
DeviceRequestParser
.
-
parse
@NonNull public DeviceRequestParser.DeviceRequest parse()
Parses the device request.This parser will successfully parse requests where the request is signed by the reader but the signature check fails. The method
DeviceRequestParser.DocumentRequest.getReaderAuthenticated()
can used to get additional information whetherItemsRequest
was authenticated. AGeneralSecurityException
may be thrown if there issues within the default security provider. UsesetSkipReaderAuthParseAndCheck
to skip some usage of security provider in reader auth parsing.- Returns:
- a
DeviceRequestParser.DeviceRequest
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.
-
-