aboutsummaryrefslogtreecommitdiff
path: root/app/src/main/java
diff options
context:
space:
mode:
authorHarsh Shandilya <me@msfjarvis.dev>2023-05-19 18:58:48 +0530
committerHarsh Shandilya <me@msfjarvis.dev>2023-05-19 18:58:48 +0530
commit5420faff34b8626fa65430b945c1bb098c26e40f (patch)
tree101cf4505d204024240aff7ffccc844947359e30 /app/src/main/java
parent65509eaa54ea5fa8e363e3d6b1c044b1383a2c31 (diff)
feat(gpg): add methods to clear entries from GPG passphrase cache
Diffstat (limited to 'app/src/main/java')
-rw-r--r--app/src/main/java/app/passwordstore/data/crypto/GPGPassphraseCache.kt13
1 files changed, 13 insertions, 0 deletions
diff --git a/app/src/main/java/app/passwordstore/data/crypto/GPGPassphraseCache.kt b/app/src/main/java/app/passwordstore/data/crypto/GPGPassphraseCache.kt
index 193c363c..e00809a8 100644
--- a/app/src/main/java/app/passwordstore/data/crypto/GPGPassphraseCache.kt
+++ b/app/src/main/java/app/passwordstore/data/crypto/GPGPassphraseCache.kt
@@ -37,6 +37,19 @@ constructor(
}
}
+ suspend fun clearCachedPassphrase(
+ context: Context,
+ identifier: GpgIdentifier,
+ ) {
+ withContext(dispatcherProvider.io()) {
+ getPreferences(context).edit { remove(identifier.toString()) }
+ }
+ }
+
+ suspend fun clearAllCachedPassphrases(context: Context) {
+ withContext(dispatcherProvider.io()) { getPreferences(context).edit { clear() } }
+ }
+
private suspend fun getPreferences(context: Context) =
withContext(dispatcherProvider.io()) {
EncryptedSharedPreferences.create(