public class Keyring extends Object
The key identifier should be unique for the whole application, so qualify it with any prefixes as needed.
Since 1.10 it is allowed to call methods of this class from even dispatch thread.
Modifier and Type | Method and Description |
---|---|
static void |
delete(String key)
Deletes a key from the ring.
|
static char[] |
read(String key)
Reads a key from the ring.
|
static void |
save(String key,
char[] password,
String description)
Saves a key to the ring.
|
@CheckForNull public static char[] read(@NonNull String key)
This method can be called from any thread.
All the changes done by previous calls to Keyring.delete(java.lang.String)
or Keyring.save(java.lang.String, char[], java.lang.String)
methods
are guaranteed to be visible by subsequent calls to this method.
key
- the identifier of the keypublic static void save(@NonNull String key, @NonNull char[] password, @NullAllowed String description)
This method can be called from any thread.
The changes done by multiple calls to Keyring.delete(java.lang.String)
or Keyring.save(java.lang.String, char[], java.lang.String)
methods
are guaranteed to be processed in order in which they were called.
key
- a key identifierpassword
- the password or other sensitive information associated with the key
(its contents will be nulled out by end of call)description
- a user-visible description of the key (may be null)public static void delete(@NonNull String key)
This method can be called from any thread.
The changes done by multiple calls to Keyring.delete(java.lang.String)
or Keyring.save(java.lang.String, char[], java.lang.String)
methods
are guaranteed to be processed in order in which they were called.
key
- a key identifier