Class DSSSecurityFactory<I,O>

java.lang.Object
eu.europa.esig.dss.spi.security.DSSSecurityFactory<I,O>
Type Parameters:
I - represents an input object for the result generation
O - represents an output of the building process
Direct Known Subclasses:
DSSCertificateTokenSecurityFactory, DSSContentVerifierProviderSecurityFactory, DSSKeyPairGeneratorSecurityFactory, DSSP7CCertificatesSecurityFactory, DSSSignatureSecurityFactory, DSSSignerInformationVerifierSecurityFactory

public abstract class DSSSecurityFactory<I,O> extends Object
This class provides an abstract logic to load securely Java Cryptographic Architecture classes, based on eu.europa.esig.dss.spi.DSSSecurityProvider's configuration.

The implementation will initially use the primary security provider to load a given token, and only in case of a failure of the main security provider, the implementation will try to perform the same operation using alternative security providers, until the first success. The first successful result is returned immediately, while in case of failure of all security providers, the class will throw a eu.europa.esig.dss.model.DSSException.

  • Constructor Details

    • DSSSecurityFactory

      protected DSSSecurityFactory()
      Default constructor
  • Method Details

    • build

      public O build(I input)
      This method implements the main logic to load a given token. It will first try to generate the output result using a main security provider from DSSSecurityProvider, and only in case of failure will try to use alternative security providers until the first success.
      Parameters:
      input - object to be used as an input for result generation
      Returns:
      output object result
    • buildWithPrimarySecurityProvider

      protected O buildWithPrimarySecurityProvider(I input)
      Builds the result based on the given input using the primary security provider. If the build fails, it returns a NULL value.
      Parameters:
      input - object to be used as an input for result generation
      Returns:
      output object result
    • buildWithAlternativeSecurityProviders

      protected O buildWithAlternativeSecurityProviders(I input)
      Builds the result based on the given input using the alternative security providers. The method iterates accords all available alternative security providers until the first successful result and returns it. If the build fails for all security providers, it returns a NULL value.
      Parameters:
      input - object to be used as an input for result generation
      Returns:
      output object result
    • getFactoryClassName

      protected abstract String getFactoryClassName()
      Gets the factory class name
      Returns:
      String
    • toString

      protected abstract String toString(I input)
      Gets a string representation for the given input
      Parameters:
      input - object to be used as an input for result generation
      Returns:
      String
    • buildWithProvider

      protected abstract O buildWithProvider(I input, Provider securityProvider) throws Exception
      Builds the result using a given securityProvider
      Parameters:
      input - object to be used as an input for result generation
      securityProvider - Provider
      Returns:
      output object result if the build is successful
      Throws:
      Exception - if an error occurred