-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: added KmsService and local KMS module
- Loading branch information
1 parent
cf6d37d
commit ba581e3
Showing
4 changed files
with
61 additions
and
0 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
plugins { | ||
kotlin("jvm") version "2.0.0" | ||
} | ||
|
||
group = "com.sphereon.oid.fed.kms.local" | ||
version = "0.1.0" | ||
|
||
repositories { | ||
mavenCentral() | ||
mavenLocal() | ||
google() | ||
} | ||
|
||
dependencies { | ||
testImplementation(kotlin("test")) | ||
} | ||
|
||
tasks.test { | ||
useJUnitPlatform() | ||
} | ||
kotlin { | ||
jvmToolchain(21) | ||
} |
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,5 @@ | ||
package com.sphereon.oid.fed.kms.local | ||
|
||
fun main() { | ||
println("Hello World!") | ||
} |
32 changes: 32 additions & 0 deletions
32
modules/services/src/commonMain/kotlin/com/sphereon/oid/fed/services/KmsService.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,32 @@ | ||
package com.sphereon.oid.fed.services | ||
|
||
import com.sphereon.oid.fed.persistence.models.Jwk | ||
|
||
class KmsService(private val provider: String) { | ||
|
||
private val kmsClient: KmsClient by lazy { | ||
when (provider) { | ||
//"local" -> LocalKmsClient() | ||
//"aws" -> AwsKmsClient() | ||
else -> throw IllegalArgumentException("Unsupported KMS provider: $provider") | ||
} | ||
} | ||
|
||
fun generateKeyPair(keyId: String): Jwk { | ||
return kmsClient.generateKeyPair(keyId) | ||
} | ||
|
||
fun sign(data: String, keyId: String): String { | ||
return kmsClient.sign(data, keyId) | ||
} | ||
|
||
fun verify(token: String, keyId: String): Boolean { | ||
return kmsClient.verify(token, keyId) | ||
} | ||
} | ||
|
||
interface KmsClient { | ||
fun generateKeyPair(keyId: String): Jwk | ||
fun sign(data: String, keyId: String): String | ||
fun verify(token: String, keyId: String): Boolean | ||
} |
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