Search in sources :

Example 11 with IAS4IncomingMessageMetadata

use of com.helger.phase4.messaging.IAS4IncomingMessageMetadata in project phase4 by phax.

the class Phase4PeppolServletMessageProcessorSPI method processAS4UserMessage.

@Nonnull
public AS4MessageProcessorResult processAS4UserMessage(@Nonnull final IAS4IncomingMessageMetadata aMessageMetadata, @Nonnull final HttpHeaderMap aHttpHeaders, @Nonnull final Ebms3UserMessage aUserMessage, @Nonnull final IPMode aSrcPMode, @Nullable final Node aPayload, @Nullable final ICommonsList<WSS4JAttachment> aIncomingAttachments, @Nonnull final IAS4MessageState aState, @Nonnull final ICommonsList<Ebms3Error> aProcessingErrorMessages) {
    if (LOGGER.isDebugEnabled())
        LOGGER.debug("Invoking processAS4UserMessage");
    final String sMessageID = aUserMessage.getMessageInfo().getMessageId();
    final String sService = aUserMessage.getCollaborationInfo().getServiceValue();
    final String sAction = aUserMessage.getCollaborationInfo().getAction();
    final String sConversationID = aUserMessage.getCollaborationInfo().getConversationId();
    final String sLogPrefix = "[" + sMessageID + "] ";
    final Locale aDisplayLocale = aState.getLocale();
    // Debug log
    if (LOGGER.isDebugEnabled()) {
        if (aSrcPMode == null)
            LOGGER.debug(sLogPrefix + "  No Source PMode present");
        else
            LOGGER.debug(sLogPrefix + "  Source PMode = " + aSrcPMode.getID());
        LOGGER.debug(sLogPrefix + "  AS4 Message ID = '" + sMessageID + "'");
        LOGGER.debug(sLogPrefix + "  AS4 Service = '" + sService + "'");
        LOGGER.debug(sLogPrefix + "  AS4 Action = '" + sAction + "'");
        LOGGER.debug(sLogPrefix + "  AS4 ConversationId = '" + sConversationID + "'");
        // Log source properties
        if (aUserMessage.getMessageProperties() != null && aUserMessage.getMessageProperties().hasPropertyEntries()) {
            LOGGER.debug(sLogPrefix + "  AS4 MessageProperties:");
            for (final Ebms3Property p : aUserMessage.getMessageProperties().getProperty()) LOGGER.debug(sLogPrefix + "    [" + p.getName() + "] = [" + p.getValue() + "]");
        } else
            LOGGER.debug(sLogPrefix + "  No AS4 Mesage Properties present");
        if (aPayload == null)
            LOGGER.debug(sLogPrefix + "  No SOAP Body Payload present");
        else
            LOGGER.debug(sLogPrefix + "  SOAP Body Payload = " + XMLWriter.getNodeAsString(aPayload));
    }
    // Read all attachments
    final ICommonsList<ReadAttachment> aReadAttachments = new CommonsArrayList<>();
    if (aIncomingAttachments != null) {
        int nAttachmentIndex = 0;
        for (final IAS4Attachment aIncomingAttachment : aIncomingAttachments) {
            final ReadAttachment a = new ReadAttachment();
            a.m_sID = aIncomingAttachment.getId();
            a.m_sMimeType = aIncomingAttachment.getMimeType();
            a.m_sUncompressedMimeType = aIncomingAttachment.getUncompressedMimeType();
            a.m_aCharset = aIncomingAttachment.getCharset();
            a.m_eCompressionMode = aIncomingAttachment.getCompressionMode();
            try (final InputStream aSIS = aIncomingAttachment.getSourceStream()) {
                final NonBlockingByteArrayOutputStream aBAOS = new NonBlockingByteArrayOutputStream();
                if (StreamHelper.copyInputStreamToOutputStreamAndCloseOS(aSIS, aBAOS).isSuccess()) {
                    a.m_aPayloadBytes = aBAOS.getBufferOrCopy();
                }
            } catch (final IOException | AS4DecompressException ex) {
            // Fall through
            }
            if (a.m_aPayloadBytes == null) {
                LOGGER.error(sLogPrefix + "Failed to decompress the payload");
                aProcessingErrorMessages.add(EEbmsError.EBMS_DECOMPRESSION_FAILURE.getAsEbms3Error(aDisplayLocale, aState.getMessageID()));
                return AS4MessageProcessorResult.createFailure(null);
            }
            // Read data as SBDH
            // Hint for production systems: this may take a huge amount of memory,
            // if the payload is large
            final ErrorList aSBDHErrors = new ErrorList();
            a.m_aSBDH = SBDHReader.standardBusinessDocument().setValidationEventHandler(new WrappedCollectingValidationEventHandler(aSBDHErrors)).read(a.m_aPayloadBytes);
            if (a.m_aSBDH == null) {
                if (aSBDHErrors.isEmpty()) {
                    final String sMsg = "Failed to read the provided SBDH document";
                    LOGGER.error(sLogPrefix + sMsg);
                    aProcessingErrorMessages.add(EEbmsError.EBMS_OTHER.getAsEbms3Error(aDisplayLocale, aState.getMessageID(), sMsg));
                } else {
                    for (final IError aError : aSBDHErrors) {
                        final String sMsg = "Peppol SBDH Issue: " + aError.getAsString(aDisplayLocale);
                        LOGGER.error(sLogPrefix + sMsg);
                        aProcessingErrorMessages.add(EEbmsError.EBMS_OTHER.getAsEbms3Error(aDisplayLocale, aState.getMessageID(), sMsg));
                    }
                }
                return AS4MessageProcessorResult.createFailure(null);
            }
            aReadAttachments.add(a);
            if (LOGGER.isDebugEnabled())
                LOGGER.debug(sLogPrefix + "AS4 Attachment " + nAttachmentIndex + " with ID [" + a.m_sID + "] uses [" + a.m_sMimeType + (a.m_sUncompressedMimeType == null ? null : " - uncompressed " + a.m_sUncompressedMimeType) + "] and [" + StringHelper.getToString(a.m_aCharset, "no charset") + "] and length is " + (a.m_aPayloadBytes == null ? "<error>" : Integer.toString(a.m_aPayloadBytes.length)) + " bytes" + (a.m_eCompressionMode == null ? "" : " of compressed payload"));
            nAttachmentIndex++;
        }
    }
    if (aReadAttachments.size() != 1) {
        // In Peppol there must be exactly one payload
        final String sMsg = "In Peppol exactly one payload attachment is expected. This request has " + aReadAttachments.size() + " attachments";
        LOGGER.error(sLogPrefix + sMsg);
        return AS4MessageProcessorResult.createFailure(sMsg);
    }
    // The one and only
    final ReadAttachment aReadAttachment = aReadAttachments.getFirst();
    // Extract Peppol values from SBD
    final PeppolSBDHDocument aPeppolSBD;
    try {
        if (LOGGER.isDebugEnabled())
            LOGGER.debug(sLogPrefix + "Now evaluating the SBDH against Peppol rules");
        final boolean bPerformValueChecks = Phase4PeppolServletConfiguration.isPerformSBDHValueChecks();
        aPeppolSBD = new PeppolSBDHDocumentReader(SimpleIdentifierFactory.INSTANCE).setPerformValueChecks(bPerformValueChecks).extractData(aReadAttachment.standardBusinessDocument());
        if (LOGGER.isDebugEnabled())
            LOGGER.debug(sLogPrefix + "The provided SBDH is valid according to Peppol rules, with value checks being " + (bPerformValueChecks ? "enabled" : "disabled"));
    } catch (final PeppolSBDHDocumentReadException ex) {
        final String sMsg = "Failed to extract the Peppol data from SBDH. Technical details: " + ex.getClass().getName() + " - " + ex.getMessage();
        LOGGER.error(sLogPrefix + sMsg);
        return AS4MessageProcessorResult.createFailure(sMsg);
    }
    if (m_aHandlers.isEmpty()) {
        LOGGER.error(sLogPrefix + "No SPI handler is present - the message is unhandled and discarded");
    } else {
        // Start consistency checks?
        final Phase4PeppolReceiverCheckData aReceiverCheckData = m_aReceiverCheckData != null ? m_aReceiverCheckData : Phase4PeppolServletConfiguration.getAsReceiverCheckData();
        if (aReceiverCheckData != null) {
            if (LOGGER.isDebugEnabled())
                LOGGER.debug("Performing check if the provided data is registered in our SMP");
            try {
                // Get the endpoint information required from the recipient
                // Check if an endpoint is registered
                final IParticipantIdentifier aReceiverID = aPeppolSBD.getReceiverAsIdentifier();
                final IDocumentTypeIdentifier aDocTypeID = aPeppolSBD.getDocumentTypeAsIdentifier();
                final IProcessIdentifier aProcessID = aPeppolSBD.getProcessAsIdentifier();
                final EndpointType aReceiverEndpoint = _getReceiverEndpoint(sLogPrefix, aReceiverCheckData.getSMPClient(), aReceiverID, aDocTypeID, aProcessID);
                if (aReceiverEndpoint == null) {
                    final String sMsg = "Failed to resolve SMP endpoint for provided receiver ID (" + (aReceiverID == null ? "null" : aReceiverID.getURIEncoded()) + ")/documentType ID (" + (aDocTypeID == null ? "null" : aDocTypeID.getURIEncoded()) + ")/process ID (" + (aProcessID == null ? "null" : aProcessID.getURIEncoded()) + ")/transport profile (" + m_aTransportProfile.getID() + ") - not handling incoming AS4 document";
                    LOGGER.error(sLogPrefix + sMsg);
                    return AS4MessageProcessorResult.createFailure(sMsg);
                }
                // Check if the message is for us
                _checkIfReceiverEndpointURLMatches(sLogPrefix, aReceiverCheckData.getAS4EndpointURL(), aReceiverEndpoint);
                // Get the recipient certificate from the SMP
                _checkIfEndpointCertificateMatches(sLogPrefix, aReceiverCheckData.getAPCertificate(), aReceiverEndpoint);
            } catch (final Phase4Exception ex) {
                final String sMsg = "The addressing data contained in the SBDH could not be verified. Technical details: " + ex.getClass().getName() + " - " + ex.getMessage();
                LOGGER.error(sLogPrefix + sMsg);
                return AS4MessageProcessorResult.createFailure(sMsg);
            }
        } else {
            LOGGER.info(sLogPrefix + "Endpoint checks for incoming AS4 messages are disabled");
        }
        for (final IPhase4PeppolIncomingSBDHandlerSPI aHandler : m_aHandlers) {
            try {
                if (LOGGER.isDebugEnabled())
                    LOGGER.debug(sLogPrefix + "Invoking Peppol handler " + aHandler);
                aHandler.handleIncomingSBD(aMessageMetadata, aHttpHeaders.getClone(), aUserMessage.clone(), aReadAttachment.payloadBytes(), aReadAttachment.standardBusinessDocument(), aPeppolSBD, aState);
            } catch (final Exception ex) {
                LOGGER.error(sLogPrefix + "Error invoking Peppol handler " + aHandler, ex);
                if (aHandler.exceptionTranslatesToAS4Error()) {
                    final String sMsg = "The incoming Peppol message could not be processed. Technical details: " + ex.getClass().getName() + " - " + ex.getMessage();
                    LOGGER.error(sLogPrefix + sMsg);
                    return AS4MessageProcessorResult.createFailure(sMsg);
                }
            }
        }
    }
    return AS4MessageProcessorResult.createSuccess();
}
Also used : Locale(java.util.Locale) AS4DecompressException(com.helger.phase4.attachment.AS4DecompressException) IAS4Attachment(com.helger.phase4.attachment.IAS4Attachment) WrappedCollectingValidationEventHandler(com.helger.jaxb.validation.WrappedCollectingValidationEventHandler) IDocumentTypeIdentifier(com.helger.peppolid.IDocumentTypeIdentifier) IProcessIdentifier(com.helger.peppolid.IProcessIdentifier) Phase4Exception(com.helger.phase4.util.Phase4Exception) EndpointType(com.helger.xsds.peppol.smp1.EndpointType) PeppolSBDHDocumentReadException(com.helger.peppol.sbdh.read.PeppolSBDHDocumentReadException) Ebms3Property(com.helger.phase4.ebms3header.Ebms3Property) PeppolSBDHDocument(com.helger.peppol.sbdh.PeppolSBDHDocument) InputStream(java.io.InputStream) NonBlockingByteArrayOutputStream(com.helger.commons.io.stream.NonBlockingByteArrayOutputStream) PeppolSBDHDocumentReader(com.helger.peppol.sbdh.read.PeppolSBDHDocumentReader) IOException(java.io.IOException) IError(com.helger.commons.error.IError) AS4DecompressException(com.helger.phase4.attachment.AS4DecompressException) PeppolSBDHDocumentReadException(com.helger.peppol.sbdh.read.PeppolSBDHDocumentReadException) Phase4Exception(com.helger.phase4.util.Phase4Exception) IOException(java.io.IOException) CertificateException(java.security.cert.CertificateException) ErrorList(com.helger.commons.error.list.ErrorList) CommonsArrayList(com.helger.commons.collection.impl.CommonsArrayList) IParticipantIdentifier(com.helger.peppolid.IParticipantIdentifier) Nonnull(javax.annotation.Nonnull)

