diff --git a/README.md b/README.md index 3fbd3da..4dc14ec 100644 --- a/README.md +++ b/README.md @@ -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 diff --git a/src/jvmTest/kotlin/id/walt/oid4vc/CITestProvider.kt b/src/jvmTest/kotlin/id/walt/oid4vc/CITestProvider.kt index d1e6223..58c5beb 100644 --- a/src/jvmTest/kotlin/id/walt/oid4vc/CITestProvider.kt +++ b/src/jvmTest/kotlin/id/walt/oid4vc/CITestProvider.kt @@ -54,15 +54,21 @@ class CITestProvider(): OpenIDCredentialIssuer( ) ) ) { + + // session management private val authSessions: MutableMap = 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() - 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())