Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Draft: Add GaiaxSD template #1

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ dependencies {
implementation("com.google.guava:guava:31.0.1-jre")

// VC
implementation("id.walt:waltid-ssikit-vclib:1.5-SNAPSHOT")
implementation("id.walt:waltid-ssikit-vclib:1.6-SNAPSHOT")

// JSON
implementation("org.json:json:20210307")
Expand Down
1 change: 1 addition & 0 deletions src/main/kotlin/id/walt/auditor/PolicyRegistry.kt
Original file line number Diff line number Diff line change
Expand Up @@ -22,5 +22,6 @@ object PolicyRegistry {
register(ValidFromBeforePolicy())
register(ExpirationDateAfterPolicy())
register(GaiaxTrustedPolicy())
register(GaiaxSDPolicy())
}
}
8 changes: 8 additions & 0 deletions src/main/kotlin/id/walt/auditor/VerificationPolicy.kt
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ 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 @@ -200,6 +201,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) {
Expand Down
29 changes: 29 additions & 0 deletions src/main/kotlin/id/walt/signatory/CLIDataProvider.kt
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package id.walt.signatory

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


class GaiaxSDProvider : CLIDataProvider() {
override fun populate(template: VerifiableCredential, proofConfig: ProofConfig): VerifiableCredential {
(template as GaiaxSD).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
Expand Down
14 changes: 14 additions & 0 deletions src/main/kotlin/id/walt/signatory/SignatoryDataProvider.kt
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ object DataProviderRegistry {
register(VerifiableId::class, VerifiableIdDataProvider())
register(Europass::class, EuropassDataProvider())
register(GaiaxCredential::class, DeltaDaoDataProvider())
register(GaiaxSD::class, SdDataProvider())
register(PermanentResidentCard::class, PermanentResidentCardDataProvider())
}
}
Expand Down Expand Up @@ -118,6 +119,19 @@ class NoSuchDataProviderException(credentialType: KClass<out VerifiableCredentia
Exception("No data provider is registered for ${credentialType.simpleName}")



class SdDataProvider : SignatoryDataProvider {

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


class DeltaDaoDataProvider : SignatoryDataProvider {
override fun populate(template: VerifiableCredential, proofConfig: ProofConfig): VerifiableCredential {
if (template is GaiaxCredential) {
Expand Down