use of com.helger.smpclient.peppol.jaxb.EndpointType in project as2-peppol-servlet by phax.
the class AS2ServletSBDModule method handle.
public void handle(@Nonnull final String sAction, @Nonnull final IMessage aMsg, @Nullable final Map<String, Object> aOptions) throws AS2Exception {
try {
// Set the signing algorithm, so that the MIC calculation is done
// correctly
aMsg.partnership().setSigningAlgorithm(m_eAS2Version.getCryptoAlgorithmSign());
aMsg.partnership().setVerifyUseCertificateInBodyPart(ETriState.TRUE);
// Interpret content as SBD
final StandardBusinessDocument aSBD = new SBDMarshaller().read(aMsg.getData().getInputStream());
if (aSBD == null)
throw new IllegalArgumentException("Failed to interpret the passed document as a Standard Business Document!");
if (AS2PeppolServletConfiguration.isReceiverCheckEnabled()) {
final PeppolSBDHDocument aDD = new PeppolSBDHDocumentReader().extractData(aSBD);
final String sLogPrefix = "[" + aDD.getInstanceIdentifier() + "] ";
// Get the endpoint information required from the recipient
final EndpointType aReceiverEndpoint = _getReceiverEndpoint(sLogPrefix, aDD.getReceiverAsIdentifier(), aDD.getDocumentTypeAsIdentifier(), aDD.getProcessAsIdentifier());
if (aReceiverEndpoint == null) {
throw new AS2Exception(sLogPrefix + "Failed to resolve endpoint for provided receiver/documentType/process - not handling document");
}
// Check if the message is for us
_checkIfReceiverEndpointURLMatches(sLogPrefix, aReceiverEndpoint);
// Get the recipient certificate from the SMP
_checkIfEndpointCertificateMatches(sLogPrefix, aReceiverEndpoint);
} else {
LOGGER.info("Endpoint checks for the AS2 AP are disabled");
}
// Handle incoming document via SPI
final HttpHeaderMap aHeaders = aMsg.headers().getClone();
for (final IAS2IncomingSBDHandlerSPI aHandler : m_aHandlers) aHandler.handleIncomingSBD(aHeaders, aSBD);
} catch (final Exception ex) {
// Something went wrong
throw WrappedAS2Exception.wrap(ex);
}
}
Aggregations