Package com.android.identity
Class DeviceResponseParser.Document
- java.lang.Object
-
- com.android.identity.DeviceResponseParser.Document
-
- Enclosing class:
- DeviceResponseParser
public static class DeviceResponseParser.Document extends java.lang.ObjectAn 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 Document()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description booleangetDeviceEntryBoolean(java.lang.String namespaceName, java.lang.String name)LikegetDeviceEntryData(String, String)but returns the CBOR decoded as a boolean.byte[]getDeviceEntryByteString(java.lang.String namespaceName, java.lang.String name)LikegetDeviceEntryData(String, String)but returns the CBOR decoded as a byte-string.byte[]getDeviceEntryData(java.lang.String namespaceName, java.lang.String name)Gets the raw CBOR data for the value of given data element in a given namespace in device-signed data.TimestampgetDeviceEntryDateTime(java.lang.String namespaceName, java.lang.String name)LikegetDeviceEntryData(String, String)but returns the CBOR decoded as aTimestamp.java.util.List<java.lang.String>getDeviceEntryNames(java.lang.String namespaceName)Gets the names of data elements in the given device-signed namespace.longgetDeviceEntryNumber(java.lang.String namespaceName, java.lang.String name)LikegetDeviceEntryData(String, String)but returns the CBOR decoded as a long.java.lang.StringgetDeviceEntryString(java.lang.String namespaceName, java.lang.String name)LikegetDeviceEntryData(String, String)but returns the CBOR decoded as a string.java.security.PublicKeygetDeviceKey()Returns theDeviceKeyfrom the MSO.java.util.List<java.lang.String>getDeviceNamespaces()Gets the names of namespaces with retrieved entries of the device-signed data.booleangetDeviceSignedAuthenticated()Returns whether theDeviceSigneddata was authenticated.booleangetDeviceSignedAuthenticatedViaSignature()Returns whetherDeviceSignedwas authenticated using ECDSA signature or using a MAC.java.lang.StringgetDocType()Returns the type of document (commonly referred to asdocType).java.util.List<java.security.cert.X509Certificate>getIssuerCertificateChain()Returns the X509 certificate chain for the issuer which signed the data in the document.booleangetIssuerEntryBoolean(java.lang.String namespaceName, java.lang.String name)LikegetIssuerEntryData(String, String)but returns the CBOR decoded as a boolean.byte[]getIssuerEntryByteString(java.lang.String namespaceName, java.lang.String name)LikegetIssuerEntryData(String, String)but returns the CBOR decoded as a byte-string.byte[]getIssuerEntryData(java.lang.String namespaceName, java.lang.String name)Gets the raw CBOR data for the value of given data element in a given namespace in issuer-signed data.TimestampgetIssuerEntryDateTime(java.lang.String namespaceName, java.lang.String name)LikegetIssuerEntryData(String, String)but returns the CBOR decoded as aTimestamp.booleangetIssuerEntryDigestMatch(java.lang.String namespaceName, java.lang.String name)Gets whether the digest for the given entry matches the digest in the MSO.java.util.List<java.lang.String>getIssuerEntryNames(java.lang.String namespaceName)Gets the names of data elements in the given issuer-signed namespace.longgetIssuerEntryNumber(java.lang.String namespaceName, java.lang.String name)LikegetIssuerEntryData(String, String)but returns the CBOR decoded as a long.java.lang.StringgetIssuerEntryString(java.lang.String namespaceName, java.lang.String name)LikegetIssuerEntryData(String, String)but returns the CBOR decoded as a string.java.util.List<java.lang.String>getIssuerNamespaces()Gets the names of namespaces with retrieved entries of the issuer-signed data.booleangetIssuerSignedAuthenticated()Returns whether theIssuerSigneddata was authenticated.intgetNumIssuerEntryDigestMatchFailures()Gets the number of issuer entries for that didn't match the digest in the MSO.TimestampgetValidityInfoExpectedUpdate()Returns theexpectedUpdatedate from the MSO.TimestampgetValidityInfoSigned()Returns thesigneddate from the MSO.TimestampgetValidityInfoValidFrom()Returns thevalidFromdate from the MSO.TimestampgetValidityInfoValidUntil()Returns thevalidUntildate from the MSO.
-
-
-
Method Detail
-
getDocType
@NonNull public java.lang.String getDocType()
Returns the type of document (commonly referred to asdocType).- Returns:
- the document type.
-
getValidityInfoSigned
@NonNull public Timestamp getValidityInfoSigned()
Returns thesigneddate from the MSO.- Returns:
- a
Timestampfor when the MSO was signed.
-
getValidityInfoValidFrom
@NonNull public Timestamp getValidityInfoValidFrom()
Returns thevalidFromdate from the MSO.- Returns:
- a
Timestampfor when the MSO is valid from.
-
getValidityInfoValidUntil
@NonNull public Timestamp getValidityInfoValidUntil()
Returns thevalidUntildate from the MSO.- Returns:
- a
Timestampfor when the MSO is valid until.
-
getValidityInfoExpectedUpdate
@Nullable public Timestamp getValidityInfoExpectedUpdate()
Returns theexpectedUpdatedate from the MSO.- Returns:
- a
Timestampfor when the MSO is valid until ornullif this isn't set.
-
getDeviceKey
@NonNull public java.security.PublicKey getDeviceKey()
Returns theDeviceKeyfrom the MSO.- Returns:
- a
PublicKeyrepresenting theDeviceKey.
-
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 theIssuerSigneddata was authenticated.This returns
trueonly if the signature on theMobileSecurityObjectdata was made with the public key in the leaf certificate returned by.getIssuerCertificateChain()- Returns:
- whether the
DeviceSigneddata 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)returnsfalse.
-
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)LikegetIssuerEntryData(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)LikegetIssuerEntryData(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)LikegetIssuerEntryData(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)LikegetIssuerEntryData(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)
LikegetIssuerEntryData(String, String)but returns the CBOR decoded as aTimestamp.- 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 theDeviceSigneddata was authenticated.This returns
trueonly if the returned device-signed data was properly MACed or signed by aDeviceKeyin the MSO.- Returns:
- whether the
DeviceSigneddata was authenticated.
-
getDeviceSignedAuthenticatedViaSignature
public boolean getDeviceSignedAuthenticatedViaSignature()
Returns whetherDeviceSignedwas authenticated using ECDSA signature or using a MAC.- Returns:
trueif ECDSA signature was used,falseotherwise.
-
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)LikegetDeviceEntryData(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)LikegetDeviceEntryData(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)LikegetDeviceEntryData(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)LikegetDeviceEntryData(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)
LikegetDeviceEntryData(String, String)but returns the CBOR decoded as aTimestamp.- 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.
-
-