public class JCEKSPasswordAliasStore extends Object implements PasswordAliasStore
The keystore is actually managed by the PasswordAdapter, to which this implementation currently delegates its work.
Note that this service is currently per-lookup. This is so that each use of the alias store gets the current on-disk information. Ideally we can change this when we can use Java 7 features, including the WatchService feature.
This class's methods are not synchronized because the PasswordAdapter's methods are. If this implementation changes so that it no longer delegates to those synchronized PasswordAdapter methods, then make sure that the implementation is thread-safe.
Note that the domain-scoped password alias store service class extends this class. As a service, that class will be instantiated using the no-args constructor. So the actual initialization of the class occurs in the init method. The domain-scoped service class invokes the init method itself. Any code that needs to create some other alias store can use the newInstance method to provide the location of the alias store file and the password.
Constructor and Description |
---|
JCEKSPasswordAliasStore() |
Modifier and Type | Method and Description |
---|---|
void |
clear()
Deletes all password aliases from the store.
|
boolean |
containsKey(String alias)
Reports whether the store contains the specified alias.
|
char[] |
get(String alias)
Returns the password associated with the specified alias.
|
protected void |
init(String pathToAliasStore,
char[] storePassword) |
boolean |
isEmpty()
Reports whether the alias store is empty.
|
Iterator<String> |
keys()
Returns an Iterator over aliases present in the alias store.
|
static JCEKSPasswordAliasStore |
newInstance(String pathToAliasStore,
char[] storePassword) |
void |
put(String alias,
char[] password)
Insert a new alias with the specified password, or assigns a new
password to an existing alias.
|
void |
putAll(Map<String,char[]> settings)
Adds a group of alias/password pairs in a single operation.
|
void |
putAll(PasswordAliasStore otherStore)
Adds all alias/password pairs from the specified store to this store.
|
void |
remove(String alias)
Removes the specified alias (and the associated password) from the
password alias store.
|
int |
size()
Reports the number of aliases present in the store.
|
protected final void init(String pathToAliasStore, char[] storePassword)
public static JCEKSPasswordAliasStore newInstance(String pathToAliasStore, char[] storePassword)
public void clear()
PasswordAliasStore
clear
in interface PasswordAliasStore
public void put(String alias, char[] password)
PasswordAliasStore
put
in interface PasswordAliasStore
alias
- the alias to create or reassignpassword
- the password to be associated with the aliaspublic void putAll(PasswordAliasStore otherStore)
PasswordAliasStore
putAll
in interface PasswordAliasStore
otherStore
- the alias store from which to get entriespublic void putAll(Map<String,char[]> settings)
PasswordAliasStore
Callers might prefer to invoke this method once rather than invoking {@link #put ) repeatedly, for example if an implementation persists each change as it is made.
putAll
in interface PasswordAliasStore
settings
- the alias/password pairs to addpublic void remove(String alias)
PasswordAliasStore
remove
in interface PasswordAliasStore
alias
- the alias to be removedpublic boolean containsKey(String alias)
PasswordAliasStore
containsKey
in interface PasswordAliasStore
alias
- the alias to check forpublic char[] get(String alias)
PasswordAliasStore
get
in interface PasswordAliasStore
alias
- the alias of interestpublic boolean isEmpty()
PasswordAliasStore
isEmpty
in interface PasswordAliasStore
public Iterator<String> keys()
PasswordAliasStore
keys
in interface PasswordAliasStore
public int size()
PasswordAliasStore
size
in interface PasswordAliasStore
Copyright © 2020. All rights reserved.