Example 12 with IAS4IncomingMessageMetadata

use of com.helger.phase4.messaging.IAS4IncomingMessageMetadata in project phase4 by phax.

the class MockMessageProcessorCheckingStreamsSPI method processAS4SignalMessage.

@Nonnull
public AS4SignalMessageProcessorResult processAS4SignalMessage(@Nonnull final IAS4IncomingMessageMetadata aMessageMetadata, @Nonnull final HttpHeaderMap aHttpHeaders, @Nonnull final Ebms3SignalMessage aSignalMessage, @Nonnull final IPMode aPmode, @Nonnull final IAS4MessageState aState, @Nonnull final ICommonsList<Ebms3Error> aProcessingErrorMessages) {
    if (aSignalMessage.getReceipt() != null) {
        // Receipt - just acknowledge
        return AS4SignalMessageProcessorResult.createSuccess();
    }
    if (!aSignalMessage.getError().isEmpty()) {
        // Error - just acknowledge
        return AS4SignalMessageProcessorResult.createSuccess();
    }
    final Ebms3PullRequest aPR = aSignalMessage.getPullRequest();
    if (aPR != null && aPR.getMpc().equals("TWO-SPI")) {
        final Node aPayload = DOMReader.readXMLDOM(new ClassPathResource(AS4TestConstants.TEST_SOAP_BODY_PAYLOAD_XML));
        // Add properties
        final ICommonsList<Ebms3Property> aEbms3Properties = AS4TestConstants.getEBMSProperties();
        final Ebms3MessageInfo aMessageInfo = aSignalMessage.getMessageInfo();
        final Ebms3MessageInfo aEbms3MessageInfo = MessageHelperMethods.createEbms3MessageInfo(aMessageInfo.getMessageId());
        final Ebms3PayloadInfo aEbms3PayloadInfo = MessageHelperMethods.createEbms3PayloadInfo(aPayload != null, null);
        final Ebms3CollaborationInfo aEbms3CollaborationInfo;
        final Ebms3PartyInfo aEbms3PartyInfo;
        aEbms3CollaborationInfo = MessageHelperMethods.createEbms3CollaborationInfo("PullPMode", DEFAULT_AGREEMENT, AS4TestConstants.TEST_SERVICE_TYPE, MockPModeGenerator.SOAP11_SERVICE, AS4TestConstants.TEST_ACTION, AS4TestConstants.TEST_CONVERSATION_ID);
        aEbms3PartyInfo = MessageHelperMethods.createEbms3PartyInfo(CAS4.DEFAULT_INITIATOR_URL, "pullinitiator", CAS4.DEFAULT_RESPONDER_URL, "pullresponder");
        final Ebms3MessageProperties aEbms3MessageProperties = MessageHelperMethods.createEbms3MessageProperties(aEbms3Properties);
        final Ebms3UserMessage aUserMessage = new Ebms3UserMessage();
        aUserMessage.setCollaborationInfo(aEbms3CollaborationInfo);
        aUserMessage.setMessageInfo(aEbms3MessageInfo);
        aUserMessage.setMessageProperties(aEbms3MessageProperties);
        aUserMessage.setPartyInfo(aEbms3PartyInfo);
        aUserMessage.setPayloadInfo(aEbms3PayloadInfo);
        aUserMessage.setMpc(aSignalMessage.getPullRequest().getMpc());
        return AS4SignalMessageProcessorResult.createSuccess(null, null, aUserMessage);
    }
    return AS4SignalMessageProcessorResult.createSuccess();
}
Also used : Ebms3MessageProperties(com.helger.phase4.ebms3header.Ebms3MessageProperties) Ebms3PayloadInfo(com.helger.phase4.ebms3header.Ebms3PayloadInfo) Ebms3PullRequest(com.helger.phase4.ebms3header.Ebms3PullRequest) Ebms3CollaborationInfo(com.helger.phase4.ebms3header.Ebms3CollaborationInfo) Node(org.w3c.dom.Node) Ebms3UserMessage(com.helger.phase4.ebms3header.Ebms3UserMessage) Ebms3MessageInfo(com.helger.phase4.ebms3header.Ebms3MessageInfo) ClassPathResource(com.helger.commons.io.resource.ClassPathResource) Ebms3PartyInfo(com.helger.phase4.ebms3header.Ebms3PartyInfo) Ebms3Property(com.helger.phase4.ebms3header.Ebms3Property) Nonnull(javax.annotation.Nonnull)

