Skip to content

Commit

Permalink
[#329] CredentialStatusPolicy fails with NPE without credentialStatus
Browse files Browse the repository at this point in the history
  • Loading branch information
tdiesler committed Jul 28, 2023
1 parent 2d90242 commit f9c9f3e
Showing 1 changed file with 9 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -50,15 +50,15 @@ class ExpirationDateAfterPolicy : SimpleVerificationPolicy() {
class CredentialStatusPolicy : SimpleVerificationPolicy() {

override val description: String = "Verify by credential status"
override fun doVerify(vc: VerifiableCredential): VerificationPolicyResult = runCatching {
Klaxon().parse<CredentialStatusCredential>(vc.toJson())!!.credentialStatus!!.let { cs ->
RevocationClientService.check(vc).let {
if (!it.isRevoked) VerificationPolicyResult.success()
else failResult(it, cs)
}
}
}.getOrElse {
VerificationPolicyResult.failure(it)
override fun doVerify(vc: VerifiableCredential): VerificationPolicyResult {
val maybeCredentialStatus = Klaxon().parse<CredentialStatusCredential>(vc.toJson())!!.credentialStatus
return maybeCredentialStatus?.let { cs -> runCatching {
RevocationClientService.check(vc).let {
if (!it.isRevoked) VerificationPolicyResult.success()
else failResult(it, cs)
}
}.getOrElse { VerificationPolicyResult.failure(it) }
} ?: VerificationPolicyResult.success()
}

private fun failResult(status: RevocationStatus, cs: CredentialStatus) = when (status) {
Expand Down

0 comments on commit f9c9f3e

Please sign in to comment.