Skip to content
This repository has been archived by the owner on Nov 20, 2023. It is now read-only.

Commit

Permalink
feat: update README.md
Browse files Browse the repository at this point in the history
refactor: structure test issuance provider
  • Loading branch information
severinstampler committed Oct 5, 2023
1 parent 8ba985b commit 5f7b3b2
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 4 deletions.
10 changes: 10 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -111,6 +111,16 @@ https://github.com/walt-id/waltid-openid4vc/blob/bd9374826d7acbd0d77d15cd2a81098

#### Business logic

For the business logic, implement the abstract issuance provider in `src/commonMain/kotlin/id/walt/oid4vc/providers/OpenIDCredentialIssuer.kt`, providing session and cache management, as well, as cryptographic operations for issuing credentials.

* **Configuration of issuance provider**

https://github.com/walt-id/waltid-openid4vc/blob/bd9374826d7acbd0d77d15cd2a81098e643eb6fa/src/jvmTest/kotlin/id/walt/oid4vc/CITestProvider.kt#L39-L56

* **Simple session management example**



### Verifier

#### REST endpoints
Expand Down
14 changes: 10 additions & 4 deletions src/jvmTest/kotlin/id/walt/oid4vc/CITestProvider.kt
Original file line number Diff line number Diff line change
Expand Up @@ -54,15 +54,21 @@ class CITestProvider(): OpenIDCredentialIssuer(
)
)
) {

// session management
private val authSessions: MutableMap<String, IssuanceSession> = mutableMapOf()

override fun getSession(id: String): IssuanceSession? = authSessions[id]
override fun putSession(id: String, session: IssuanceSession) = authSessions.put(id, session)
override fun removeSession(id: String) = authSessions.remove(id)

// crypto operations and credential issuance
private val CI_TOKEN_KEY = KeyService.getService().generate(KeyAlgorithm.RSA)
private val CI_DID_KEY = KeyService.getService().generate(KeyAlgorithm.EdDSA_Ed25519)
val CI_ISSUER_DID = DidService.create(DidMethod.key, CI_DID_KEY.id)
var deferIssuance = false
val deferredCredentialRequests = mutableMapOf<String, CredentialRequest>()
override fun getSession(id: String): IssuanceSession? = authSessions[id]
override fun putSession(id: String, session: IssuanceSession) = authSessions.put(id, session)
override fun removeSession(id: String) = authSessions.remove(id)
var deferIssuance = false

override fun signToken(target: TokenTarget, payload: JsonObject, header: JsonObject?, keyId: String?)
= JwtService.getService().sign(keyId ?: CI_TOKEN_KEY.id, payload.toString())

Expand Down

0 comments on commit 5f7b3b2

Please sign in to comment.