Class JCEKSPasswordAliasStore
- java.lang.Object
-
- org.glassfish.security.services.impl.JCEKSPasswordAliasStore
-
- All Implemented Interfaces:
PasswordAliasStore
- Direct Known Subclasses:
JCEKSDomainPasswordAliasStore
public class JCEKSPasswordAliasStore extends Object implements PasswordAliasStore
Provides the PasswordAliasStore behavior using a JCEKS keystore.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.
- Author:
- tjquinn
-
-
Constructor Summary
Constructors Constructor Description JCEKSPasswordAliasStore()
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method 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.
-
-
-
Method Detail
-
init
protected final void init(String pathToAliasStore, char[] storePassword)
-
newInstance
public static JCEKSPasswordAliasStore newInstance(String pathToAliasStore, char[] storePassword)
-
clear
public void clear()
Description copied from interface:PasswordAliasStore
Deletes all password aliases from the store.- Specified by:
clear
in interfacePasswordAliasStore
-
put
public void put(String alias, char[] password)
Description copied from interface:PasswordAliasStore
Insert a new alias with the specified password, or assigns a new password to an existing alias.- Specified by:
put
in interfacePasswordAliasStore
- Parameters:
alias
- the alias to create or reassignpassword
- the password to be associated with the alias
-
putAll
public void putAll(PasswordAliasStore otherStore)
Description copied from interface:PasswordAliasStore
Adds all alias/password pairs from the specified store to this store.- Specified by:
putAll
in interfacePasswordAliasStore
- Parameters:
otherStore
- the alias store from which to get entries
-
putAll
public void putAll(Map<String,char[]> settings)
Description copied from interface:PasswordAliasStore
Adds a group of alias/password pairs in a single operation.Callers might prefer to invoke this method once rather than invoking
) repeatedly, for example if an implementation persists each change as it is made.
- Specified by:
putAll
in interfacePasswordAliasStore
- Parameters:
settings
- the alias/password pairs to add
-
remove
public void remove(String alias)
Description copied from interface:PasswordAliasStore
Removes the specified alias (and the associated password) from the password alias store.- Specified by:
remove
in interfacePasswordAliasStore
- Parameters:
alias
- the alias to be removed
-
containsKey
public boolean containsKey(String alias)
Description copied from interface:PasswordAliasStore
Reports whether the store contains the specified alias.- Specified by:
containsKey
in interfacePasswordAliasStore
- Parameters:
alias
- the alias to check for- Returns:
- true if the alias appears in the store; false otherwise
-
get
public char[] get(String alias)
Description copied from interface:PasswordAliasStore
Returns the password associated with the specified alias.- Specified by:
get
in interfacePasswordAliasStore
- Parameters:
alias
- the alias of interest- Returns:
- the password for that alias, if the store contains the alias; null otherwise
-
isEmpty
public boolean isEmpty()
Description copied from interface:PasswordAliasStore
Reports whether the alias store is empty.- Specified by:
isEmpty
in interfacePasswordAliasStore
- Returns:
-
keys
public Iterator<String> keys()
Description copied from interface:PasswordAliasStore
Returns an Iterator over aliases present in the alias store.- Specified by:
keys
in interfacePasswordAliasStore
- Returns:
-
size
public int size()
Description copied from interface:PasswordAliasStore
Reports the number of aliases present in the store.- Specified by:
size
in interfacePasswordAliasStore
- Returns:
-
-