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.Object
An object used to represent data parsed from theDocument
CBOR (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 boolean
getDeviceEntryBoolean(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.Timestamp
getDeviceEntryDateTime(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.long
getDeviceEntryNumber(java.lang.String namespaceName, java.lang.String name)
LikegetDeviceEntryData(String, String)
but returns the CBOR decoded as a long.java.lang.String
getDeviceEntryString(java.lang.String namespaceName, java.lang.String name)
LikegetDeviceEntryData(String, String)
but returns the CBOR decoded as a string.java.security.PublicKey
getDeviceKey()
Returns theDeviceKey
from the MSO.java.util.List<java.lang.String>
getDeviceNamespaces()
Gets the names of namespaces with retrieved entries of the device-signed data.boolean
getDeviceSignedAuthenticated()
Returns whether theDeviceSigned
data was authenticated.boolean
getDeviceSignedAuthenticatedViaSignature()
Returns whetherDeviceSigned
was authenticated using ECDSA signature or using a MAC.java.lang.String
getDocType()
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.boolean
getIssuerEntryBoolean(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.Timestamp
getIssuerEntryDateTime(java.lang.String namespaceName, java.lang.String name)
LikegetIssuerEntryData(String, String)
but returns the CBOR decoded as aTimestamp
.boolean
getIssuerEntryDigestMatch(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.long
getIssuerEntryNumber(java.lang.String namespaceName, java.lang.String name)
LikegetIssuerEntryData(String, String)
but returns the CBOR decoded as a long.java.lang.String
getIssuerEntryString(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.boolean
getIssuerSignedAuthenticated()
Returns whether theIssuerSigned
data was authenticated.int
getNumIssuerEntryDigestMatchFailures()
Gets the number of issuer entries for that didn't match the digest in the MSO.Timestamp
getValidityInfoExpectedUpdate()
Returns theexpectedUpdate
date from the MSO.Timestamp
getValidityInfoSigned()
Returns thesigned
date from the MSO.Timestamp
getValidityInfoValidFrom()
Returns thevalidFrom
date from the MSO.Timestamp
getValidityInfoValidUntil()
Returns thevalidUntil
date 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 thesigned
date from the MSO.- Returns:
- a
Timestamp
for when the MSO was signed.
-
getValidityInfoValidFrom
@NonNull public Timestamp getValidityInfoValidFrom()
Returns thevalidFrom
date from the MSO.- Returns:
- a
Timestamp
for when the MSO is valid from.
-
getValidityInfoValidUntil
@NonNull public Timestamp getValidityInfoValidUntil()
Returns thevalidUntil
date from the MSO.- Returns:
- a
Timestamp
for when the MSO is valid until.
-
getValidityInfoExpectedUpdate
@Nullable public Timestamp getValidityInfoExpectedUpdate()
Returns theexpectedUpdate
date from the MSO.- Returns:
- a
Timestamp
for when the MSO is valid until ornull
if this isn't set.
-
getDeviceKey
@NonNull public java.security.PublicKey getDeviceKey()
Returns theDeviceKey
from the MSO.- Returns:
- a
PublicKey
representing 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 theIssuerSigned
data was authenticated.This returns
true
only if the signature on theMobileSecurityObject
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)
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 theDeviceSigned
data was authenticated.This returns
true
only if the returned device-signed data was properly MACed or signed by aDeviceKey
in the MSO.- Returns:
- whether the
DeviceSigned
data was authenticated.
-
getDeviceSignedAuthenticatedViaSignature
public boolean getDeviceSignedAuthenticatedViaSignature()
Returns whetherDeviceSigned
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)
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.
-
-