Skip to content

Commit

Permalink
Included GaiaxSelfDescription cred
Browse files Browse the repository at this point in the history
  • Loading branch information
philpotisk committed Nov 30, 2021
1 parent 001de31 commit 2c42b35
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 13 deletions.
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
11 changes: 5 additions & 6 deletions src/main/kotlin/id/walt/auditor/VerificationPolicy.kt
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@ import id.walt.vclib.Helpers.encode
import id.walt.vclib.VcUtils
import id.walt.vclib.credentials.GaiaxCredential
import id.walt.vclib.credentials.VerifiablePresentation
import id.walt.vclib.credentials.GaiaxSD
import id.walt.vclib.model.VerifiableCredential
import id.walt.vclib.schema.SchemaService
import kotlinx.serialization.Serializable
Expand Down Expand Up @@ -69,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
}
Expand Down Expand Up @@ -128,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
}
}
Expand Down Expand Up @@ -187,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
}
Expand Down
6 changes: 3 additions & 3 deletions src/main/kotlin/id/walt/signatory/CLIDataProvider.kt
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
package id.walt.signatory

import id.walt.vclib.model.VerifiableCredential
import id.walt.vclib.credentials.GaiaxSD
import id.walt.vclib.credentials.GaiaxSelfDescription
import id.walt.vclib.credentials.GaiaxCredential
import id.walt.vclib.credentials.VerifiableDiploma
import id.walt.vclib.credentials.VerifiableId
Expand All @@ -13,7 +13,7 @@ object CLIDataProviders {
"VerifiableDiploma" -> VerifiableDiplomaCLIDataProvider()
"VerifiableId" -> VerifiableIDCLIDataProvider()
"GaiaxCredential" -> GaiaxCLIDataProvider()
"GaiaxSD" -> GaiaxSDProvider()
"GaiaxSelfDescription" -> GaiaxSDProvider()
else -> null
}
}
Expand Down Expand Up @@ -188,7 +188,7 @@ class GaiaxCLIDataProvider : CLIDataProvider() {

class GaiaxSDProvider : CLIDataProvider() {
override fun populate(template: VerifiableCredential, proofConfig: ProofConfig): VerifiableCredential {
(template as GaiaxSD).apply {
(template as GaiaxSelfDescription).apply {
println()
println("> Subject information")
println()
Expand Down
8 changes: 4 additions & 4 deletions src/main/kotlin/id/walt/signatory/SignatoryDataProvider.kt
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ object DataProviderRegistry {
register(VerifiableId::class, VerifiableIdDataProvider())
register(Europass::class, EuropassDataProvider())
register(GaiaxCredential::class, DeltaDaoDataProvider())
register(GaiaxSD::class, SdDataProvider())
register(GaiaxSelfDescription::class, SdDataProvider())
register(PermanentResidentCard::class, PermanentResidentCardDataProvider())
}
}
Expand Down Expand Up @@ -122,11 +122,11 @@ class NoSuchDataProviderException(credentialType: KClass<out VerifiableCredentia

class SdDataProvider : SignatoryDataProvider {

override fun populate(template: VerifiableCredential, proofConfig: ProofConfig): GaiaxSD {
val vc = template as GaiaxSD
override fun populate(template: VerifiableCredential, proofConfig: ProofConfig): GaiaxSelfDescription {
val vc = template as GaiaxSelfDescription
vc.id = proofConfig.credentialId
vc.issuer = proofConfig.issuerDid
vc.credentialSubject!!.id = proofConfig.subjectDid!!
vc.credentialSubject.id = proofConfig.subjectDid!!
return vc
}
}
Expand Down

0 comments on commit 2c42b35

Please sign in to comment.