Class PkiCredentialFactoryBean

java.lang.Object
org.springframework.beans.factory.config.AbstractFactoryBean<PkiCredential>
se.swedenconnect.security.credential.factory.PkiCredentialFactoryBean
All Implemented Interfaces:
Aware, BeanClassLoaderAware, BeanFactoryAware, DisposableBean, FactoryBean<PkiCredential>, InitializingBean

public class PkiCredentialFactoryBean extends AbstractFactoryBean<PkiCredential>
A utility factory that can create any type of PkiCredential class defined in this module.

The logic is as follows:

Author:
Martin Lindström (martin@idsec.se), Stefan Santesson (stefan@idsec.se)
  • Constructor Details

    • PkiCredentialFactoryBean

      public PkiCredentialFactoryBean()
      Default constructor.
    • PkiCredentialFactoryBean

      public PkiCredentialFactoryBean(PkiCredentialConfigurationProperties properties)
      Constructor that initializes the factory from the supplied credential configuration properties object.
      Parameters:
      properties - credential configuration properties
  • Method Details

    • createInstance

      protected PkiCredential createInstance() throws Exception
      Specified by:
      createInstance in class AbstractFactoryBean<PkiCredential>
      Throws:
      Exception
    • getObjectType

      public Class<?> getObjectType()
      Specified by:
      getObjectType in interface FactoryBean<PkiCredential>
      Specified by:
      getObjectType in class AbstractFactoryBean<PkiCredential>
    • setName

      public void setName(String name)
      Assigns the name of the credential.
      Parameters:
      name - the credential name
    • setCertificate

      public void setCertificate(Resource certificate)
      Assigns the resource holding the certificate part of the credential (optional since the certificate may be part of a keystore).
      Parameters:
      certificate - certificate resource
    • setCertificates

      public void setCertificates(List<Resource> certificates)
      Assigns the list of resources holding the certificate chain that part of the credential (optional since the certificate may be part of a keystore). If used, the entity certificate must be the first element.
      Parameters:
      certificates - a list of certificate resources
    • setPrivateKey

      public void setPrivateKey(Resource privateKey)
      Assigns the resource holding the private key part of the credential (optional since the key may be part of a keystore).
      Parameters:
      privateKey - private key resource
    • setResource

      public void setResource(Resource resource)
      Assigns the resource to the keystore containing the credential.
      Parameters:
      resource - the keystore resource
    • setPassword

      public void setPassword(char[] password)
      Assigns the keystore password.
      Parameters:
      password - keystore password
    • setType

      public void setType(String type)
      Assigns the type of keystore.
      Parameters:
      type - the keystore type
    • setProvider

      public void setProvider(String provider)
      Assigns the name of the security provider to use when creating the KeyStore instance.
      Parameters:
      provider - security provider name
    • setPkcs11Configuration

      public void setPkcs11Configuration(String pkcs11Configuration)
      Assigns the PKCS#11 configuration file to use.
      Parameters:
      pkcs11Configuration - PKCS#11 configuration file (full path)
    • setAlias

      public void setAlias(String alias)
      Assigns the keystore alias to the entry holding the key pair.
      Parameters:
      alias - keystore alias
    • setKeyPassword

      public void setKeyPassword(char[] keyPassword)
      Assigns the password to unlock the private key from the keystore.
      Parameters:
      keyPassword - the key password
    • setPin

      public void setPin(char[] pin)
      Assigns the PIN. The same as keyPassword (used mainly for PKCS#11 credentials).
      Parameters:
      pin - the PIN
    • afterPropertiesSet

      public void afterPropertiesSet() throws Exception
      Specified by:
      afterPropertiesSet in interface InitializingBean
      Overrides:
      afterPropertiesSet in class AbstractFactoryBean<PkiCredential>
      Throws:
      Exception
    • destroy

      public void destroy() throws Exception
      Specified by:
      destroy in interface DisposableBean
      Overrides:
      destroy in class AbstractFactoryBean<PkiCredential>
      Throws:
      Exception