Example 13 with IAS4IncomingMessageMetadata

use of com.helger.phase4.messaging.IAS4IncomingMessageMetadata in project phase4 by phax.

the class MockMessageProcessorSPI method processAS4SignalMessage.

@Nonnull
public AS4SignalMessageProcessorResult processAS4SignalMessage(@Nonnull final IAS4IncomingMessageMetadata aMessageMetadata, @Nonnull final HttpHeaderMap aHttpHeaders, @Nonnull final Ebms3SignalMessage aSignalMessage, @Nullable final IPMode aPMode, @Nonnull final IAS4MessageState aState, @Nonnull final ICommonsList<Ebms3Error> aProcessingErrorMessages) {
    if (aSignalMessage.getReceipt() != null) {
        // Receipt - just acknowledge
        return AS4SignalMessageProcessorResult.createSuccess();
    }
    if (!aSignalMessage.getError().isEmpty()) {
        // Error - just acknowledge
        return AS4SignalMessageProcessorResult.createSuccess();
    }
    // Must be a pull-request
    final Ebms3PullRequest aPullRequest = aSignalMessage.getPullRequest();
    if (aPullRequest != null) {
        if (aPullRequest.getMpc().equals(MPC_FAILURE)) {
            return AS4SignalMessageProcessorResult.createFailure("Error in creating the usermessage - mock MPC 'failure' was used!");
        }
        // Empty MPC
        if (aPullRequest.getMpc().equals(MPC_EMPTY)) {
            return AS4SignalMessageProcessorResult.createSuccess();
        }
    }
    final Node aPayload = DOMReader.readXMLDOM(new ClassPathResource(AS4TestConstants.TEST_SOAP_BODY_PAYLOAD_XML));
    // Add properties
    final ICommonsList<Ebms3Property> aEbms3Properties = AS4TestConstants.getEBMSProperties();
    final Ebms3MessageInfo aMessageInfo = aSignalMessage.getMessageInfo();
    final Ebms3MessageInfo aEbms3MessageInfo = MessageHelperMethods.createEbms3MessageInfo(aMessageInfo.getMessageId());
    final Ebms3PayloadInfo aEbms3PayloadInfo = MessageHelperMethods.createEbms3PayloadInfo(aPayload != null, null);
    final Ebms3CollaborationInfo aEbms3CollaborationInfo;
    final Ebms3PartyInfo aEbms3PartyInfo;
    aEbms3CollaborationInfo = MessageHelperMethods.createEbms3CollaborationInfo("PullPMode", DEFAULT_AGREEMENT, AS4TestConstants.TEST_SERVICE_TYPE, MockPModeGenerator.SOAP11_SERVICE, AS4TestConstants.TEST_ACTION, AS4TestConstants.TEST_CONVERSATION_ID);
    aEbms3PartyInfo = MessageHelperMethods.createEbms3PartyInfo(CAS4.DEFAULT_INITIATOR_URL, "pullinitiator", CAS4.DEFAULT_RESPONDER_URL, "pullresponder");
    final Ebms3MessageProperties aEbms3MessageProperties = MessageHelperMethods.createEbms3MessageProperties(aEbms3Properties);
    final Ebms3UserMessage aUserMessage = new Ebms3UserMessage();
    aUserMessage.setCollaborationInfo(aEbms3CollaborationInfo);
    aUserMessage.setMessageInfo(aEbms3MessageInfo);
    aUserMessage.setMessageProperties(aEbms3MessageProperties);
    aUserMessage.setPartyInfo(aEbms3PartyInfo);
    aUserMessage.setPayloadInfo(aEbms3PayloadInfo);
    if (aPullRequest != null)
        aUserMessage.setMpc(aPullRequest.getMpc());
    return AS4SignalMessageProcessorResult.createSuccess(null, null, aUserMessage);
}
Also used : Ebms3MessageProperties(com.helger.phase4.ebms3header.Ebms3MessageProperties) Ebms3PayloadInfo(com.helger.phase4.ebms3header.Ebms3PayloadInfo) Ebms3PullRequest(com.helger.phase4.ebms3header.Ebms3PullRequest) Ebms3CollaborationInfo(com.helger.phase4.ebms3header.Ebms3CollaborationInfo) Node(org.w3c.dom.Node) Ebms3UserMessage(com.helger.phase4.ebms3header.Ebms3UserMessage) Ebms3MessageInfo(com.helger.phase4.ebms3header.Ebms3MessageInfo) ClassPathResource(com.helger.commons.io.resource.ClassPathResource) Ebms3PartyInfo(com.helger.phase4.ebms3header.Ebms3PartyInfo) Ebms3Property(com.helger.phase4.ebms3header.Ebms3Property) Nonnull(javax.annotation.Nonnull)

