Skip to content

Commit

Permalink
feat: Added query for delete key
Browse files Browse the repository at this point in the history
  • Loading branch information
robertmathew committed Aug 29, 2024
1 parent 659c4c9 commit 8d4b9fa
Show file tree
Hide file tree
Showing 4 changed files with 7 additions and 10 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
);
Original file line number Diff line number Diff line change
Expand Up @@ -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 = ?;
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand All @@ -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)
}
}

0 comments on commit 8d4b9fa

Please sign in to comment.