addCredential

@Blocking
fun addCredential(credential: String, deviceKeyId: String): String

Add a mobile credential to storage.

This function validates the mobile credential as per ISO 18013-5 including checking that the issuer of the credential is trusted by checking the corresponding issuer certificate is already stored by the SDK. Furthermore this function validates the relationship between the device key referenced by the deviceKeyId parameter by 1) checking it isn't already in use by being bound to another mobile credential stored by the SDK and 2) checking the device key matches the device key in the provided mobile credential.

Return

credentialId of the saved mobile credential

Parameters

credential

Base64 encoded string (with or without padding) containing a CBOR formatted mobile credential (ISO 18013-5 section 8.3.2.1.2.2 - IssuerSigned)

deviceKeyId

the Id of the deviceKey used to generate the mobile credential. A device key can be generated using generateDeviceKey

Throws

If the SDK API is called before the SDK is initialised.

If the deviceKey is already in use.

If the deviceKey is not found.

If there is an error in generating the metadata from the metadata record.

If the local deviceKey does not match the credential key deviceKeyId.

If the credential is not valid and could not be added.

If the TrustedIssuerCertificate is not found.