-
Notifications
You must be signed in to change notification settings - Fork 35
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: status list 2021 entry - check revocation (#294)
- Loading branch information
Showing
20 changed files
with
337 additions
and
68 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
35 changes: 35 additions & 0 deletions
35
src/main/kotlin/id/walt/model/credential/status/CredentialStatusModels.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
package id.walt.model.credential.status | ||
|
||
import com.beust.klaxon.TypeAdapter | ||
import com.beust.klaxon.TypeFor | ||
import kotlinx.serialization.Serializable | ||
import kotlin.reflect.KClass | ||
|
||
@Serializable | ||
@TypeFor(field = "type", adapter = CredentialStatusTypeAdapter::class) | ||
sealed class CredentialStatus( | ||
val type: String, | ||
) { | ||
abstract val id: String | ||
} | ||
|
||
@Serializable | ||
class SimpleCredentialStatus2022( | ||
override val id: String, | ||
) : CredentialStatus("SimpleCredentialStatus2022") | ||
|
||
@Serializable | ||
data class StatusList2021EntryCredentialStatus( | ||
override val id: String, | ||
val statusPurpose: String, | ||
val statusListIndex: String, | ||
val statusListCredential: String, | ||
) : CredentialStatus("StatusList2021Entry") | ||
|
||
class CredentialStatusTypeAdapter : TypeAdapter<CredentialStatus> { | ||
override fun classFor(type: Any): KClass<out CredentialStatus> = when (type as String) { | ||
"SimpleCredentialStatus2022" -> SimpleCredentialStatus2022::class | ||
"StatusList2021Entry" -> StatusList2021EntryCredentialStatus::class | ||
else -> throw IllegalArgumentException("CredentialStatus type is not supported: $type") | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
52 changes: 52 additions & 0 deletions
52
src/main/kotlin/id/walt/signatory/revocation/RevocationService.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
package id.walt.signatory.revocation | ||
|
||
import com.beust.klaxon.Json | ||
import id.walt.model.credential.status.StatusList2021EntryCredentialStatus | ||
import kotlinx.serialization.Serializable | ||
|
||
interface RevocationService { | ||
fun checkRevocation(parameter: RevocationParameter): RevocationResult | ||
fun getRevocation(): RevocationData | ||
fun clearAll() | ||
fun setRevocation(parameter: RevocationParameter) | ||
} | ||
|
||
data class RevocationList(val revokedList: List<RevocationResult>) | ||
|
||
/* | ||
Revocation results | ||
*/ | ||
@Serializable | ||
abstract class RevocationResult { | ||
abstract val isRevoked: Boolean | ||
} | ||
|
||
@Serializable | ||
data class TokenRevocationResult( | ||
val token: String, | ||
override val isRevoked: Boolean, | ||
@Json(serializeNull = false) | ||
val timeOfRevocation: Long? = null | ||
) : RevocationResult() | ||
|
||
@Serializable | ||
data class StatusListRevocationResult( | ||
override val isRevoked: Boolean | ||
) : RevocationResult() | ||
|
||
/* | ||
Revocation parameters | ||
*/ | ||
interface RevocationParameter | ||
data class TokenRevocationParameter( | ||
val token: String, | ||
) : RevocationParameter | ||
|
||
data class StatusListRevocationParameter( | ||
val credentialStatus: StatusList2021EntryCredentialStatus, | ||
) : RevocationParameter | ||
|
||
/* | ||
Revocation data | ||
*/ | ||
interface RevocationData |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.