Class AbstractTbsDocumentProcessor<T>

java.lang.Object
se.idsec.signservice.integration.document.impl.AbstractTbsDocumentProcessor<T>
Type Parameters:
T - document type
All Implemented Interfaces:
DocumentProcessor<T>, TbsDocumentProcessor<T>

public abstract class AbstractTbsDocumentProcessor<T> extends Object implements TbsDocumentProcessor<T>
Abstract base class for TbsDocumentProcessor implementations.
Author:
Martin Lindström (martin@idsec.se), Stefan Santesson (stefan@idsec.se)
  • Constructor Details

    • AbstractTbsDocumentProcessor

      public AbstractTbsDocumentProcessor()
  • Method Details

    • preProcess

      public ProcessedTbsDocument preProcess(se.idsec.signservice.integration.document.TbsDocument document, se.idsec.signservice.integration.SignRequestInput signRequestInput, IntegrationServiceConfiguration config, DocumentCache documentCache, String callerId, String fieldName) throws se.idsec.signservice.integration.core.error.InputValidationException
      Performs a pre-processing of the supplied document where the document is validated, and in some cases updated with default settings.
      Specified by:
      preProcess in interface TbsDocumentProcessor<T>
      Parameters:
      document - the document to process
      signRequestInput - the sign request input
      config - the current policy configuration
      documentCache - the document cache
      callerId - optional ID for the calling entity
      fieldName - used for error reporting and logging
      Returns:
      a processed (and possibly updated) document
      Throws:
      se.idsec.signservice.integration.core.error.InputValidationException - for validation errors
    • process

      public final se.swedenconnect.schemas.csig.dssext_1_1.SignTaskData process(@Nonnull ProcessedTbsDocument document, @Nonnull String signatureAlgorithm, @Nonnull IntegrationServiceConfiguration config) throws DocumentProcessingException
      Prepares the document for signing by creating a SignTaskData element.
      Specified by:
      process in interface TbsDocumentProcessor<T>
      Parameters:
      document - the document to sign
      signatureAlgorithm - the signature algorithm to be used for signing the document
      config - profile configuration
      Returns:
      a SignTaskData element
      Throws:
      DocumentProcessingException - for processing errors
    • calculateToBeSigned

      protected abstract TbsCalculationResult calculateToBeSigned(ProcessedTbsDocument document, String signatureAlgorithm, IntegrationServiceConfiguration config) throws DocumentProcessingException
      Calculates the ToBeSignedBytes, and optionally AdES data, that will be part of the SignTaskData.
      Parameters:
      document - the document to sign
      signatureAlgorithm - the signature algorithm to be used for signing the document
      config - the profile configuration
      Returns:
      the TBS bytes and optionally AdES data
      Throws:
      DocumentProcessingException - for processing errors
    • getEtsiAdesRequirementValidator

      protected abstract EtsiAdesRequirementValidator getEtsiAdesRequirementValidator()
      Gets the validator for checking AdES requirements.
      Returns:
      validator for AdES requirements
    • validateDocumentContent

      protected T validateDocumentContent(se.idsec.signservice.integration.document.TbsDocument document, IntegrationServiceConfiguration config, String fieldName) throws se.idsec.signservice.integration.core.error.InputValidationException
      Validates the document contents. The default implementation invokes DocumentDecoder.decodeDocument(String).
      Parameters:
      document - the document holding the content to validate
      config - the current policy configuration
      fieldName - used for error reporting and logging
      Returns:
      the contents represented according to the document format
      Throws:
      se.idsec.signservice.integration.core.error.InputValidationException - for validation errors
    • getTbsDocumentValidator

      protected TbsDocumentValidator getTbsDocumentValidator()
      Gets the TbsDocumentValidator to use while processing.
      Returns:
      a TbsDocumentValidator
    • afterPropertiesSet

      @PostConstruct public void afterPropertiesSet() throws Exception
      Ensures that the getEtsiAdesRequirementValidator() does not return null and sets up a TbsDocumentValidator.

      Note: If executing in a Spring Framework environment this method is automatically invoked after all properties have been assigned. Otherwise it should be explicitly invoked.

      Throws:
      Exception - for init errors