Skip to content

Commit

Permalink
chore: revocation leftovers
Browse files Browse the repository at this point in the history
  • Loading branch information
mikeplotean committed Nov 13, 2023
1 parent d524fd4 commit 202fbdd
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 10 deletions.
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
package id.walt.credentials.w3c.builder

import id.walt.common.asMap
import id.walt.common.createBaseToken
import id.walt.credentials.w3c.*
import id.walt.model.credential.status.CredentialStatus
Expand Down Expand Up @@ -46,7 +45,7 @@ class W3CCredentialBuilderWithCredentialStatus<C : VerifiableCredential, B : Abs
issuer = issuer,
)
}.let {
CredentialStatusFactory.create(it).asMap()
CredentialStatusFactory.create(it)
}.takeIf {
it.isNotEmpty()
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
package id.walt.signatory.revocation

import id.walt.model.credential.status.CredentialStatus
import id.walt.common.asMap
import id.walt.signatory.revocation.simplestatus2022.SimpleCredentialClientService
import id.walt.signatory.revocation.statuslist2021.StatusList2021EntryClientService

object CredentialStatusFactory {
private val simpleStatus = SimpleCredentialClientService()
private val statusList2021 = StatusList2021EntryClientService()
fun create(parameter: CredentialStatusFactoryParameter): CredentialStatus = when (parameter) {
is SimpleStatusFactoryParameter -> simpleStatus.create(parameter)
is StatusListEntryFactoryParameter -> statusList2021.create(parameter)
fun create(parameter: CredentialStatusFactoryParameter): Map<String, Any?> = when (parameter) {
is SimpleStatusFactoryParameter -> simpleStatus.create(parameter).asMap()
is StatusListEntryFactoryParameter -> statusList2021.create(parameter).asMap()
else -> throw IllegalArgumentException("Status type not supported: ${parameter.javaClass.simpleName}")
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,10 +38,20 @@ class StatusList2021EntryClientService: CredentialStatusClientService {
}

override fun revoke(parameter: RevocationConfig): Unit = (parameter as StatusListRevocationConfig).run {
storageService.fetch(this.credentialStatus.statusListCredential)?.let {
extractStatusListCredentialSubject(it)
}?.let {
updateBitString(it.encodedList, this.credentialStatus.statusListIndex, 1)
storageService.fetch(this.credentialStatus.statusListCredential)?.let { credential ->
extractStatusListCredentialSubject(credential)?.encodedList?.let { bitString ->
credential.issuer?.let { issuer ->
issue(
credential.id ?: parameter.credentialStatus.id,
parameter.credentialStatus.statusPurpose,
parameter.credentialStatus.statusListCredential,
issuer.id,
updateBitString(bitString, parameter.credentialStatus.statusListIndex, 1)
)
}
}?.run {
storageService.store(this, parameter.credentialStatus.statusListCredential)
}
}
}

Expand Down

0 comments on commit 202fbdd

Please sign in to comment.