Skip to content

Commit

Permalink
CredentialTypeRepository with it's content
Browse files Browse the repository at this point in the history
  • Loading branch information
keesgeluk committed Nov 15, 2023
1 parent 60fcadc commit 2c4ce10
Show file tree
Hide file tree
Showing 23 changed files with 441 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
package com.android.identity.credentialtype

interface CredentialAttribute {
val type: CredentialAttributeType
val identifier: String
val displayName: String
val description: String
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
package com.android.identity.credentialtype

enum class CredentialAttributeType {
STRING,
NUMBER,
DATE,
DATE_TIME,
PICTURE,
BOOLEAN,
CBOR,
JSON
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
package com.android.identity.credentialtype

import com.android.identity.credentialtype.mdoc.MdocCredentialType
import com.android.identity.credentialtype.vc.VcCredentialType

interface CredentialType {
val displayName: String
val attributes: List<CredentialAttribute>
val mdocCredentialType: MdocCredentialType?
val vcCredentialType: VcCredentialType?
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
package com.android.identity.credentialtype

object CredentialTypeRepository {
private val credentialTypes: MutableList<CredentialType> = mutableListOf()
init {
addCredentialType(DrivingLicense)
addCredentialType(VehicleRegistration)
addCredentialType(VaccinationDocument)
addCredentialType(EUPersonalID)
}

fun addCredentialType(credentialType: CredentialType){
credentialTypes.add(credentialType)
}
fun getCredentialTypes(): List<CredentialType>{
return credentialTypes
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
package com.android.identity.credentialtype

import com.android.identity.credentialtype.mdoc.MdocDrivingLicense
import com.android.identity.credentialtype.vc.VcDrivingLicense

object DrivingLicense: CredentialType {
override val displayName = "Driving License"
override val attributes: List<CredentialAttribute> = emptyList() // TODO: what should be expected here?
override val mdocCredentialType = MdocDrivingLicense
override val vcCredentialType = VcDrivingLicense
}

Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
package com.android.identity.credentialtype

import com.android.identity.credentialtype.mdoc.MdocEUPersonalID
import com.android.identity.credentialtype.vc.VcCredentialType

object EUPersonalID: CredentialType {
override val displayName = "EU Personal ID"
override val attributes: List<CredentialAttribute> = emptyList() // TODO: what should be expected here?
override val mdocCredentialType = MdocEUPersonalID
override val vcCredentialType: VcCredentialType? = null
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
package com.android.identity.credentialtype

import com.android.identity.credentialtype.mdoc.MdocVaccinationDocument
import com.android.identity.credentialtype.vc.VcCredentialType

object VaccinationDocument: CredentialType {
override val displayName = "Vaccination Document"
override val attributes: List<CredentialAttribute> = emptyList() // TODO: what should be expected here?
override val mdocCredentialType = MdocVaccinationDocument
override val vcCredentialType: VcCredentialType? = null
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
package com.android.identity.credentialtype

import com.android.identity.credentialtype.mdoc.MdocVehicleRegistration
import com.android.identity.credentialtype.vc.VcCredentialType

object VehicleRegistration : CredentialType {
override val displayName = "Vehicle Registration"
override val attributes: List<CredentialAttribute> = emptyList() // TODO: what should be expected here?
override val mdocCredentialType = MdocVehicleRegistration
override val vcCredentialType: VcCredentialType? = null
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
package com.android.identity.credentialtype.mdoc

abstract class MdocCredentialType {
abstract val docType: String
abstract val namespaces: List<MdocNamespace>

fun getNamespaceByName(namespace: String): MdocNamespace? {
return namespaces.find { it.namespace.equals(namespace, ignoreCase = true) }
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
package com.android.identity.credentialtype.mdoc

import com.android.identity.credentialtype.CredentialAttribute

interface MdocDataElement: CredentialAttribute {
val mandatory: Boolean
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
package com.android.identity.credentialtype.mdoc

object MdocDrivingLicense: MdocCredentialType(){
override val docType= "org.iso.18013.5.1.mDL"
override val namespaces: List<MdocNamespace> = listOf(NamespaceMdl, NamespaceMdlAamva)
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
package com.android.identity.credentialtype.mdoc

object MdocEUPersonalID: MdocCredentialType() {
override val docType = "eu.europa.ec.eudiw.pid.1"
override val namespaces: List<MdocNamespace> = listOf(NamespaceEUPID)
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
package com.android.identity.credentialtype.mdoc

abstract class MdocNamespace {
abstract val namespace: String
abstract val dataElements: List<MdocDataElement>
fun getDataElementByIdentifier(identifier: String): MdocDataElement? {
return dataElements.find { it.identifier.equals(identifier, ignoreCase = true) }
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
package com.android.identity.credentialtype.mdoc

object MdocVaccinationDocument: MdocCredentialType() {
override val docType = "org.micov.1"
override val namespaces: List<MdocNamespace> = listOf(NamespaceMicovAtt, NamespaceMicovVtr)
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
package com.android.identity.credentialtype.mdoc

object MdocVehicleRegistration : MdocCredentialType() {
override val docType = "nl.rdw.mekb.1"
override val namespaces: List<MdocNamespace> = listOf(NamespaceMvr)
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
package com.android.identity.credentialtype.mdoc

import com.android.identity.credentialtype.CredentialAttributeType

object NamespaceEUPID : MdocNamespace() {
override val namespace = "eu.europa.ec.eudiw.pid.1"
override val dataElements: List<MdocDataElement> = Element.values().asList()

// TODO: check description/mandatory
enum class Element(
override val type: CredentialAttributeType,
override val identifier: String,
override val displayName: String,
override val description: String,
override val mandatory: Boolean
) : MdocDataElement {
FAMILY_NAME(CredentialAttributeType.STRING,"family_name", "Family Name", "Family Name", true),
FAMILY_NAME_NATIONAL_CHARACTER(CredentialAttributeType.STRING,"family_name_national_characters","Family name in national characters", "Family name in national characters", true),
GIVEN_NAMES(CredentialAttributeType.STRING,"given_name", "Given Names", "Given Names", true),
GIVEN_NAME_NATIONAL_CHARACTER(CredentialAttributeType.STRING,"given_name_national_characters", "Given name in national characters", "Given name in national characters", true),
BIRTH_DATE(CredentialAttributeType.DATE,"birth_date", "Date of birth", "Date of birth", true),
UNIQUE_IDENTIFIER(CredentialAttributeType.STRING,"persistent_id", "Unique Identifier", "Unique Identifier", true),
BIRTH_FAMILY_NAME(CredentialAttributeType.STRING,"family_name_birth", "Family Name at Birth", "Family Name at Birth", true),
BIRTH_FAMILY_NAME_NATIONAL_CHARACTERS(CredentialAttributeType.STRING,"family_name_birth_national_characters", "Family Name at Birth in national characters", "Family Name at Birth in national characters", true),
BIRTH_FIRST_NAME(CredentialAttributeType.STRING,"given_name_birth", "First Name at Birth", "First Name at Birth", true),
BIRTH_FIRST_NAME_NATIONAL_CHARACTERS(CredentialAttributeType.STRING,"given_name_birth_national_characters", "First Name at Birth in national characters", "First Name at Birth in national characters", true),
BIRTH_PLACE(CredentialAttributeType.STRING,"birth_place", "Place of birth", "Place of birth", true),
RESIDENT_ADDRESS(CredentialAttributeType.STRING,"resident_address", "Permanent place of residence", "Permanent place of residence", true),
RESIDENT_POSTAL_CODE(CredentialAttributeType.STRING,"resident_postal_code", "Resident postal code", "Resident postal code", true),
RESIDENT_CITY(CredentialAttributeType.STRING,"resident_city", "Resident city", "Resident city", true),
RESIDENT_STATE(CredentialAttributeType.STRING,"resident_state", "Resident state", "Resident state", true),
RESIDENT_COUNTRY(CredentialAttributeType.STRING,"resident_country", "Resident country", "Resident country", true),
GENDER(CredentialAttributeType.STRING,"gender", "Gender", "Gender", true),
NATIONALITY(CredentialAttributeType.STRING,"nationality", "Nationality", "Nationality", true),
PORTRAIT(CredentialAttributeType.PICTURE,"portrait", "FacialImage/Portrait", "FacialImage/Portrait", true),
PORTRAIT_CAPTURE_DATE(CredentialAttributeType.DATE,"portrait_capture_date", "Portrait image timestamp", "Portrait image timestamp", true),
BIOMETRIC_TEMPLATE_FINGER(CredentialAttributeType.PICTURE,"biometric_template_finger", "Fingerprint", "Fingerprint", true),
AGE_OVER_13(CredentialAttributeType.BOOLEAN,"age_over_13", "Age over 13?", "Age over 13?", true),
AGE_OVER_16(CredentialAttributeType.BOOLEAN,"age_over_16", "Age over 16?", "Age over 16?", true),
AGE_OVER_18(CredentialAttributeType.BOOLEAN,"age_over_18", "Age over 18?", "Age over 18?", true),
AGE_OVER_21(CredentialAttributeType.BOOLEAN,"age_over_21", "Age over 21?", "Age over 21?", true),
AGE_OVER_60(CredentialAttributeType.BOOLEAN,"age_over_60", "Age over 60?", "Age over 60?", true),
AGE_OVER_65(CredentialAttributeType.BOOLEAN,"age_over_65", "Age over 65?", "Age over 65?", true),
AGE_OVER_68(CredentialAttributeType.BOOLEAN,"age_over_68", "Age over 68?", "Age over 68?", true),
AGE_IN_YEARS(CredentialAttributeType.NUMBER,"age_in_years", "How old are you (in years)?", "How old are you (in years)?", true),
AGE_BIRTH_YEAR(CredentialAttributeType.NUMBER,"age_birth_year", "In what year were you born?", "In what year were you born?", true),
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
package com.android.identity.credentialtype.mdoc

import com.android.identity.credentialtype.CredentialAttributeType

object NamespaceMdl: MdocNamespace(){
override val namespace: String = "org.iso.18013.5.1"
override val dataElements: List<MdocDataElement> = Element.values().asList()

enum class Element(
override val type: CredentialAttributeType,
override val identifier: String,
override val displayName: String,
override val description: String,
override val mandatory: Boolean): MdocDataElement {
FAMILY_NAME(CredentialAttributeType.STRING, "family_name", "Family name", "Last name, surname, or primary identifier, of the mDL holder.", true),
GIVEN_NAME(CredentialAttributeType.STRING, "given_name", "Given names", "First name(s), other name(s), or secondary identifier, of the mDL holder", true),
BIRTH_DATE(CredentialAttributeType.DATE, "birth_date", "Date of birth", "Day, month and year on which the mDL holder was born. If unknown, approximate date of birth", true),
ISSUE_DATE(CredentialAttributeType.DATE, "issue_date", "Date of issue", "Date when mDL was issued", true),
EXPIRY_DATE(CredentialAttributeType.DATE,"expiry_date", "Date of expiry", "Date when mDL expires", true),
ISSUING_COUNTRY(CredentialAttributeType.STRING, "issuing_country", "Issuing country", "Alpha-2 country code, as defined in ISO 3166-1, of the issuing authority’s country or territory", true),
ISSUING_AUTHORITY(CredentialAttributeType.STRING, "issuing_authority", "Issuing authority", "Issuing authority name.", true),
DOCUMENT_NUMBER(CredentialAttributeType.STRING, "document_number", "Licence number", "The number assigned or calculated by the issuing authority.", true),
PORTRAIT(CredentialAttributeType.PICTURE, "portrait", "Portrait of mDL holder", "A reproduction of the mDL holder’s portrait.", true),
DRIVING_PRIVILEGES(CredentialAttributeType.CBOR,"driving_privileges", "Categories of vehicles/ restrictions/ conditions", "Driving privileges of the mDL holder", true),
UN_DISTINGUISHING_SIGN(CredentialAttributeType.STRING, "un_distinguishing_sign", "UN distinguishing sign","Distinguishing sign of the issuing country", true),
ADMINISTRATIVE_NUMBER(CredentialAttributeType.STRING, "administrative_number", "Administrative number", "An audit control number assigned by the issuing authority", false),
SEX(CredentialAttributeType.NUMBER, "sex", "Sex", "mDL holder’s sex", false),
HEIGHT(CredentialAttributeType.NUMBER, "heigh", "Height (cm)", "mDL holder’s height in centimetres", false),
WEIGHT(CredentialAttributeType.NUMBER, "weight", "Weight (kg)", "mDL holder’s weight in kilograms", false),
EYE_COLOUR(CredentialAttributeType.STRING, "eye_colour", "Eye colour", "mDL holder’s eye colour. The value shall be one of the following: 'black', 'blue', 'brown', 'dichromatic', 'grey', 'green', 'hazel', 'maroon', 'pink', 'unknown'", false),
HAIR_COLOUR(CredentialAttributeType.STRING, "hair_colour", "Hair colour", "mDL holder’s hair colour. The value shall be one of the following: 'bald', 'black', 'blond', 'brown', 'grey', 'red', 'auburn', 'sandy', 'white', 'unknown'", false),
BIRTH_PLACE(CredentialAttributeType.STRING, "birth_place", "Place of birth", "Country and municipality or state/province where the mDL holder was born", false),
RESIDENT_ADDRESS(CredentialAttributeType.STRING, "resident_address", "Permanent place of residence", "The place where the mDL holder resides and/or may be contacted (street/house number, municipality etc.)", false),
PORTRAIT_CAPTURE_DATE(CredentialAttributeType.DATE, "portrait_capture_date", "Portrait image timestamp", "Date when portrait was taken", false),
AGE_IN_YEARS(CredentialAttributeType.NUMBER, "age_in_years", "Age attestation: How old are you (in years)?", "The age of the mDL holder", false),
AGE_BIRTH_YEAR(CredentialAttributeType.NUMBER, "age_birth_year", "Age attestation: In what year were you born?", "The year when the mDL holder was born", false),
AGE_OVER_18(CredentialAttributeType.BOOLEAN, "age_over_18", "Age attestation: are you older than 18 years", "Indication wheter the mDL holder is as old or older than 18", false),
AGE_OVER_21(CredentialAttributeType.BOOLEAN, "age_over_21", "Age attestation: are you older than 21 years", "Indication wheter the mDL holder is as old or older than 21", false),
AGE_OVER_23(CredentialAttributeType.BOOLEAN, "age_over_23", "Age attestation: are you older than 23 years", "Indication wheter the mDL holder is as old or older than 23", false),
AGE_OVER_25(CredentialAttributeType.BOOLEAN, "age_over_25", "Age attestation: are you older than 25 years", "Indication wheter the mDL holder is as old or older than 25", false),
AGE_OVER_62(CredentialAttributeType.BOOLEAN, "age_over_62", "Age attestation: are you older than 62 years", "Indication wheter the mDL holder is as old or older than 62", false),
AGE_OVER_65(CredentialAttributeType.BOOLEAN, "age_over_65", "Age attestation: are you older than 65 years", "Indication wheter the mDL holder is as old or older than 65", false),
ISSUING_JURISDICTION(CredentialAttributeType.STRING, "issuing_jurisdiction", "Issuing jurisdiction", "Country subdivision code of the jurisdiction that issued the mDL", false),
NATIONALITY(CredentialAttributeType.STRING, "nationality", "Nationality", "Nationality of the mDL holder", false),
RESIDENT_CITY(CredentialAttributeType.STRING, "resident_city", "Resident city", "The city where the mDL holder lives", false),
RESIDENT_STATE(CredentialAttributeType.STRING, "resident_state", "Resident state/province/district", "The state/province/district where the mDL holder lives", false),
RESIDENT_POSTAL_CODE(CredentialAttributeType.STRING, "resident_postal_code", "Resident postal code", "The postal code of the mDL holder", false),
RESIDENT_COUNTRY(CredentialAttributeType.STRING, "resident_country", "Resident country", "The country where the mDL holder lives", false),
BIOMETRIC_TEMPLATE_FACE(CredentialAttributeType.PICTURE, "biometric_template_face", "Biometric template face", "Facial biometric information of the mDL holder", false),
BIOMETRIC_TEMPLATE_FINGER(CredentialAttributeType.PICTURE, "biometric_template_finger", "Biometric template fingerprint", "Fingerprint of the mDL holder", false),
BIOMETRIC_TEMPLATE_SIGNATURE_SIGN(CredentialAttributeType.PICTURE, "biometric_template_signature_sign", "Biometric template signature/sign", "Signature/sign of the mDL holder", false),
BIOMETRIC_TEMPLATE_IRIS(CredentialAttributeType.PICTURE, "biometric_template_iris", "Biometric template iris", "Iris of the mDL holder", false),
FAMILY_NAME_NATIONAL_CHARACTER(CredentialAttributeType.STRING, "family_name_national_character", "Family name in national characters", "The family name of the mDL holder", false),
GIVEN_NAME_NATIONAL_CHARACTER(CredentialAttributeType.STRING, "given_name_national_character", "Given name in national characters", "The given name of the mDL holder", false),
SIGNATURE_USUAL_MARK(CredentialAttributeType.PICTURE, "signature_usual_mark", "Signature / usual mark", "Image of the signature or usual mark of the mDL holder,", false)
}
}
Loading

0 comments on commit 2c4ce10

Please sign in to comment.