diff --git a/CHANGELOG.md b/CHANGELOG.md index d8e38f14..3734331c 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,6 +4,9 @@ Notable changes since the last release of the [SSI Kit](https://github.com/walt- ## [Unreleased] +- Features + - Added GaiaxSelfDecription credential https://github.com/dNationCloud/waltid-ssikit/pull/1 thx to https://github.com/dNationCloud & https://github.com/matofeder + ## [1.1.0] - 2021-11-25 - Features diff --git a/build.gradle.kts b/build.gradle.kts index e9e082ec..c5cfb80b 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -40,7 +40,7 @@ dependencies { implementation("com.google.guava:guava:31.0.1-jre") // VC - implementation("id.walt:waltid-ssikit-vclib:1.6.0") + implementation("id.walt:waltid-ssikit-vclib:1.6.1") // JSON implementation("org.json:json:20210307") diff --git a/src/main/kotlin/id/walt/auditor/PolicyRegistry.kt b/src/main/kotlin/id/walt/auditor/PolicyRegistry.kt index dd7ff1be..4198bb20 100644 --- a/src/main/kotlin/id/walt/auditor/PolicyRegistry.kt +++ b/src/main/kotlin/id/walt/auditor/PolicyRegistry.kt @@ -22,5 +22,6 @@ object PolicyRegistry { register(ValidFromBeforePolicy()) register(ExpirationDateAfterPolicy()) register(GaiaxTrustedPolicy()) + register(GaiaxSDPolicy()) } } diff --git a/src/main/kotlin/id/walt/auditor/VerificationPolicy.kt b/src/main/kotlin/id/walt/auditor/VerificationPolicy.kt index 67ca91dd..590d2837 100644 --- a/src/main/kotlin/id/walt/auditor/VerificationPolicy.kt +++ b/src/main/kotlin/id/walt/auditor/VerificationPolicy.kt @@ -68,11 +68,11 @@ class JsonSchemaPolicy : VerificationPolicy { override fun verify(vc: VerifiableCredential): Boolean { SchemaService.validateSchema(vc.json!!).apply { - if(valid) + if (valid) return true log.error { "Credential not valid according the json-schema of type ${vc.type}. The validation errors are:" } - errors?.forEach{ error -> log.error { error }} + errors?.forEach { error -> log.error { error } } } return false } @@ -127,7 +127,7 @@ class TrustedIssuerRegistryPolicy : VerificationPolicy { private fun isValidTrustedIssuerRecord(tirRecord: TrustedIssuer): Boolean { for (attribute in tirRecord.attributes) { val attributeInfo = AttributeInfo.from(attribute.body) - if(TIR_TYPE_ATTRIBUTE.equals(attributeInfo?.type) && TIR_NAME_ISSUER.equals(attributeInfo?.name)) { + if (TIR_TYPE_ATTRIBUTE.equals(attributeInfo?.type) && TIR_NAME_ISSUER.equals(attributeInfo?.name)) { return true } } @@ -186,12 +186,12 @@ class GaiaxTrustedPolicy : VerificationPolicy { val gaiaxVc = vc as GaiaxCredential // TODO: validate trusted fields properly - if (gaiaxVc.credentialSubject.DNSpublicKey.length < 0) { + if (gaiaxVc.credentialSubject.DNSpublicKey.length < 1) { log.debug { "DNS Public key not valid." } return false } - if (gaiaxVc.credentialSubject.ethereumAddress.id.length < 0) { + if (gaiaxVc.credentialSubject.ethereumAddress.id.length < 1) { log.debug { "ETH address not valid." } return false } @@ -200,6 +200,13 @@ class GaiaxTrustedPolicy : VerificationPolicy { } } +class GaiaxSDPolicy : VerificationPolicy { + override val description: String = "Verify Gaiax SD fields" + override fun verify(vc: VerifiableCredential): Boolean { + return true + } +} + private fun parseDate(date: String?) = try { dateFormatter.parse(date) } catch (e: Exception) { diff --git a/src/main/kotlin/id/walt/signatory/CLIDataProvider.kt b/src/main/kotlin/id/walt/signatory/CLIDataProvider.kt index 7532a219..414eff01 100644 --- a/src/main/kotlin/id/walt/signatory/CLIDataProvider.kt +++ b/src/main/kotlin/id/walt/signatory/CLIDataProvider.kt @@ -1,6 +1,7 @@ package id.walt.signatory import id.walt.vclib.model.VerifiableCredential +import id.walt.vclib.credentials.GaiaxSelfDescription import id.walt.vclib.credentials.GaiaxCredential import id.walt.vclib.credentials.VerifiableDiploma import id.walt.vclib.credentials.VerifiableId @@ -12,6 +13,7 @@ object CLIDataProviders { "VerifiableDiploma" -> VerifiableDiplomaCLIDataProvider() "VerifiableId" -> VerifiableIDCLIDataProvider() "GaiaxCredential" -> GaiaxCLIDataProvider() + "GaiaxSelfDescription" -> GaiaxSDProvider() else -> null } } @@ -183,6 +185,33 @@ class GaiaxCLIDataProvider : CLIDataProvider() { } } + +class GaiaxSDProvider : CLIDataProvider() { + override fun populate(template: VerifiableCredential, proofConfig: ProofConfig): VerifiableCredential { + (template as GaiaxSelfDescription).apply { + println() + println("> Subject information") + println() + issuer = proofConfig.issuerDid + credentialSubject.apply { + if (proofConfig.subjectDid != null) id = proofConfig.subjectDid + type = prompt("Type", "Service") ?: "" + hasName = prompt("Name", "AIS") ?: "" + description = prompt("Description", "AIS demonstrates machine learning application use case.") ?:"" + hasVersion = prompt("Version", "0.1.0") ?: "" + providedBy = prompt("Provided by", "GAIA-X") ?: "" + hasMarketingImage = prompt("Marketing Image", "https://www.data-infrastructure.eu/GAIAX/Redaktion/EN/Bilder/UseCases/ai-marketplace-for-product-development.jpg?__blob=normal") ?: "" + hasCertifications = listOf(prompt("Certifications", hasCertifications?.get(0)) ?: "") + utilizes = listOf(prompt("Utilizes", utilizes?.get(0)) ?: "") + dependsOn = listOf(prompt("Depends on", dependsOn?.get(0)) ?: "") + } + } + + return template + } +} + + class VerifiableIDCLIDataProvider : CLIDataProvider() { override fun populate(template : VerifiableCredential, proofConfig: ProofConfig): VerifiableCredential { template as VerifiableId diff --git a/src/main/kotlin/id/walt/signatory/SignatoryDataProvider.kt b/src/main/kotlin/id/walt/signatory/SignatoryDataProvider.kt index 4c0c93cb..a65a9dfa 100644 --- a/src/main/kotlin/id/walt/signatory/SignatoryDataProvider.kt +++ b/src/main/kotlin/id/walt/signatory/SignatoryDataProvider.kt @@ -32,6 +32,7 @@ object DataProviderRegistry { register(VerifiableId::class, VerifiableIdDataProvider()) register(Europass::class, EuropassDataProvider()) register(GaiaxCredential::class, DeltaDaoDataProvider()) + register(GaiaxSelfDescription::class, SdDataProvider()) register(PermanentResidentCard::class, PermanentResidentCardDataProvider()) } } @@ -118,6 +119,19 @@ class NoSuchDataProviderException(credentialType: KClasstemplateId, issuerDid, and the subjectDid, are mandatory parameters. All other parameters are optional.

This is a example request, that also demonstrates how to populate the credential with custom data: the

{
" + + " \"templateId\": \"VerifiableId\",
" + + " \"config\": {
" + + "      \"issuerDid\": \"did:ebsi:zuathxHtXTV8psijTjtuZD7\",
" + + "      \"subjectDid\": \"did:key:z6MkwfgBDSMRqXaJtw5DjhkJdDsDmRNSrvrM1L6UMBDtvaSX\"
" + + "      },
" + + " \"credentialData\": {
" + + "      \"credentialSubject\": {
" + + "          \"firstName\": \"Severin\"
" + + "          }
" + + "      }
" + + "}
") }.body().json("200") }