Example 14 with IAS4IncomingMessageMetadata

use of com.helger.phase4.messaging.IAS4IncomingMessageMetadata in project phase4 by phax.

the class AS4WebAppListener method _initAS4.

private static void _initAS4() {
    AS4ServerInitializer.initAS4Server();
    // Store the incoming file as is
    AS4DumpManager.setIncomingDumper(new AS4IncomingDumperFileBased((aMessageMetadata, aHttpHeaderMap) -> StorageHelper.getStorageFile(aMessageMetadata, ".as4in")) {

        @Override
        public void onEndRequest(@Nonnull final IAS4IncomingMessageMetadata aMessageMetadata) {
            // Save the metadata also to a file
            final File aFile = StorageHelper.getStorageFile(aMessageMetadata, ".metadata");
            if (SimpleFileIO.writeFile(aFile, AS4MessagingHelper.getIncomingMetadataAsJson(aMessageMetadata).getAsJsonString(JsonWriterSettings.DEFAULT_SETTINGS_FORMATTED), StandardCharsets.UTF_8).isFailure())
                LOGGER.error("Failed to write metadata to '" + aFile.getAbsolutePath() + "'");
            else
                LOGGER.info("Wrote metadata to '" + aFile.getAbsolutePath() + "'");
        }
    });
    // Store the outgoings file as well
    AS4DumpManager.setOutgoingDumper(new AS4OutgoingDumperFileBased((eMsgMode, sMessageID, nTry) -> StorageHelper.getStorageFile(sMessageID, nTry, ".as4out")));
}
Also used : ServletRegistration(javax.servlet.ServletRegistration) LoggerFactory(org.slf4j.LoggerFactory) AS4Configuration(com.helger.phase4.config.AS4Configuration) IUserManager(com.helger.photon.security.user.IUserManager) SLF4JBridgeHandler(org.slf4j.bridge.SLF4JBridgeHandler) JsonWriterSettings(com.helger.json.serialize.JsonWriterSettings) CommandMap(javax.activation.CommandMap) CSecurity(com.helger.photon.security.CSecurity) CMimeType(com.helger.commons.mime.CMimeType) Locale(java.util.Locale) Map(java.util.Map) IAS4IncomingMessageMetadata(com.helger.phase4.messaging.IAS4IncomingMessageMetadata) GlobalDebug(com.helger.commons.debug.GlobalDebug) Nonnull(javax.annotation.Nonnull) AS4CryptoFactoryProperties(com.helger.phase4.crypto.AS4CryptoFactoryProperties) Nullable(javax.annotation.Nullable) AS4IncomingDumperFileBased(com.helger.phase4.dump.AS4IncomingDumperFileBased) Logger(org.slf4j.Logger) StorageHelper(com.helger.phase4.server.storage.StorageHelper) AS4OutgoingDumperFileBased(com.helger.phase4.dump.AS4OutgoingDumperFileBased) WebAppListener(com.helger.photon.core.servlet.WebAppListener) File(java.io.File) StandardCharsets(java.nio.charset.StandardCharsets) WebListener(javax.servlet.annotation.WebListener) AS4DumpManager(com.helger.phase4.dump.AS4DumpManager) AS4ServerInitializer(com.helger.phase4.servlet.AS4ServerInitializer) HttpDebugger(com.helger.httpclient.HttpDebugger) SimpleFileIO(com.helger.commons.io.file.SimpleFileIO) AS4MessagingHelper(com.helger.phase4.messaging.AS4MessagingHelper) ServletContext(javax.servlet.ServletContext) RequestTrackerSettings(com.helger.xservlet.requesttrack.RequestTrackerSettings) PhotonSecurityManager(com.helger.photon.security.mgr.PhotonSecurityManager) IAS4IncomingMessageMetadata(com.helger.phase4.messaging.IAS4IncomingMessageMetadata) AS4IncomingDumperFileBased(com.helger.phase4.dump.AS4IncomingDumperFileBased) File(java.io.File) AS4OutgoingDumperFileBased(com.helger.phase4.dump.AS4OutgoingDumperFileBased)

