Class DefaultSignResponseProcessor
java.lang.Object
se.idsec.signservice.integration.process.impl.DefaultSignResponseProcessor
- All Implemented Interfaces:
SignResponseProcessor
Default implementation of the
SignResponseProcessor
interface.- Author:
- Martin Lindström (martin@idsec.se), Stefan Santesson (stefan@idsec.se)
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoid
Ensures that all required properties have been assigned.protected void
checkSignTaskData
(se.swedenconnect.schemas.csig.dssext_1_1.SignTaskData signTaskData, SignRequestWrapper signRequest) Make checks that the suppliedSignTaskData
object follows the specs.Gets the processing configuration that this processor is configured with.protected List
<X509Certificate> getSignerCertificateChain
(se.swedenconnect.schemas.csig.dssext_1_1.SignatureCertificateChain signatureCertificateChain, String requestID) Gets a list ofX509Certificate
by reading the suppliedSignatureCertificateChain
.protected se.idsec.signservice.integration.document.TbsDocument
getTbsDocument
(se.swedenconnect.schemas.csig.dssext_1_1.SignTaskData signTaskData, SignatureSessionState state) Given aSignTaskData
the method finds the corresponding TBS document from the session state.protected <T,
X extends AdesObject>
se.idsec.signservice.integration.document.SignedDocumentprocessDocument
(SignedDocumentProcessor<T, X> processor, se.swedenconnect.schemas.csig.dssext_1_1.SignTaskData signTaskData, List<X509Certificate> signerCertificateChain, SignatureSessionState state, SignResponseWrapper signResponse, se.idsec.signservice.integration.SignResponseProcessingParameters parameters) Compiles a signed document and validates it.se.idsec.signservice.integration.SignatureResult
processSignResponse
(String signResponse, SignatureSessionState sessionState, IntegrationServiceConfiguration config, se.idsec.signservice.integration.SignResponseProcessingParameters parameters) Processes the supplied SignResponse according to the supplied processing parameters and the session state.void
setCertificateValidators
(Map<String, CertificateValidator> certificateValidators) Assigns a mapping between policies and certificate validators.void
setProcessingConfiguration
(SignResponseProcessingConfig processingConfiguration) Assigns the processing config settings.void
setSignedDocumentProcessors
(List<SignedDocumentProcessor<?, ?>> signedDocumentProcessors) Assigns the processors for handling the signed documents.void
setSignerAssertionInfoProcessor
(SignerAssertionInfoProcessor signerAssertionInfoProcessor) Assigns the processor for handling the signer assertion info from the sign response.protected void
validateReceivedRequest
(byte[] request, SignRequestWrapper sentRequest) Validates the received Request element (throws only if strict processing is active).protected void
validateResponseTime
(XMLGregorianCalendar responseTime, XMLGregorianCalendar requestTime, String requestID) Validates the response time from the SignResponse is valid.
-
Constructor Details
-
DefaultSignResponseProcessor
public DefaultSignResponseProcessor()Constructor.
-
-
Method Details
-
processSignResponse
@Nonnull public se.idsec.signservice.integration.SignatureResult processSignResponse(@Nonnull String signResponse, @Nonnull SignatureSessionState sessionState, @Nonnull IntegrationServiceConfiguration config, se.idsec.signservice.integration.SignResponseProcessingParameters parameters) throws se.idsec.signservice.integration.SignResponseErrorStatusException, se.idsec.signservice.integration.core.error.SignServiceIntegrationException Processes the supplied SignResponse according to the supplied processing parameters and the session state.- Specified by:
processSignResponse
in interfaceSignResponseProcessor
- Parameters:
signResponse
- the encoded SignResponse messagesessionState
- the stateconfig
- the policy configurationparameters
- optional processing parameters- Returns:
- a signature response
- Throws:
se.idsec.signservice.integration.SignResponseErrorStatusException
- if the sign service reported an errorse.idsec.signservice.integration.core.error.SignServiceIntegrationException
- for processing and validation errors
-
processDocument
protected <T,X extends AdesObject> se.idsec.signservice.integration.document.SignedDocument processDocument(SignedDocumentProcessor<T, X> processor, se.swedenconnect.schemas.csig.dssext_1_1.SignTaskData signTaskData, List<X509Certificate> signerCertificateChain, SignatureSessionState state, SignResponseWrapper signResponse, se.idsec.signservice.integration.SignResponseProcessingParameters parameters) throws se.idsec.signservice.integration.core.error.SignServiceIntegrationExceptionCompiles a signed document and validates it.- Parameters:
processor
- the document processorsignTaskData
- the sign task datasignerCertificateChain
- the certificate chainstate
- the session statesignResponse
- the sign responseparameters
- optional processing parameters- Returns:
- a signed document
- Throws:
se.idsec.signservice.integration.core.error.SignServiceIntegrationException
- for processing errors
-
validateResponseTime
protected void validateResponseTime(XMLGregorianCalendar responseTime, XMLGregorianCalendar requestTime, String requestID) throws se.idsec.signservice.integration.core.error.SignServiceIntegrationException Validates the response time from the SignResponse is valid. The method also ensures that the server processing time hasn't exceeded or max limit.- Parameters:
responseTime
- the response timerequestTime
- the time when the request was sentrequestID
- the requestID (for logging)- Throws:
se.idsec.signservice.integration.core.error.SignServiceIntegrationException
- for expired responses
-
validateReceivedRequest
protected void validateReceivedRequest(byte[] request, SignRequestWrapper sentRequest) throws se.idsec.signservice.integration.core.error.SignServiceIntegrationException Validates the received Request element (throws only if strict processing is active).- Parameters:
request
- the received Request elementsentRequest
- the request that was actually sent- Throws:
se.idsec.signservice.integration.core.error.SignServiceIntegrationException
- if the Request is not present or differs from what was sent
-
getSignerCertificateChain
protected List<X509Certificate> getSignerCertificateChain(se.swedenconnect.schemas.csig.dssext_1_1.SignatureCertificateChain signatureCertificateChain, String requestID) throws se.idsec.signservice.integration.core.error.SignServiceIntegrationException Gets a list ofX509Certificate
by reading the suppliedSignatureCertificateChain
.- Parameters:
signatureCertificateChain
- the chain received in the responserequestID
- the request ID for the response- Returns:
- a list of X509Certificate objects
- Throws:
se.idsec.signservice.integration.core.error.SignServiceIntegrationException
- for decoding errors
-
checkSignTaskData
protected void checkSignTaskData(se.swedenconnect.schemas.csig.dssext_1_1.SignTaskData signTaskData, SignRequestWrapper signRequest) throws se.idsec.signservice.integration.core.error.SignServiceIntegrationException Make checks that the suppliedSignTaskData
object follows the specs.- Parameters:
signTaskData
- the object to checksignRequest
- the sign request corresponding to the response in which we received the SignTaskData- Throws:
se.idsec.signservice.integration.core.error.SignServiceIntegrationException
- for validation errors
-
getTbsDocument
protected se.idsec.signservice.integration.document.TbsDocument getTbsDocument(se.swedenconnect.schemas.csig.dssext_1_1.SignTaskData signTaskData, SignatureSessionState state) throws se.idsec.signservice.integration.core.error.SignServiceIntegrationException Given aSignTaskData
the method finds the corresponding TBS document from the session state.- Parameters:
signTaskData
- the signaturestate
- the state holding the TBS documents- Returns:
- a TbsDocument
- Throws:
se.idsec.signservice.integration.core.error.SignServiceIntegrationException
- if no matching TBS document is found
-
setSignedDocumentProcessors
public void setSignedDocumentProcessors(List<SignedDocumentProcessor<?, ?>> signedDocumentProcessors) Assigns the processors for handling the signed documents.- Parameters:
signedDocumentProcessors
- document processors
-
setSignerAssertionInfoProcessor
public void setSignerAssertionInfoProcessor(SignerAssertionInfoProcessor signerAssertionInfoProcessor) Assigns the processor for handling the signer assertion info from the sign response. If not assigned an instance ofDefaultSignerAssertionInfoProcessor
will be used.- Parameters:
signerAssertionInfoProcessor
- signer assertion info processor
-
setProcessingConfiguration
Assigns the processing config settings.- Parameters:
processingConfiguration
- the processing config settings
-
getProcessingConfiguration
Gets the processing configuration that this processor is configured with.- Specified by:
getProcessingConfiguration
in interfaceSignResponseProcessor
- Returns:
- the processing configuration
-
setCertificateValidators
Assigns a mapping between policies and certificate validators. It does not matter what trust anchor each validator has been configured with since this will be explicitly set for each call. This information is taken from theIntegrationServiceDefaultConfiguration.getTrustAnchors()
.If no mapping for a given policy exists, a default validator will be used (see
SimpleCertificateValidator
).- Parameters:
certificateValidators
- policy to certificate validator mappings
-
afterPropertiesSet
Ensures that all required properties have been assigned. The method also makes sure that theprocessingConfiguration
property is assigned (by defaultSignResponseProcessingConfig.defaultSignResponseProcessingConfig()
is used) and thatsignerAssertionInfoProcessor
is set (by default aDefaultSignerAssertionInfoProcessor
is used).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
- if not all settings are correct
-