Class DeviceRequestParser


  • public final class DeviceRequestParser
    extends java.lang.Object
    Helper class for parsing the bytes of DeviceRequest CBOR as specified in ISO/IEC 18013-5 section 8.3 Device Retrieval.
    • Method Detail

      • setDeviceRequest

        @NonNull
        public DeviceRequestParser setDeviceRequest​(@NonNull
                                                    byte[] encodedDeviceRequest)
        Sets the bytes of the DeviceRequest CBOR.
        Parameters:
        encodedDeviceRequest - the bytes of the DeviceRequest CBOR.
        Returns:
        the DeviceRequestParser.
      • setSessionTranscript

        @NonNull
        public DeviceRequestParser setSessionTranscript​(@NonNull
                                                        byte[] encodedSessionTranscript)
        Sets the bytes of the SessionTranscript CBOR.
        Parameters:
        encodedSessionTranscript - the bytes of SessionTranscript.
        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
        For example, if this code is to be used in production and there is uncertainty about which devices will have which security providers, and there is concern about running into parsing / validating issues. By default this value is set to false.
        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 whether ItemsRequest was authenticated. A GeneralSecurityException may be thrown if there issues within the default security provider. Use setSkipReaderAuthParseAndCheck 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.