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 Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoid
Ensures that thegetEtsiAdesRequirementValidator()
does not returnnull
and sets up aTbsDocumentValidator
.protected abstract TbsCalculationResult
calculateToBeSigned
(ProcessedTbsDocument document, String signatureAlgorithm, IntegrationServiceConfiguration config) Calculates the ToBeSignedBytes, and optionally AdES data, that will be part of theSignTaskData
.protected abstract EtsiAdesRequirementValidator
Gets the validator for checking AdES requirements.protected TbsDocumentValidator
Gets theTbsDocumentValidator
to use while processing.preProcess
(se.idsec.signservice.integration.document.TbsDocument document, se.idsec.signservice.integration.SignRequestInput signRequestInput, IntegrationServiceConfiguration config, DocumentCache documentCache, String callerId, String fieldName) Performs a pre-processing of the supplied document where the document is validated, and in some cases updated with default settings.final se.swedenconnect.schemas.csig.dssext_1_1.SignTaskData
process
(ProcessedTbsDocument document, String signatureAlgorithm, IntegrationServiceConfiguration config) Prepares the document for signing by creating aSignTaskData
element.protected T
validateDocumentContent
(se.idsec.signservice.integration.document.TbsDocument document, IntegrationServiceConfiguration config, String fieldName) Validates the document contents.Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
Methods inherited from interface se.idsec.signservice.integration.document.DocumentProcessor
getDocumentDecoder, getDocumentEncoder
Methods inherited from interface se.idsec.signservice.integration.document.TbsDocumentProcessor
supports
-
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 interfaceTbsDocumentProcessor<T>
- Parameters:
document
- the document to processsignRequestInput
- the sign request inputconfig
- the current policy configurationdocumentCache
- the document cachecallerId
- optional ID for the calling entityfieldName
- 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 aSignTaskData
element.- Specified by:
process
in interfaceTbsDocumentProcessor<T>
- Parameters:
document
- the document to signsignatureAlgorithm
- the signature algorithm to be used for signing the documentconfig
- 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 theSignTaskData
.- Parameters:
document
- the document to signsignatureAlgorithm
- the signature algorithm to be used for signing the documentconfig
- the profile configuration- Returns:
- the TBS bytes and optionally AdES data
- Throws:
DocumentProcessingException
- for processing errors
-
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 invokesDocumentDecoder.decodeDocument(String)
.- Parameters:
document
- the document holding the content to validateconfig
- the current policy configurationfieldName
- 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
Gets theTbsDocumentValidator
to use while processing.- Returns:
- a TbsDocumentValidator
-
afterPropertiesSet
Ensures that thegetEtsiAdesRequirementValidator()
does not returnnull
and sets up aTbsDocumentValidator
.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
-