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 voidclear()Deletes all password aliases from the store.booleancontainsKey(String alias)Reports whether the store contains the specified alias.char[]get(String alias)Returns the password associated with the specified alias.protected voidinit(String pathToAliasStore, char[] storePassword)booleanisEmpty()Reports whether the alias store is empty.Iterator<String>keys()Returns an Iterator over aliases present in the alias store.static JCEKSPasswordAliasStorenewInstance(String pathToAliasStore, char[] storePassword)voidput(String alias, char[] password)Insert a new alias with the specified password, or assigns a new password to an existing alias.voidputAll(Map<String,char[]> settings)Adds a group of alias/password pairs in a single operation.voidputAll(PasswordAliasStore otherStore)Adds all alias/password pairs from the specified store to this store.voidremove(String alias)Removes the specified alias (and the associated password) from the password alias store.intsize()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:PasswordAliasStoreDeletes all password aliases from the store.- Specified by:
clearin interfacePasswordAliasStore
-
put
public void put(String alias, char[] password)
Description copied from interface:PasswordAliasStoreInsert a new alias with the specified password, or assigns a new password to an existing alias.- Specified by:
putin 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:PasswordAliasStoreAdds all alias/password pairs from the specified store to this store.- Specified by:
putAllin interfacePasswordAliasStore- Parameters:
otherStore- the alias store from which to get entries
-
putAll
public void putAll(Map<String,char[]> settings)
Description copied from interface:PasswordAliasStoreAdds 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:
putAllin interfacePasswordAliasStore- Parameters:
settings- the alias/password pairs to add
-
remove
public void remove(String alias)
Description copied from interface:PasswordAliasStoreRemoves the specified alias (and the associated password) from the password alias store.- Specified by:
removein interfacePasswordAliasStore- Parameters:
alias- the alias to be removed
-
containsKey
public boolean containsKey(String alias)
Description copied from interface:PasswordAliasStoreReports whether the store contains the specified alias.- Specified by:
containsKeyin 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:PasswordAliasStoreReturns the password associated with the specified alias.- Specified by:
getin 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:PasswordAliasStoreReports whether the alias store is empty.- Specified by:
isEmptyin interfacePasswordAliasStore- Returns:
-
keys
public Iterator<String> keys()
Description copied from interface:PasswordAliasStoreReturns an Iterator over aliases present in the alias store.- Specified by:
keysin interfacePasswordAliasStore- Returns:
-
size
public int size()
Description copied from interface:PasswordAliasStoreReports the number of aliases present in the store.- Specified by:
sizein interfacePasswordAliasStore- Returns:
-
-