Skip to content

Commit 0cafab2

Browse files
authored
Widen API to allow storing keychain entries for an authenticated user (#41)
Overlead and extend method storePassphrase() with requiresAuth flag
1 parent d1c2623 commit 0cafab2

File tree

1 file changed

+18
-1
lines changed

1 file changed

+18
-1
lines changed

src/main/java/org/cryptomator/integrations/keychain/KeychainAccessProvider.java

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,24 @@ default void storePassphrase(String key, CharSequence passphrase) throws Keychai
5656
* @throws KeychainAccessException If storing the password failed
5757
*/
5858
@Blocking
59-
void storePassphrase(String key, @Nullable String displayName, CharSequence passphrase) throws KeychainAccessException;
59+
default void storePassphrase(String key, @Nullable String displayName, CharSequence passphrase) throws KeychainAccessException {
60+
storePassphrase(key, displayName, passphrase, false);
61+
}
62+
63+
/**
64+
* Associates a passphrase with a given key and a name for that key.
65+
*
66+
* @param key Key used to retrieve the passphrase via {@link #loadPassphrase(String)}.
67+
* @param displayName The according name to the key. That's the name of the vault displayed in the UI.
68+
* It's passed to the keychain as an additional information about the vault besides the key.
69+
* The parameter does not need to be unique or be checked by the keychain.
70+
* @param passphrase The secret to store in this keychain.
71+
* @param requireOsAuthentication Defines, whether the user needs to authenticate to store a passphrase.
72+
* The authentication mechanism is provided by the operating system dependent
73+
* implementations of this API.
74+
* @throws KeychainAccessException If storing the password failed
75+
*/
76+
void storePassphrase(String key, @Nullable String displayName, CharSequence passphrase, boolean requireOsAuthentication) throws KeychainAccessException;
6077

6178
/**
6279
* @param key Unique key previously used while {@link #storePassphrase(String, String, CharSequence)} storing a passphrase}.

0 commit comments

Comments
 (0)