Class PKCS11PrivateKeyFactoryBean

java.lang.Object
net.shibboleth.shared.spring.security.factory.PKCS11PrivateKeyFactoryBean
All Implemented Interfaces:
FactoryBean<PrivateKey>

public class PKCS11PrivateKeyFactoryBean extends Object implements FactoryBean<PrivateKey>
Spring bean factory for extracting a PrivateKey from a PKCS#11 keystore. This relies on the SunPKCS11 provider.
  • Field Details

    • UNCONFIGURED_PROVIDER_NAME

      @Nonnull @NotEmpty private static final String UNCONFIGURED_PROVIDER_NAME
      The name for the base PKCS#11 provider.
      See Also:
    • provider

      @Nullable private static Provider provider
      Singleton Provider for all instances of this factory.
    • log

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

      @Nullable private String pkcs11Config
      PKCS#11 provider parameter string.
    • keyAlias

      @Nullable private String keyAlias
      Alias for the private key.
    • keyPassword

      @Nullable private String keyPassword
      Password for the private key.
    • key

      @Nullable private PrivateKey key
      The singleton instance of the private key produced by this factory.
  • Constructor Details

    • PKCS11PrivateKeyFactoryBean

      public PKCS11PrivateKeyFactoryBean()
  • Method Details

    • getPkcs11Config

      @Nullable public String getPkcs11Config()
      Returns the PKCS#11 configuration.
      Returns:
      returns the PKCS#11 configuration.
    • setPkcs11Config

      public void setPkcs11Config(@Nullable String config)
      Sets the PKCS#11 configuration to use.
      Parameters:
      config - the PKCS#11 configuration to use
    • getKeyAlias

      @Nullable public String getKeyAlias()
      Gets the key alias in use.
      Returns:
      returns the key alias in use
    • setKeyAlias

      public void setKeyAlias(@Nullable String alias)
      Sets the key alias to use.
      Parameters:
      alias - the key alias to use
    • getKeyPassword

      @Nullable public String getKeyPassword()
      Gets the key password in use.
      Returns:
      returns the key password in use
    • setKeyPassword

      public void setKeyPassword(@Nullable String password)
      Set the key password to use.
      Parameters:
      password - the key password to use
    • getProvider

      @Nonnull private Provider getProvider() throws Exception
      Gets the singleton PKCS#11 Provider. The constructed Provider is also added to the system's list of providers.
      Returns:
      the singleton Provider
      Throws:
      Exception - if something goes wrong building the Provider
    • getKeyStore

      @Nonnull private KeyStore getKeyStore() throws Exception
      Gets a PKCS#11 KeyStore from the Provider.
      Returns:
      the KeyStore
      Throws:
      Exception - if something goes wrong building the keystore
    • getObject

      @Nonnull public PrivateKey getObject() throws Exception
      Specified by:
      getObject in interface FactoryBean<PrivateKey>
      Throws:
      Exception
    • getObjectType

      @Nonnull public Class<?> getObjectType()
      Specified by:
      getObjectType in interface FactoryBean<PrivateKey>
    • isSingleton

      public boolean isSingleton()
      Specified by:
      isSingleton in interface FactoryBean<PrivateKey>