Class DeviceResponseParser.Document

  • Enclosing class:
    DeviceResponseParser

    public static class DeviceResponseParser.Document
    extends java.lang.Object
    An object used to represent data parsed from the Document CBOR (part of DeviceResponse) as specified in ISO/IEC 18013-5 section 8.3 Device Retrieval.
    • Constructor Detail

      • Document

        public Document()
    • Method Detail

      • getDocType

        @NonNull
        public java.lang.String getDocType()
        Returns the type of document (commonly referred to as docType).
        Returns:
        the document type.
      • getValidityInfoSigned

        @NonNull
        public Timestamp getValidityInfoSigned()
        Returns the signed date from the MSO.
        Returns:
        a Timestamp for when the MSO was signed.
      • getValidityInfoValidFrom

        @NonNull
        public Timestamp getValidityInfoValidFrom()
        Returns the validFrom date from the MSO.
        Returns:
        a Timestamp for when the MSO is valid from.
      • getValidityInfoValidUntil

        @NonNull
        public Timestamp getValidityInfoValidUntil()
        Returns the validUntil date from the MSO.
        Returns:
        a Timestamp for when the MSO is valid until.
      • getValidityInfoExpectedUpdate

        @Nullable
        public Timestamp getValidityInfoExpectedUpdate()
        Returns the expectedUpdate date from the MSO.
        Returns:
        a Timestamp for when the MSO is valid until or null if this isn't set.
      • getDeviceKey

        @NonNull
        public java.security.PublicKey getDeviceKey()
        Returns the DeviceKey from the MSO.
        Returns:
        a PublicKey representing the DeviceKey.
      • getIssuerCertificateChain

        @NonNull
        public java.util.List<java.security.cert.X509Certificate> getIssuerCertificateChain()
        Returns the X509 certificate chain for the issuer which signed the data in the document.
        Returns:
        A X.509 certificate chain.
      • getIssuerSignedAuthenticated

        public boolean getIssuerSignedAuthenticated()
        Returns whether the IssuerSigned data was authenticated.

        This returns true only if the signature on the MobileSecurityObject data was made with the public key in the leaf certificate returned by. getIssuerCertificateChain()

        Returns:
        whether the DeviceSigned data was authenticated.
      • getIssuerNamespaces

        @NonNull
        public java.util.List<java.lang.String> getIssuerNamespaces()
        Gets the names of namespaces with retrieved entries of the issuer-signed data.

        If the document doesn't contain any issuer-signed data, this returns the empty collection.

        Returns:
        Collection of names of namespaces in the issuer-signed data.
      • getIssuerEntryNames

        @NonNull
        public java.util.List<java.lang.String> getIssuerEntryNames​(@NonNull
                                                                    java.lang.String namespaceName)
        Gets the names of data elements in the given issuer-signed namespace.
        Parameters:
        namespaceName - the name of the namespace to get data element names from.
        Returns:
        A collection of data element names for the namespace.
        Throws:
        java.lang.IllegalArgumentException - if the given namespace isn't in the data.
      • getIssuerEntryDigestMatch

        public boolean getIssuerEntryDigestMatch​(@NonNull
                                                 java.lang.String namespaceName,
                                                 @NonNull
                                                 java.lang.String name)
        Gets whether the digest for the given entry matches the digest in the MSO.
        Parameters:
        namespaceName - the name of the namespace to get a data element value from.
        name - the name of the data element in the given namespace.
        Returns:
        the encoded CBOR data for the data element
        Throws:
        java.lang.IllegalArgumentException - if the given namespace or entry isn't in the data.
      • getNumIssuerEntryDigestMatchFailures

        public int getNumIssuerEntryDigestMatchFailures()
        Gets the number of issuer entries for that didn't match the digest in the MSO.
        Returns:
        Number of entries for which getIssuerEntryDigestMatch(String, String) returns false.
      • getIssuerEntryData

        @NonNull
        public byte[] getIssuerEntryData​(@NonNull
                                         java.lang.String namespaceName,
                                         @NonNull
                                         java.lang.String name)
        Gets the raw CBOR data for the value of given data element in a given namespace in issuer-signed data.
        Parameters:
        namespaceName - the name of the namespace to get a data element value from.
        name - the name of the data element in the given namespace.
        Returns:
        the encoded CBOR data for the data element
        Throws:
        java.lang.IllegalArgumentException - if the given namespace or entry isn't in the data.
      • getIssuerEntryString

        @NonNull
        public java.lang.String getIssuerEntryString​(@NonNull
                                                     java.lang.String namespaceName,
                                                     @NonNull
                                                     java.lang.String name)
        Like getIssuerEntryData(String, String) but returns the CBOR decoded as a string.
        Parameters:
        namespaceName - the name of the namespace to get a data element value from.
        name - the name of the data element in the given namespace.
        Returns:
        the decoded data.
        Throws:
        java.lang.IllegalArgumentException - if the CBOR data isn't in data or not the right type.
      • getIssuerEntryByteString

        @NonNull
        public byte[] getIssuerEntryByteString​(@NonNull
                                               java.lang.String namespaceName,
                                               @NonNull
                                               java.lang.String name)
        Like getIssuerEntryData(String, String) but returns the CBOR decoded as a byte-string.
        Parameters:
        namespaceName - the name of the namespace to get a data element value from.
        name - the name of the data element in the given namespace.
        Returns:
        the decoded data.
        Throws:
        java.lang.IllegalArgumentException - if the CBOR data isn't in data or not the right type.
      • getIssuerEntryBoolean

        public boolean getIssuerEntryBoolean​(@NonNull
                                             java.lang.String namespaceName,
                                             @NonNull
                                             java.lang.String name)
        Like getIssuerEntryData(String, String) but returns the CBOR decoded as a boolean.
        Parameters:
        namespaceName - the name of the namespace to get a data element value from.
        name - the name of the data element in the given namespace.
        Returns:
        the decoded data.
        Throws:
        java.lang.IllegalArgumentException - if the CBOR data isn't in data or not the right type.
      • getIssuerEntryNumber

        public long getIssuerEntryNumber​(@NonNull
                                         java.lang.String namespaceName,
                                         @NonNull
                                         java.lang.String name)
        Like getIssuerEntryData(String, String) but returns the CBOR decoded as a long.
        Parameters:
        namespaceName - the name of the namespace to get a data element value from.
        name - the name of the data element in the given namespace.
        Returns:
        the decoded data.
        Throws:
        java.lang.IllegalArgumentException - if the CBOR data isn't in data or not the right type.
      • getIssuerEntryDateTime

        @NonNull
        public Timestamp getIssuerEntryDateTime​(@NonNull
                                                java.lang.String namespaceName,
                                                @NonNull
                                                java.lang.String name)
        Like getIssuerEntryData(String, String) but returns the CBOR decoded as a Timestamp.
        Parameters:
        namespaceName - the name of the namespace to get a data element value from.
        name - the name of the data element in the given namespace.
        Returns:
        the decoded data.
        Throws:
        java.lang.IllegalArgumentException - if the CBOR data isn't in data or not the right type.
      • getDeviceSignedAuthenticated

        public boolean getDeviceSignedAuthenticated()
        Returns whether the DeviceSigned data was authenticated.

        This returns true only if the returned device-signed data was properly MACed or signed by a DeviceKey in the MSO.

        Returns:
        whether the DeviceSigned data was authenticated.
      • getDeviceSignedAuthenticatedViaSignature

        public boolean getDeviceSignedAuthenticatedViaSignature()
        Returns whether DeviceSigned was authenticated using ECDSA signature or using a MAC.
        Returns:
        true if ECDSA signature was used, false otherwise.
      • getDeviceNamespaces

        @NonNull
        public java.util.List<java.lang.String> getDeviceNamespaces()
        Gets the names of namespaces with retrieved entries of the device-signed data.

        If the document doesn't contain any device-signed data, this returns the empty collection.

        Returns:
        Collection of names of namespaces in the device-signed data.
      • getDeviceEntryNames

        @NonNull
        public java.util.List<java.lang.String> getDeviceEntryNames​(@NonNull
                                                                    java.lang.String namespaceName)
        Gets the names of data elements in the given device-signed namespace.
        Parameters:
        namespaceName - the name of the namespace to get data element names from.
        Returns:
        A collection of data element names for the namespace.
        Throws:
        java.lang.IllegalArgumentException - if the given namespace isn't in the data.
      • getDeviceEntryData

        @NonNull
        public byte[] getDeviceEntryData​(@NonNull
                                         java.lang.String namespaceName,
                                         @NonNull
                                         java.lang.String name)
        Gets the raw CBOR data for the value of given data element in a given namespace in device-signed data.
        Parameters:
        namespaceName - the name of the namespace to get a data element value from.
        name - the name of the data element in the given namespace.
        Returns:
        the encoded CBOR data for the data element
        Throws:
        java.lang.IllegalArgumentException - if the given namespace or entry isn't in the data.
      • getDeviceEntryString

        @NonNull
        public java.lang.String getDeviceEntryString​(@NonNull
                                                     java.lang.String namespaceName,
                                                     @NonNull
                                                     java.lang.String name)
        Like getDeviceEntryData(String, String) but returns the CBOR decoded as a string.
        Parameters:
        namespaceName - the name of the namespace to get a data element value from.
        name - the name of the data element in the given namespace.
        Returns:
        the decoded data.
        Throws:
        java.lang.IllegalArgumentException - if the CBOR data isn't in data or not the right type.
      • getDeviceEntryByteString

        @NonNull
        public byte[] getDeviceEntryByteString​(@NonNull
                                               java.lang.String namespaceName,
                                               @NonNull
                                               java.lang.String name)
        Like getDeviceEntryData(String, String) but returns the CBOR decoded as a byte-string.
        Parameters:
        namespaceName - the name of the namespace to get a data element value from.
        name - the name of the data element in the given namespace.
        Returns:
        the decoded data.
        Throws:
        java.lang.IllegalArgumentException - if the CBOR data isn't in data or not the right type.
      • getDeviceEntryBoolean

        public boolean getDeviceEntryBoolean​(@NonNull
                                             java.lang.String namespaceName,
                                             @NonNull
                                             java.lang.String name)
        Like getDeviceEntryData(String, String) but returns the CBOR decoded as a boolean.
        Parameters:
        namespaceName - the name of the namespace to get a data element value from.
        name - the name of the data element in the given namespace.
        Returns:
        the decoded data.
        Throws:
        java.lang.IllegalArgumentException - if the CBOR data isn't in data or not the right type.
      • getDeviceEntryNumber

        public long getDeviceEntryNumber​(@NonNull
                                         java.lang.String namespaceName,
                                         @NonNull
                                         java.lang.String name)
        Like getDeviceEntryData(String, String) but returns the CBOR decoded as a long.
        Parameters:
        namespaceName - the name of the namespace to get a data element value from.
        name - the name of the data element in the given namespace.
        Returns:
        the decoded data.
        Throws:
        java.lang.IllegalArgumentException - if the CBOR data isn't in data or not the right type.
      • getDeviceEntryDateTime

        @NonNull
        public Timestamp getDeviceEntryDateTime​(@NonNull
                                                java.lang.String namespaceName,
                                                @NonNull
                                                java.lang.String name)
        Like getDeviceEntryData(String, String) but returns the CBOR decoded as a Timestamp.
        Parameters:
        namespaceName - the name of the namespace to get a data element value from.
        name - the name of the data element in the given namespace.
        Returns:
        the decoded data.
        Throws:
        java.lang.IllegalArgumentException - if the CBOR data isn't in data or not the right type.