Example 15 with IAS4IncomingMessageMetadata

use of com.helger.phase4.messaging.IAS4IncomingMessageMetadata in project phase4 by phax.

the class CustomPeppolIncomingSBDHandlerSPI method handleIncomingSBD.

public void handleIncomingSBD(@Nonnull final IAS4IncomingMessageMetadata aMessageMetadata, @Nonnull final HttpHeaderMap aHeaders, @Nonnull final Ebms3UserMessage aUserMessage, @Nonnull final byte[] aSBDBytes, @Nonnull final StandardBusinessDocument aSBD, @Nonnull final PeppolSBDHDocument aPeppolSBD, @Nonnull final IAS4MessageState aState) throws Exception {
    // Get the service from the locator
    LOGGER.info("Retrieving the handler service.");
    final ISBDHandlerService service = SDBHandlerServiceLocator.getService(ESBDHHandlerServiceSelector.CUSTOM_PEPPOL_INCOMING);
    LOGGER.info("Successfully retrieved the handler service.");
    // Inject the parameters into the service
    LOGGER.info("Injecting parameters into the handler service.");
    service.setMessageMetadata(aMessageMetadata);
    service.setHttpHeaders(aHeaders);
    service.setUserMessage(aUserMessage);
    service.setStandardBusinessDocumentBytes(aSBDBytes);
    service.setStandardBusinessDocument(aSBD);
    service.setPeppolStandardBusinessDocumentHeader(aPeppolSBD);
    service.setMessageState(aState);
    // Handle the request, might raise an exception that needs to be dealt
    // carefully
    LOGGER.info("Handling request.");
    service.handle();
    LOGGER.info("Request handled with success.");
}
Also used : ISBDHandlerService(com.helger.phase4.springboot.service.ISBDHandlerService)

