diff --git a/modules/local-kms/src/commonMain/kotlin/com/sphereon/oid/fed/kms/local/LocalKms.kt b/modules/local-kms/src/commonMain/kotlin/com/sphereon/oid/fed/kms/local/LocalKms.kt index 79b41024..00a14f7e 100644 --- a/modules/local-kms/src/commonMain/kotlin/com/sphereon/oid/fed/kms/local/LocalKms.kt +++ b/modules/local-kms/src/commonMain/kotlin/com/sphereon/oid/fed/kms/local/LocalKms.kt @@ -5,6 +5,7 @@ import com.sphereon.oid.fed.kms.local.jwk.generateKeyPair import com.sphereon.oid.fed.openapi.models.JWTHeader import com.sphereon.oid.fed.kms.local.jwt.sign import com.sphereon.oid.fed.kms.local.jwt.verify +import com.sphereon.oid.fed.openapi.models.Jwk import kotlinx.serialization.json.Json import kotlinx.serialization.json.JsonObject @@ -23,9 +24,7 @@ class LocalKms { return sign(header = header, payload = payload, key = Json.decodeFromString(jwk.private_key)) } - fun verify(token: String, keyId: String): Boolean { - val jwk = database.getKey(keyId) - - return verify(jwt = token, key = Json.decodeFromString(jwk.private_key)) + fun verify(token: String, jwk: Jwk): Boolean { + return verify(jwt = token, key = jwk) } } \ No newline at end of file diff --git a/modules/services/src/commonMain/kotlin/com/sphereon/oid/fed/services/KmsService.kt b/modules/services/src/commonMain/kotlin/com/sphereon/oid/fed/services/KmsService.kt index 772c7676..a692c2db 100644 --- a/modules/services/src/commonMain/kotlin/com/sphereon/oid/fed/services/KmsService.kt +++ b/modules/services/src/commonMain/kotlin/com/sphereon/oid/fed/services/KmsService.kt @@ -1,6 +1,7 @@ package com.sphereon.oid.fed.services import com.sphereon.oid.fed.openapi.models.JWTHeader +import com.sphereon.oid.fed.openapi.models.Jwk import kotlinx.serialization.json.JsonObject class KmsService(private val provider: String) { @@ -18,13 +19,13 @@ class KmsService(private val provider: String) { return kmsClient.sign(header, payload, keyId) } - fun verify(token: String, keyId: String): Boolean { - return kmsClient.verify(token, keyId) + fun verify(token: String, jwk: Jwk): Boolean { + return kmsClient.verify(token, jwk) } } interface KmsClient { fun generateKeyPair(keyId: String) fun sign(header: JWTHeader, payload: JsonObject, keyId: String): String - fun verify(token: String, keyId: String): Boolean + fun verify(token: String, jwk: Jwk): Boolean } \ No newline at end of file diff --git a/modules/services/src/commonMain/kotlin/com/sphereon/oid/fed/services/LocalKmsClient.kt b/modules/services/src/commonMain/kotlin/com/sphereon/oid/fed/services/LocalKmsClient.kt index 7f03fb0a..b5b8c5eb 100644 --- a/modules/services/src/commonMain/kotlin/com/sphereon/oid/fed/services/LocalKmsClient.kt +++ b/modules/services/src/commonMain/kotlin/com/sphereon/oid/fed/services/LocalKmsClient.kt @@ -2,11 +2,12 @@ package com.sphereon.oid.fed.services import com.sphereon.oid.fed.kms.local.LocalKms import com.sphereon.oid.fed.openapi.models.JWTHeader +import com.sphereon.oid.fed.openapi.models.Jwk import kotlinx.serialization.json.JsonObject class LocalKmsClient : KmsClient { - val localKms = LocalKms() + private val localKms = LocalKms() override fun generateKeyPair(keyId: String) { return localKms.generateKey(keyId) @@ -16,7 +17,7 @@ class LocalKmsClient : KmsClient { return localKms.sign(header, payload, keyId) } - override fun verify(token: String, keyId: String): Boolean { - return localKms.verify(token, keyId) + override fun verify(token: String, jwk: Jwk): Boolean { + return localKms.verify(token, jwk) } } \ No newline at end of file