Class X509KeyStoreStorageServiceResolver

All Implemented Interfaces:
Component, DestructableComponent, IdentifiableComponent, IdentifiedComponent, InitializableComponent, Resolver<Credential,CriteriaSet>, OrderedCredentialResolver, CredentialResolver, Ordered

public class X509KeyStoreStorageServiceResolver extends AbstractStorageServiceCredentialResolver<X509Credential>
A specialized storage-based resolver that can resolve the X509Credential type from a KeyStore, typically though not inherently the "PKCS12" type.

Additional settings are required to specify how to locate the various components such as the keystore data and alias to use. A keystore password may be configured but must be usable for any resolved keys.

  • Field Details

    • log

      @Nonnull private final org.slf4j.Logger log
      Class logger.
    • keyStoreType

      @Nonnull private String keyStoreType
      Keystore type.
    • keyStoreTemplateString

      @Nonnull private String keyStoreTemplateString
      Template used to construct the storage key for the keystore.
    • aliasTemplateString

      @Nonnull private String aliasTemplateString
      Template used to construct the keystore alias to load.
    • privateKeyPassword

      @Nullable private char[] privateKeyPassword
      Password for private key(s).
    • keyStoreTemplate

      @NonnullAfterInit Template keyStoreTemplate
      Velocity template for keystore storage key.
    • aliasTemplate

      Velocity template for certificate storage key.
  • Constructor Details

    • X509KeyStoreStorageServiceResolver

      public X509KeyStoreStorageServiceResolver()
      Constructor.
  • Method Details

    • setKeyStoreType

      public void setKeyStoreType(@Nonnull @NotEmpty String type)
      Sets the KeyStore type.

      Defaults to "PKCS12".

      Parameters:
      type - keystore type
    • setKeyStoreTemplate

      public void setKeyStoreTemplate(@Nonnull @NotEmpty String template)
      Sets the Velocity template string for the keystore's storage key.

      Defaults to "sp-keystore.p12", which punts any other decoration to the storage context and assumes a fixed keystore with potentially multiple key entries.

      Parameters:
      template - template string
    • setAliasTemplate

      public void setAliasTemplate(@Nonnull @NotEmpty String template)
      Sets the Velocity template string for the KeyStore alias to load.

      Defaults to "${agentID}${usage}", which assumes per-Agent entries discriminated by usage.

      Parameters:
      template - template string
    • setPassword

      public void setPassword(@Nullable String password)
      Sets the password to apply to the keystore and any resolved entries.
      Parameters:
      password - keystore password
    • doInitialize

      protected void doInitialize() throws ComponentInitializationException
      Overrides:
      doInitialize in class AbstractStorageServiceCredentialResolver<X509Credential>
      Throws:
      ComponentInitializationException
    • doResolve

      @Nonnull @NotLive @Unmodifiable protected Iterable<Credential> doResolve(@Nonnull org.apache.velocity.VelocityContext velocityContext, @Nullable CriteriaSet criteria, @Nonnull String storageContext) throws ResolverException
      Perform the resolution as required for the specific type of Credential.

      Subclasses implement this by taking the supplied information and adjusting it if required to perform one or more storage lookups for information needed to construct the resolved credential(s).

      Most often, a single Credential (at most) will be returned as it is complex to store the information needed for multiple objects without some fairly exotic tricks, but this is left to the subclass to decide.

      Specified by:
      doResolve in class AbstractStorageServiceCredentialResolver<X509Credential>
      Parameters:
      velocityContext - Velocity context constructed from criteria
      criteria - input to resolver
      storageContext - evaluated storage context
      Returns:
      zero or more resolved credentials
      Throws:
      ResolverException - on errors, generally wrapped from storage service