Skip to content

Commit

Permalink
Rename constant container to match semantics
Browse files Browse the repository at this point in the history
  • Loading branch information
nodh committed Oct 30, 2023
1 parent 29e3339 commit 061b926
Show file tree
Hide file tree
Showing 12 changed files with 143 additions and 163 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import at.asitplus.wallet.lib.agent.Issuer
import at.asitplus.wallet.lib.data.Base64UrlStrict
import at.asitplus.wallet.lib.data.ConstantIndex
import at.asitplus.wallet.lib.data.VcDataModelConstants.VERIFIABLE_CREDENTIAL
import at.asitplus.wallet.lib.iso.IsoDataModelConstants.DataElements
import at.asitplus.wallet.lib.iso.MobileDrivingLicenceDataElements
import at.asitplus.wallet.lib.jws.JsonWebToken
import at.asitplus.wallet.lib.jws.JwsAlgorithm
import at.asitplus.wallet.lib.jws.JwsSigned
Expand Down Expand Up @@ -85,7 +85,7 @@ class IssuerService(
)

private fun ConstantIndex.CredentialScheme.buildIsoClaims() = mapOf(
isoNamespace to DataElements.ALL_ELEMENTS.associateWith { RequestedCredentialClaimSpecification() }
isoNamespace to MobileDrivingLicenceDataElements.ALL_ELEMENTS.associateWith { RequestedCredentialClaimSpecification() }
)

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ class WalletService(
private val credentialScheme: ConstantIndex.CredentialScheme,
private val credentialRepresentation: ConstantIndex.CredentialRepresentation,
/**
* Pass names of attributes the credential shall contain, e.g. [at.asitplus.wallet.lib.iso.IsoDataModelConstants.DataElements]
* Pass names of attributes the credential shall contain, e.g. [at.asitplus.wallet.lib.iso.MobileDrivingLicenceDataElements]
*/
private val requestedAttributes: Collection<String>? = null,
private val clientId: String = "https://wallet.a-sit.at/app",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,13 @@ import at.asitplus.wallet.lib.data.ConstantIndex
import at.asitplus.wallet.lib.iso.DrivingPrivilege
import at.asitplus.wallet.lib.iso.DrivingPrivilegeCode
import at.asitplus.wallet.lib.iso.ElementValue
import at.asitplus.wallet.lib.iso.IsoDataModelConstants.DataElements
import at.asitplus.wallet.lib.iso.IssuerSignedItem
import at.asitplus.wallet.lib.iso.MobileDrivingLicenceDataElements.DOCUMENT_NUMBER
import at.asitplus.wallet.lib.iso.MobileDrivingLicenceDataElements.DRIVING_PRIVILEGES
import at.asitplus.wallet.lib.iso.MobileDrivingLicenceDataElements.EXPIRY_DATE
import at.asitplus.wallet.lib.iso.MobileDrivingLicenceDataElements.FAMILY_NAME
import at.asitplus.wallet.lib.iso.MobileDrivingLicenceDataElements.GIVEN_NAME
import at.asitplus.wallet.lib.iso.MobileDrivingLicenceDataElements.ISSUE_DATE
import kotlinx.datetime.Clock
import kotlinx.datetime.LocalDate
import kotlin.random.Random
Expand Down Expand Up @@ -76,12 +81,12 @@ class DummyCredentialDataProvider(
codes = arrayOf(DrivingPrivilegeCode(code = "B"))
)
val issuerSignedItems = listOf(
buildIssuerSignedItem(DataElements.FAMILY_NAME, "Mustermann", 0U),
buildIssuerSignedItem(DataElements.GIVEN_NAME, "Max", 1U),
buildIssuerSignedItem(DataElements.DOCUMENT_NUMBER, "123456789", 2U),
buildIssuerSignedItem(DataElements.ISSUE_DATE, "2023-01-01", 3U),
buildIssuerSignedItem(DataElements.EXPIRY_DATE, "2033-01-31", 4U),
buildIssuerSignedItem(DataElements.DRIVING_PRIVILEGES, drivingPrivilege, 5U),
buildIssuerSignedItem(FAMILY_NAME, "Mustermann", 0U),
buildIssuerSignedItem(GIVEN_NAME, "Max", 1U),
buildIssuerSignedItem(DOCUMENT_NUMBER, "123456789", 2U),
buildIssuerSignedItem(ISSUE_DATE, "2023-01-01", 3U),
buildIssuerSignedItem(EXPIRY_DATE, "2033-01-31", 4U),
buildIssuerSignedItem(DRIVING_PRIVILEGES, drivingPrivilege, 5U),
)

credentials.add(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import at.asitplus.wallet.lib.agent.Verifier
import at.asitplus.wallet.lib.agent.VerifierAgent
import at.asitplus.wallet.lib.data.ConstantIndex
import at.asitplus.wallet.lib.data.IsoDocumentParsed
import at.asitplus.wallet.lib.iso.IsoDataModelConstants
import at.asitplus.wallet.lib.iso.MobileDrivingLicenceDataElements
import com.benasher44.uuid.uuid4
import io.kotest.core.spec.style.FreeSpec
import io.kotest.matchers.collections.shouldBeEmpty
Expand Down Expand Up @@ -96,7 +96,7 @@ class OidcSiopIsoProtocolTest : FreeSpec({
}

"Selective Disclosure with mDL" {
val requestedClaim = IsoDataModelConstants.DataElements.FAMILY_NAME
val requestedClaim = MobileDrivingLicenceDataElements.FAMILY_NAME
verifierSiop = OidcSiopVerifier.newInstance(
verifier = verifierAgent,
cryptoService = verifierCryptoService,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,6 @@ import at.asitplus.wallet.lib.data.VerifiableCredential
import at.asitplus.wallet.lib.data.VerifiableCredentialJws
import at.asitplus.wallet.lib.data.VerifiableCredentialSdJwt
import at.asitplus.wallet.lib.iso.DeviceKeyInfo
import at.asitplus.wallet.lib.iso.IsoDataModelConstants.DIGEST_SHA_256
import at.asitplus.wallet.lib.iso.IsoDataModelConstants.VERSION_1_0
import at.asitplus.wallet.lib.iso.IssuerSigned
import at.asitplus.wallet.lib.iso.IssuerSignedList
import at.asitplus.wallet.lib.iso.MobileSecurityObject
Expand Down Expand Up @@ -148,8 +146,8 @@ class IssuerAgent(
failed = listOf(Issuer.FailedAttribute(scheme.vcType, DataSourceProblem("vcId internal mismatch")))
).also { Napier.w("Got no statusListIndex from issuerCredentialStore, can't issue credential") }
val mso = MobileSecurityObject(
version = VERSION_1_0,
digestAlgorithm = DIGEST_SHA_256,
version = "1.0",
digestAlgorithm = "SHA-256",
valueDigests = mapOf(
scheme.isoNamespace to ValueDigestList(credential.issuerSignedItems.map {
ValueDigest.fromIssuerSigned(it)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -523,23 +523,6 @@ data class DeviceSigned(
}
}

// TODO see if we really need this class
data class DeviceNameSpaces(
@SerialName("org.iso.18013.5.1")
val entries: Map<String, ElementValue>
) {
fun serialize() = cborSerializer.encodeToByteArray(this)

companion object {
fun deserialize(it: ByteArray) = kotlin.runCatching {
cborSerializer.decodeFromByteArray<DeviceNameSpaces>(it)
}.getOrElse {
Napier.w("deserialize failed", it)
null
}
}
}


/**
* Part of the ISO/IEC 18013-5:2021 standard: Data structure for mdoc request (8.3.2.1.2.1)
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -2,38 +2,38 @@

package at.asitplus.wallet.lib.iso

import at.asitplus.wallet.lib.iso.IsoDataModelConstants.DataElements.ADMINISTRATIVE_NUMBER
import at.asitplus.wallet.lib.iso.IsoDataModelConstants.DataElements.AGE_BIRTH_YEAR
import at.asitplus.wallet.lib.iso.IsoDataModelConstants.DataElements.AGE_IN_YEARS
import at.asitplus.wallet.lib.iso.IsoDataModelConstants.DataElements.AGE_OVER_18
import at.asitplus.wallet.lib.iso.IsoDataModelConstants.DataElements.BIRTH_DATE
import at.asitplus.wallet.lib.iso.IsoDataModelConstants.DataElements.BIRTH_PLACE
import at.asitplus.wallet.lib.iso.IsoDataModelConstants.DataElements.DOCUMENT_NUMBER
import at.asitplus.wallet.lib.iso.IsoDataModelConstants.DataElements.DRIVING_PRIVILEGES
import at.asitplus.wallet.lib.iso.IsoDataModelConstants.DataElements.EXPIRY_DATE
import at.asitplus.wallet.lib.iso.IsoDataModelConstants.DataElements.EYE_COLOUR
import at.asitplus.wallet.lib.iso.IsoDataModelConstants.DataElements.FAMILY_NAME
import at.asitplus.wallet.lib.iso.IsoDataModelConstants.DataElements.FAMILY_NAME_NATIONAL_CHARACTER
import at.asitplus.wallet.lib.iso.IsoDataModelConstants.DataElements.GIVEN_NAME
import at.asitplus.wallet.lib.iso.IsoDataModelConstants.DataElements.GIVEN_NAME_NATIONAL_CHARACTER
import at.asitplus.wallet.lib.iso.IsoDataModelConstants.DataElements.HAIR_COLOUR
import at.asitplus.wallet.lib.iso.IsoDataModelConstants.DataElements.HEIGHT
import at.asitplus.wallet.lib.iso.IsoDataModelConstants.DataElements.ISSUE_DATE
import at.asitplus.wallet.lib.iso.IsoDataModelConstants.DataElements.ISSUING_AUTHORITY
import at.asitplus.wallet.lib.iso.IsoDataModelConstants.DataElements.ISSUING_COUNTRY
import at.asitplus.wallet.lib.iso.IsoDataModelConstants.DataElements.ISSUING_JURISDICTION
import at.asitplus.wallet.lib.iso.IsoDataModelConstants.DataElements.NATIONALITY
import at.asitplus.wallet.lib.iso.IsoDataModelConstants.DataElements.PORTRAIT
import at.asitplus.wallet.lib.iso.IsoDataModelConstants.DataElements.PORTRAIT_CAPTURE_DATE
import at.asitplus.wallet.lib.iso.IsoDataModelConstants.DataElements.RESIDENT_ADDRESS
import at.asitplus.wallet.lib.iso.IsoDataModelConstants.DataElements.RESIDENT_CITY
import at.asitplus.wallet.lib.iso.IsoDataModelConstants.DataElements.RESIDENT_COUNTRY
import at.asitplus.wallet.lib.iso.IsoDataModelConstants.DataElements.RESIDENT_POSTAL_CODE
import at.asitplus.wallet.lib.iso.IsoDataModelConstants.DataElements.RESIDENT_STATE
import at.asitplus.wallet.lib.iso.IsoDataModelConstants.DataElements.SEX
import at.asitplus.wallet.lib.iso.IsoDataModelConstants.DataElements.SIGNATURE_USUAL_MARK
import at.asitplus.wallet.lib.iso.IsoDataModelConstants.DataElements.UN_DISTINGUISHING_SIGN
import at.asitplus.wallet.lib.iso.IsoDataModelConstants.DataElements.WEIGHT
import at.asitplus.wallet.lib.iso.MobileDrivingLicenceDataElements.ADMINISTRATIVE_NUMBER
import at.asitplus.wallet.lib.iso.MobileDrivingLicenceDataElements.AGE_BIRTH_YEAR
import at.asitplus.wallet.lib.iso.MobileDrivingLicenceDataElements.AGE_IN_YEARS
import at.asitplus.wallet.lib.iso.MobileDrivingLicenceDataElements.AGE_OVER_18
import at.asitplus.wallet.lib.iso.MobileDrivingLicenceDataElements.BIRTH_DATE
import at.asitplus.wallet.lib.iso.MobileDrivingLicenceDataElements.BIRTH_PLACE
import at.asitplus.wallet.lib.iso.MobileDrivingLicenceDataElements.DOCUMENT_NUMBER
import at.asitplus.wallet.lib.iso.MobileDrivingLicenceDataElements.DRIVING_PRIVILEGES
import at.asitplus.wallet.lib.iso.MobileDrivingLicenceDataElements.EXPIRY_DATE
import at.asitplus.wallet.lib.iso.MobileDrivingLicenceDataElements.EYE_COLOUR
import at.asitplus.wallet.lib.iso.MobileDrivingLicenceDataElements.FAMILY_NAME
import at.asitplus.wallet.lib.iso.MobileDrivingLicenceDataElements.FAMILY_NAME_NATIONAL_CHARACTER
import at.asitplus.wallet.lib.iso.MobileDrivingLicenceDataElements.GIVEN_NAME
import at.asitplus.wallet.lib.iso.MobileDrivingLicenceDataElements.GIVEN_NAME_NATIONAL_CHARACTER
import at.asitplus.wallet.lib.iso.MobileDrivingLicenceDataElements.HAIR_COLOUR
import at.asitplus.wallet.lib.iso.MobileDrivingLicenceDataElements.HEIGHT
import at.asitplus.wallet.lib.iso.MobileDrivingLicenceDataElements.ISSUE_DATE
import at.asitplus.wallet.lib.iso.MobileDrivingLicenceDataElements.ISSUING_AUTHORITY
import at.asitplus.wallet.lib.iso.MobileDrivingLicenceDataElements.ISSUING_COUNTRY
import at.asitplus.wallet.lib.iso.MobileDrivingLicenceDataElements.ISSUING_JURISDICTION
import at.asitplus.wallet.lib.iso.MobileDrivingLicenceDataElements.NATIONALITY
import at.asitplus.wallet.lib.iso.MobileDrivingLicenceDataElements.PORTRAIT
import at.asitplus.wallet.lib.iso.MobileDrivingLicenceDataElements.PORTRAIT_CAPTURE_DATE
import at.asitplus.wallet.lib.iso.MobileDrivingLicenceDataElements.RESIDENT_ADDRESS
import at.asitplus.wallet.lib.iso.MobileDrivingLicenceDataElements.RESIDENT_CITY
import at.asitplus.wallet.lib.iso.MobileDrivingLicenceDataElements.RESIDENT_COUNTRY
import at.asitplus.wallet.lib.iso.MobileDrivingLicenceDataElements.RESIDENT_POSTAL_CODE
import at.asitplus.wallet.lib.iso.MobileDrivingLicenceDataElements.RESIDENT_STATE
import at.asitplus.wallet.lib.iso.MobileDrivingLicenceDataElements.SEX
import at.asitplus.wallet.lib.iso.MobileDrivingLicenceDataElements.SIGNATURE_USUAL_MARK
import at.asitplus.wallet.lib.iso.MobileDrivingLicenceDataElements.UN_DISTINGUISHING_SIGN
import at.asitplus.wallet.lib.iso.MobileDrivingLicenceDataElements.WEIGHT
import at.asitplus.wallet.lib.jws.ByteArrayBase64UrlSerializer
import io.github.aakira.napier.Napier
import io.matthewnelson.encoding.base16.Base16
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,73 @@
package at.asitplus.wallet.lib.iso

object MobileDrivingLicenceDataElements {

const val FAMILY_NAME = "family_name"
const val GIVEN_NAME = "given_name"
const val BIRTH_DATE = "birth_date"
const val ISSUE_DATE = "issue_date"
const val EXPIRY_DATE = "expiry_date"
const val ISSUING_COUNTRY = "issuing_country"
const val ISSUING_AUTHORITY = "issuing_authority"
const val DOCUMENT_NUMBER = "document_number"
const val PORTRAIT = "portrait"
const val DRIVING_PRIVILEGES = "driving_privileges"
const val UN_DISTINGUISHING_SIGN = "un_distinguishing_sign"
const val ADMINISTRATIVE_NUMBER = "administrative_number"
const val SEX = "sex"
const val HEIGHT = "height"
const val WEIGHT = "weight"
const val EYE_COLOUR = "eye_colour"
const val HAIR_COLOUR = "hair_colour"
const val BIRTH_PLACE = "birth_place"
const val RESIDENT_ADDRESS = "resident_address"
const val PORTRAIT_CAPTURE_DATE = "portrait_capture_date"
const val AGE_IN_YEARS = "age_in_years"
const val AGE_BIRTH_YEAR = "age_birth_year"
const val AGE_OVER_18 = "age_over_18"
const val ISSUING_JURISDICTION = "issuing_jurisdiction"
const val NATIONALITY = "nationality"
const val RESIDENT_CITY = "resident_city"
const val RESIDENT_STATE = "resident_state"
const val RESIDENT_POSTAL_CODE = "resident_postal_code"
const val RESIDENT_COUNTRY = "resident_country"
const val FAMILY_NAME_NATIONAL_CHARACTER = "family_name_national_character"
const val GIVEN_NAME_NATIONAL_CHARACTER = "given_name_national_character"
const val SIGNATURE_USUAL_MARK = "signature_usual_mark"

val ALL_ELEMENTS = listOf(
FAMILY_NAME,
GIVEN_NAME,
BIRTH_DATE,
ISSUE_DATE,
EXPIRY_DATE,
ISSUING_COUNTRY,
ISSUING_AUTHORITY,
DOCUMENT_NUMBER,
PORTRAIT,
DRIVING_PRIVILEGES,
UN_DISTINGUISHING_SIGN,
ADMINISTRATIVE_NUMBER,
SEX,
HEIGHT,
WEIGHT,
EYE_COLOUR,
HAIR_COLOUR,
BIRTH_PLACE,
RESIDENT_ADDRESS,
PORTRAIT_CAPTURE_DATE,
AGE_IN_YEARS,
AGE_BIRTH_YEAR,
AGE_OVER_18,
ISSUING_JURISDICTION,
NATIONALITY,
RESIDENT_CITY,
RESIDENT_STATE,
RESIDENT_POSTAL_CODE,
RESIDENT_COUNTRY,
FAMILY_NAME_NATIONAL_CHARACTER,
GIVEN_NAME_NATIONAL_CHARACTER,
SIGNATURE_USUAL_MARK,
)

}
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,12 @@ package at.asitplus.wallet.lib.iso
import at.asitplus.wallet.lib.cbor.CoseSigned
import at.asitplus.wallet.lib.data.ConstantIndex
import at.asitplus.wallet.lib.data.jsonSerializer
import at.asitplus.wallet.lib.iso.IsoDataModelConstants.DataElements.DOCUMENT_NUMBER
import at.asitplus.wallet.lib.iso.IsoDataModelConstants.DataElements.DRIVING_PRIVILEGES
import at.asitplus.wallet.lib.iso.IsoDataModelConstants.DataElements.EXPIRY_DATE
import at.asitplus.wallet.lib.iso.IsoDataModelConstants.DataElements.FAMILY_NAME
import at.asitplus.wallet.lib.iso.IsoDataModelConstants.DataElements.ISSUE_DATE
import at.asitplus.wallet.lib.iso.IsoDataModelConstants.DataElements.PORTRAIT
import at.asitplus.wallet.lib.iso.MobileDrivingLicenceDataElements.DOCUMENT_NUMBER
import at.asitplus.wallet.lib.iso.MobileDrivingLicenceDataElements.DRIVING_PRIVILEGES
import at.asitplus.wallet.lib.iso.MobileDrivingLicenceDataElements.EXPIRY_DATE
import at.asitplus.wallet.lib.iso.MobileDrivingLicenceDataElements.FAMILY_NAME
import at.asitplus.wallet.lib.iso.MobileDrivingLicenceDataElements.ISSUE_DATE
import at.asitplus.wallet.lib.iso.MobileDrivingLicenceDataElements.PORTRAIT
import io.kotest.core.spec.style.FreeSpec
import io.kotest.matchers.collections.shouldContain
import io.kotest.matchers.nulls.shouldNotBeNull
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,13 +8,13 @@ import at.asitplus.wallet.lib.cbor.CoseSigned
import at.asitplus.wallet.lib.cbor.DefaultCoseService
import at.asitplus.wallet.lib.cbor.DefaultVerifierCoseService
import at.asitplus.wallet.lib.data.ConstantIndex
import at.asitplus.wallet.lib.iso.IsoDataModelConstants.DataElements.DOCUMENT_NUMBER
import at.asitplus.wallet.lib.iso.IsoDataModelConstants.DataElements.DRIVING_PRIVILEGES
import at.asitplus.wallet.lib.iso.IsoDataModelConstants.DataElements.EXPIRY_DATE
import at.asitplus.wallet.lib.iso.IsoDataModelConstants.DataElements.FAMILY_NAME
import at.asitplus.wallet.lib.iso.IsoDataModelConstants.DataElements.GIVEN_NAME
import at.asitplus.wallet.lib.iso.IsoDataModelConstants.DataElements.ISSUE_DATE
import at.asitplus.wallet.lib.iso.IsoDataModelConstants.DataElements.PORTRAIT
import at.asitplus.wallet.lib.iso.MobileDrivingLicenceDataElements.DOCUMENT_NUMBER
import at.asitplus.wallet.lib.iso.MobileDrivingLicenceDataElements.DRIVING_PRIVILEGES
import at.asitplus.wallet.lib.iso.MobileDrivingLicenceDataElements.EXPIRY_DATE
import at.asitplus.wallet.lib.iso.MobileDrivingLicenceDataElements.FAMILY_NAME
import at.asitplus.wallet.lib.iso.MobileDrivingLicenceDataElements.GIVEN_NAME
import at.asitplus.wallet.lib.iso.MobileDrivingLicenceDataElements.ISSUE_DATE
import at.asitplus.wallet.lib.iso.MobileDrivingLicenceDataElements.PORTRAIT
import io.kotest.core.spec.style.FreeSpec
import io.kotest.matchers.nulls.shouldBeNull
import io.kotest.matchers.nulls.shouldNotBeNull
Expand Down
Loading

0 comments on commit 061b926

Please sign in to comment.