public class KeyStoreHandler extends Object
| Modifier and Type | Method and Description |
|---|---|
static KeyStoreHandler |
create(File keyStoreFile,
char[] password)
Create brand new key store protected by a given password, and store it in a file.
|
boolean |
delete(String alias)
Remove an entry from the key store.
|
Optional<char[]> |
get(String alias)
Retrieve a previously stored key.
|
boolean |
isDirty()
Whether or not there are unsaved changes.
|
static KeyStoreHandler |
open(File keyStoreFile,
char[] password)
Open an existing key store, protected by a given password.
|
void |
save()
Persist whatever operations that have been made using this API.
|
boolean |
set(String alias,
char[] value)
Set a key in the key store.
|
public static KeyStoreHandler create(File keyStoreFile, char[] password) throws IOException, KeyStoreException
keyStoreFile - The file where the key store should be.password - Password to protect the key store.IOException - If file already exists or there is a problem writing the file.KeyStoreException - If something's happened to the key store.public static KeyStoreHandler open(File keyStoreFile, char[] password) throws IOException, KeyStoreException
keyStoreFile - The file where the key store is.password - Password that protects the key store.IOException - If file does not exist or there is a problem writing the file.KeyStoreException - If something's happened to the key store.public boolean set(String alias, char[] value)
SecretKey as the implementation. Overwrites previous contents, if any.alias - Alias to store the key under.value - The value to be stored.public Optional<char[]> get(String alias)
alias - The alias under which the key will be looked up.public boolean delete(String alias)
alias - The alias to locate the entry.public boolean isDirty()
set(String, char[]) occurred after last save().public void save()
throws IOException
IOException - If saving the key store failed.Copyright © 2017. All rights reserved.