diff --git a/modules/local-kms/src/commonMain/kotlin/com/sphereon/oid/fed/kms/local/LocalKmsDatabase.kt b/modules/local-kms/src/commonMain/kotlin/com/sphereon/oid/fed/kms/local/LocalKmsDatabase.kt index 3ca459a6..98cc7901 100644 --- a/modules/local-kms/src/commonMain/kotlin/com/sphereon/oid/fed/kms/local/LocalKmsDatabase.kt +++ b/modules/local-kms/src/commonMain/kotlin/com/sphereon/oid/fed/kms/local/LocalKmsDatabase.kt @@ -5,7 +5,6 @@ import com.sphereon.oid.fed.kms.local.models.Keys expect class LocalKmsDatabase { fun getKey(keyId: String): Keys fun insertKey(keyId: String, privateKey: ByteArray, publicKey: ByteArray, algorithm: String) - fun updateKey(keyId: String, privateKey: ByteArray, publicKey: ByteArray, algorithm: String) fun deleteKey(keyId: String) } diff --git a/modules/local-kms/src/commonMain/sqldelight/com/sphereon/oid/fed/kms/local/models/1.sqm b/modules/local-kms/src/commonMain/sqldelight/com/sphereon/oid/fed/kms/local/models/1.sqm index b0d5435c..6bf90ee4 100644 --- a/modules/local-kms/src/commonMain/sqldelight/com/sphereon/oid/fed/kms/local/models/1.sqm +++ b/modules/local-kms/src/commonMain/sqldelight/com/sphereon/oid/fed/kms/local/models/1.sqm @@ -2,5 +2,6 @@ CREATE TABLE Keys ( id TEXT PRIMARY KEY, private_key BYTEA NOT NULL, public_key BYTEA NOT NULL, - algorithm TEXT NOT NULL + algorithm TEXT NOT NULL, + deleted_at TIMESTAMP ); \ No newline at end of file diff --git a/modules/local-kms/src/commonMain/sqldelight/com/sphereon/oid/fed/kms/local/models/Keys.sq b/modules/local-kms/src/commonMain/sqldelight/com/sphereon/oid/fed/kms/local/models/Keys.sq index 6dcb3c63..34956c85 100644 --- a/modules/local-kms/src/commonMain/sqldelight/com/sphereon/oid/fed/kms/local/models/Keys.sq +++ b/modules/local-kms/src/commonMain/sqldelight/com/sphereon/oid/fed/kms/local/models/Keys.sq @@ -6,3 +6,6 @@ INSERT INTO Keys (id, private_key, public_key, algorithm) VALUES (?, ?, ?, ?) RE findById: SELECT * FROM Keys WHERE id = ?; + +delete: +UPDATE Keys SET deleted_at = CURRENT_TIMESTAMP WHERE id = ?; \ No newline at end of file diff --git a/modules/local-kms/src/jvmMain/kotlin/com/sphereon/oid/fed/kms/local/LocalKmsDatabase.jvm.kt b/modules/local-kms/src/jvmMain/kotlin/com/sphereon/oid/fed/kms/local/LocalKmsDatabase.jvm.kt index 04d10c28..261b7a5a 100644 --- a/modules/local-kms/src/jvmMain/kotlin/com/sphereon/oid/fed/kms/local/LocalKmsDatabase.jvm.kt +++ b/modules/local-kms/src/jvmMain/kotlin/com/sphereon/oid/fed/kms/local/LocalKmsDatabase.jvm.kt @@ -8,7 +8,7 @@ import com.sphereon.oid.fed.persistence.database.PlatformSqlDriver actual class LocalKmsDatabase { - var database: Database + private var database: Database init { val driver = getDriver() @@ -35,13 +35,7 @@ actual class LocalKmsDatabase { database.keysQueries.create(keyId, privateKey, publicKey, algorithm).executeAsOneOrNull() } - actual fun updateKey( - keyId: String, privateKey: ByteArray, publicKey: ByteArray, algorithm: String - ) { - TODO("Not yet implemented") - } - actual fun deleteKey(keyId: String) { - TODO("Not yet implemented") + database.keysQueries.delete(keyId) } }