Aggregations

Nonnull (javax.annotation.Nonnull)10 Ebms3UserMessage (com.helger.phase4.ebms3header.Ebms3UserMessage)7 WSS4JAttachment (com.helger.phase4.attachment.WSS4JAttachment)6 Ebms3Property (com.helger.phase4.ebms3header.Ebms3Property)6 IAS4IncomingMessageMetadata (com.helger.phase4.messaging.IAS4IncomingMessageMetadata)6 Phase4Exception (com.helger.phase4.util.Phase4Exception)6 Nullable (javax.annotation.Nullable)6 Ebms3SignalMessage (com.helger.phase4.ebms3header.Ebms3SignalMessage)5 IOException (java.io.IOException)5 Locale (java.util.Locale)5 Wrapper (com.helger.commons.wrapper.Wrapper)4 IAS4IncomingDumper (com.helger.phase4.dump.IAS4IncomingDumper)4 MessagingException (javax.mail.MessagingException)4 WSSecurityException (org.apache.wss4j.common.ext.WSSecurityException)4 Logger (org.slf4j.Logger)4 LoggerFactory (org.slf4j.LoggerFactory)4 Node (org.w3c.dom.Node)4 CommonsArrayList (com.helger.commons.collection.impl.CommonsArrayList)3 IHasInputStream (com.helger.commons.io.IHasInputStream)3 NonBlockingByteArrayInputStream (com.helger.commons.io.stream.NonBlockingByteArrayInputStream)3