Class CredentialStoreSpi
- java.lang.Object
-
- org.wildfly.security.credential.store.CredentialStoreSpi
-
public abstract class CredentialStoreSpi extends Object
SPI for credential store provider to implement.- Author:
- Peter Skopek
-
-
Field Summary
Fields Modifier and Type Field Description protected booleaninitializedField indicating successful initialization (initialize(Map, CredentialStore.ProtectionParameter, Provider[]).
-
Constructor Summary
Constructors Modifier Constructor Description protectedCredentialStoreSpi()Construct a new instance of this SPI.
-
Method Summary
All Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description booleanexists(String credentialAlias, Class<? extends Credential> credentialType)Check whether credential store service has an entry associated with the given credential alias of specified credential type.voidflush()Flush the credential store contents to storage.Set<String>getAliases()Returns credential aliases stored in this store asSet<String>.Set<String>getCredentialTypesForAlias(String credentialAlias)Returns credential types stored in this store with given alias asSet<String>.abstract voidinitialize(Map<String,String> attributes, CredentialStore.ProtectionParameter protectionParameter, Provider[] providers)Initialize credential store service with given attributes.booleanisInitialized()Checks whether underlying credential store service is initialized.abstract booleanisModifiable()Check if credential store service supports modification of its storeabstract voidremove(String credentialAlias, Class<? extends Credential> credentialType, String credentialAlgorithm, AlgorithmParameterSpec parameterSpec)Remove the credentialType with from given alias from the credential store service.abstract <C extends Credential>
Cretrieve(String credentialAlias, Class<C> credentialType, String credentialAlgorithm, AlgorithmParameterSpec parameterSpec, CredentialStore.ProtectionParameter protectionParameter)Retrieve the credential stored in the store under the given alias, matching the given criteria.abstract voidstore(String credentialAlias, Credential credential, CredentialStore.ProtectionParameter protectionParameter)Store credential to the credential store service under the given alias.voidvalidateAttribute(Map<String,String> attributes, List<String> validAttributes)Validate given attributes in credential store implementation.
-
-
-
Field Detail
-
initialized
protected boolean initialized
Field indicating successful initialization (initialize(Map, CredentialStore.ProtectionParameter, Provider[]). Each subclass should set this field.
-
-
Method Detail
-
initialize
public abstract void initialize(Map<String,String> attributes, CredentialStore.ProtectionParameter protectionParameter, Provider[] providers) throws CredentialStoreException
Initialize credential store service with given attributes. This procedure should setinitializedafter successful initialization.- Parameters:
attributes- attributes to used to pass information to credential store serviceprotectionParameter- the store-wide protection parameter to apply, ornullfor noneproviders- providers to be injected into SPI implementation to get custom object instances of various type from, ornullfor none- Throws:
CredentialStoreException- if initialization fails due to any reason
-
isInitialized
public boolean isInitialized()
Checks whether underlying credential store service is initialized.- Returns:
truein case of initialization passed successfully,falseotherwise.
-
isModifiable
public abstract boolean isModifiable()
Check if credential store service supports modification of its store- Returns:
truein case of modification of the store is supported,falseotherwise
-
exists
public boolean exists(String credentialAlias, Class<? extends Credential> credentialType) throws CredentialStoreException
Check whether credential store service has an entry associated with the given credential alias of specified credential type. The default implementation simply attempts to retrieve the credential without a protection parameter, and returnstrueif any credential was returned. Credential stores which use a protection parameter should override this method.- Parameters:
credentialAlias- key to check existencecredentialType- to class of credential to look for- Returns:
truein case key exist in store otherwisefalse- Throws:
CredentialStoreException- when there is a problem with credential store
-
store
public abstract void store(String credentialAlias, Credential credential, CredentialStore.ProtectionParameter protectionParameter) throws CredentialStoreException, UnsupportedCredentialTypeException
Store credential to the credential store service under the given alias. If given alias already contains specific credential type type the credential replaces older one. Note:CredentialStoreSpisupports storing of multiple entries (credential types) per alias. Each must be of different credential type, or differing algorithm, or differing parameters.- Parameters:
credentialAlias- to store the credential to the storecredential- instance ofCredentialto storeprotectionParameter- the protection parameter to apply to the entry, ornullfor none- Throws:
CredentialStoreException- when the credential cannot be storedUnsupportedCredentialTypeException- when the credentialType is not supported
-
retrieve
public abstract <C extends Credential> C retrieve(String credentialAlias, Class<C> credentialType, String credentialAlgorithm, AlgorithmParameterSpec parameterSpec, CredentialStore.ProtectionParameter protectionParameter) throws CredentialStoreException
Retrieve the credential stored in the store under the given alias, matching the given criteria.- Type Parameters:
C- the credential type- Parameters:
credentialAlias- to find the credential in the storecredentialType- the credential type class (must not benull)credentialAlgorithm- the credential algorithm to match, ornullto match any algorithmparameterSpec- the parameter specification to match, ornullto match any parametersprotectionParameter- the protection parameter to use to access the entry, ornullfor none- Returns:
- instance of
Credentialstored in the store, ornullif the credential is not found - Throws:
CredentialStoreException- if the credential cannot be retrieved due to an error
-
remove
public abstract void remove(String credentialAlias, Class<? extends Credential> credentialType, String credentialAlgorithm, AlgorithmParameterSpec parameterSpec) throws CredentialStoreException
Remove the credentialType with from given alias from the credential store service.- Parameters:
credentialAlias- alias to removecredentialType- the credential type class to match (must not benull)credentialAlgorithm- the credential algorithm to match, ornullto match all algorithmsparameterSpec- the credential parameters to match, ornullto match all parameters- Throws:
CredentialStoreException- if the credential cannot be removed due to an error
-
flush
public void flush() throws CredentialStoreExceptionFlush the credential store contents to storage. If the credential store does not support or require explicit flushing, this method should do nothing and simply return.- Throws:
CredentialStoreException- if the flush fails for some reason.
-
getAliases
public Set<String> getAliases() throws UnsupportedOperationException, CredentialStoreException
Returns credential aliases stored in this store asSet<String>. It is not mandatory to override this method (throwsUnsupportedOperationExceptionby default).- Returns:
Set<String>of all keys stored in this store- Throws:
UnsupportedOperationException- when this method is not supported by the underlying credential storeCredentialStoreException- if there is any problem with internal store
-
getCredentialTypesForAlias
public Set<String> getCredentialTypesForAlias(String credentialAlias) throws UnsupportedOperationException
Returns credential types stored in this store with given alias asSet<String>. It is not mandatory to override this method (throwsUnsupportedOperationExceptionby default).- Parameters:
credentialAlias- to find the credentials types in the store- Returns:
Set<String>of all credential types stored in this store with credential alias- Throws:
UnsupportedOperationException- when this method is not supported by the underlying credential store
-
validateAttribute
public void validateAttribute(Map<String,String> attributes, List<String> validAttributes) throws CredentialStoreException
Validate given attributes in credential store implementation.- Parameters:
attributes- attributes to used to pass information to credential store service.validAttributes- valid attributes based on credential store implementation.- Throws:
CredentialStoreException- if validation fails
-
-