Class MapCredentialStore

java.lang.Object
org.wildfly.security.credential.store.CredentialStoreSpi
org.wildfly.security.credential.store.impl.MapCredentialStore

public final class MapCredentialStore extends CredentialStoreSpi
A map-backed credential store implementation.
Author:
David M. Lloyd
  • Field Details

  • Constructor Details

    • MapCredentialStore

      public MapCredentialStore(ConcurrentMap<String, org.wildfly.security.credential.source.CredentialSource> credentialSources, boolean modifiable)
      Construct a new instance.
      Parameters:
      credentialSources - the credential sources map to use as the backing map for this store (must not be null)
      modifiable - true to allow modifications via the API, false otherwise
    • MapCredentialStore

      public MapCredentialStore(Map<String, org.wildfly.security.credential.source.CredentialSource> credentialSources)
      Construct a new unmodifiable instance.
      Parameters:
      credentialSources - the credential sources map to use (must not be null)
    • MapCredentialStore

      public MapCredentialStore()
      Construct a new, modifiable instance backed by a new concurrent map.
  • Method Details

    • initialize

      public void initialize(Map<String,String> attributes, CredentialStore.ProtectionParameter protectionParameter, Provider[] providers) throws CredentialStoreException
      Description copied from class: CredentialStoreSpi
      Initialize credential store service with given attributes. This procedure should set CredentialStoreSpi.initialized after successful initialization.
      Specified by:
      initialize in class CredentialStoreSpi
      Parameters:
      attributes - attributes to used to pass information to credential store service
      protectionParameter - the store-wide protection parameter to apply, or null for none
      providers - providers to be injected into SPI implementation to get custom object instances of various type from, or null for none
      Throws:
      CredentialStoreException - if initialization fails due to any reason
    • isModifiable

      public boolean isModifiable()
      Description copied from class: CredentialStoreSpi
      Check if credential store service supports modification of its store
      Specified by:
      isModifiable in class CredentialStoreSpi
      Returns:
      true in case of modification of the store is supported, false otherwise
    • getAliases

      Description copied from class: CredentialStoreSpi
      Returns credential aliases stored in this store as Set<String>. It is not mandatory to override this method (throws UnsupportedOperationException by default).
      Overrides:
      getAliases in class CredentialStoreSpi
      Returns:
      Set<String> of all keys stored in this store
      Throws:
      UnsupportedOperationException - when this method is not supported by the underlying credential store
      CredentialStoreException - if there is any problem with internal store
    • exists

      public boolean exists(String credentialAlias, Class<? extends org.wildfly.security.credential.Credential> credentialType) throws CredentialStoreException
      Description copied from class: CredentialStoreSpi
      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 returns true if any credential was returned. Credential stores which use a protection parameter should override this method.
      Overrides:
      exists in class CredentialStoreSpi
      Parameters:
      credentialAlias - key to check existence
      credentialType - to class of credential to look for
      Returns:
      true in case key exist in store otherwise false
      Throws:
      CredentialStoreException - when there is a problem with credential store
    • store

      public void store(String credentialAlias, org.wildfly.security.credential.Credential credential, CredentialStore.ProtectionParameter protectionParameter) throws CredentialStoreException, UnsupportedCredentialTypeException
      Description copied from class: CredentialStoreSpi
      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: CredentialStoreSpi supports storing of multiple entries (credential types) per alias. Each must be of different credential type, or differing algorithm, or differing parameters.
      Specified by:
      store in class CredentialStoreSpi
      Parameters:
      credentialAlias - to store the credential to the store
      credential - instance of Credential to store
      protectionParameter - the protection parameter to apply to the entry, or null for none
      Throws:
      CredentialStoreException - when the credential cannot be stored
      UnsupportedCredentialTypeException - when the credentialType is not supported
    • retrieve

      public <C extends org.wildfly.security.credential.Credential> C retrieve(String credentialAlias, Class<C> credentialType, String credentialAlgorithm, AlgorithmParameterSpec parameterSpec, CredentialStore.ProtectionParameter protectionParameter) throws CredentialStoreException
      Description copied from class: CredentialStoreSpi
      Retrieve the credential stored in the store under the given alias, matching the given criteria.
      Specified by:
      retrieve in class CredentialStoreSpi
      Type Parameters:
      C - the credential type
      Parameters:
      credentialAlias - to find the credential in the store
      credentialType - the credential type class (must not be null)
      credentialAlgorithm - the credential algorithm to match, or null to match any algorithm
      parameterSpec - the parameter specification to match, or null to match any parameters
      protectionParameter - the protection parameter to use to access the entry, or null for none
      Returns:
      instance of Credential stored in the store, or null if the credential is not found
      Throws:
      CredentialStoreException - if the credential cannot be retrieved due to an error
    • remove

      public void remove(String credentialAlias, Class<? extends org.wildfly.security.credential.Credential> credentialType, String credentialAlgorithm, AlgorithmParameterSpec parameterSpec) throws CredentialStoreException
      Description copied from class: CredentialStoreSpi
      Remove the credentialType with from given alias from the credential store service.
      Specified by:
      remove in class CredentialStoreSpi
      Parameters:
      credentialAlias - alias to remove
      credentialType - the credential type class to match (must not be null)
      credentialAlgorithm - the credential algorithm to match, or null to match all algorithms
      parameterSpec - the credential parameters to match, or null to match all parameters
      Throws:
      CredentialStoreException - if the credential cannot be removed due to an error