Search in sources :

Example 1 with DefaultMessageProcessor

use of com.helger.as2lib.processor.DefaultMessageProcessor in project as2-lib by phax.

the class AS2ReceiveXServletHandlerCodeConfig method createAS2Session.

@Override
@Nonnull
protected AS2Session createAS2Session(@Nonnull final ICommonsMap<String, String> aInitParams) throws AS2Exception, ServletException {
    final AS2Session aSession = new AS2Session();
    {
        // Create CertificateFactory
        final CertificateFactory aCertFactory = new CertificateFactory();
        aCertFactory.setKeyStoreType(EKeyStoreType.PKCS12);
        aCertFactory.setFilename("clientCertificate.jks");
        aCertFactory.setPassword("test1234");
        aCertFactory.setSaveChangesToFile(false);
        aCertFactory.initDynamicComponent(aSession, null);
        aSession.setCertificateFactory(aCertFactory);
    }
    {
        // Create PartnershipFactory
        final SelfFillingPartnershipFactory aPartnershipFactory = new SelfFillingPartnershipFactory();
        aPartnershipFactory.initDynamicComponent(aSession, null);
        aSession.setPartnershipFactory(aPartnershipFactory);
    }
    {
        // Create MessageProcessor
        final DefaultMessageProcessor aMessageProcessor = new DefaultMessageProcessor();
        aMessageProcessor.setPendingMDNFolder("data/pendingMDN");
        aMessageProcessor.setPendingMDNInfoFolder("data/pendinginfoMDN");
        aMessageProcessor.initDynamicComponent(aSession, null);
        aSession.setMessageProcessor(aMessageProcessor);
        /**
         * Required to receive messages port is required internally - simply
         * ignore it for servlets
         */
        {
            final AS2ServletReceiverModule aModule = new AS2ServletReceiverModule();
            aModule.setErrorDirectory("data/inbox/error");
            aModule.setErrorFormat("$msg.sender.as2_id$, $msg.receiver.as2_id$, $msg.headers.message-id$");
            aModule.initDynamicComponent(aSession, null);
            aMessageProcessor.addModule(aModule);
        }
        /**
         * Only needed to receive asynchronous MDNs
         */
        {
            final AS2ServletMDNReceiverModule aModule = new AS2ServletMDNReceiverModule();
            aModule.initDynamicComponent(aSession, null);
            aMessageProcessor.addModule(aModule);
        }
        /**
         * Below module is used to send async mdn
         */
        {
            final AsynchMDNSenderModule aModule = new AsynchMDNSenderModule();
            aModule.initDynamicComponent(aSession, null);
            aMessageProcessor.addModule(aModule);
        }
        /**
         * A module storing the message.
         */
        {
            final MyHandlerModule aModule = new MyHandlerModule();
            aModule.initDynamicComponent(aSession, null);
            aMessageProcessor.addModule(aModule);
        }
    // Add further modules if you need them
    }
    return aSession;
}
Also used : AS2ServletMDNReceiverModule(com.helger.as2servlet.util.AS2ServletMDNReceiverModule) AS2ServletReceiverModule(com.helger.as2servlet.util.AS2ServletReceiverModule) CertificateFactory(com.helger.as2lib.cert.CertificateFactory) SelfFillingPartnershipFactory(com.helger.as2lib.partner.SelfFillingPartnershipFactory) DefaultMessageProcessor(com.helger.as2lib.processor.DefaultMessageProcessor) AS2Session(com.helger.as2lib.session.AS2Session) AsynchMDNSenderModule(com.helger.as2lib.processor.sender.AsynchMDNSenderModule) Nonnull(javax.annotation.Nonnull)

Example 2 with DefaultMessageProcessor

use of com.helger.as2lib.processor.DefaultMessageProcessor in project as2-lib by phax.

the class AS2Client method initMessageProcessor.

/**
 * Init the message processor. If you override this method, please make sure
 * that you call
 * <code>aSession.setMessageProcessor (aMessageProcessor);</code>.
 *
 * @param aSession
 *        The AS2 session to be filled. Never <code>null</code>.
 * @throws AS2Exception
 *         In case of error
 */
@OverrideOnDemand
protected void initMessageProcessor(@Nonnull final AS2Session aSession) throws AS2Exception {
    final IMessageProcessor aMessageProcessor = new DefaultMessageProcessor();
    aMessageProcessor.initDynamicComponent(aSession, null);
    aSession.setMessageProcessor(aMessageProcessor);
}
Also used : IMessageProcessor(com.helger.as2lib.processor.IMessageProcessor) DefaultMessageProcessor(com.helger.as2lib.processor.DefaultMessageProcessor) OverrideOnDemand(com.helger.commons.annotation.OverrideOnDemand)

Aggregations

DefaultMessageProcessor (com.helger.as2lib.processor.DefaultMessageProcessor)2 CertificateFactory (com.helger.as2lib.cert.CertificateFactory)1 SelfFillingPartnershipFactory (com.helger.as2lib.partner.SelfFillingPartnershipFactory)1 IMessageProcessor (com.helger.as2lib.processor.IMessageProcessor)1 AsynchMDNSenderModule (com.helger.as2lib.processor.sender.AsynchMDNSenderModule)1 AS2Session (com.helger.as2lib.session.AS2Session)1 AS2ServletMDNReceiverModule (com.helger.as2servlet.util.AS2ServletMDNReceiverModule)1 AS2ServletReceiverModule (com.helger.as2servlet.util.AS2ServletReceiverModule)1 OverrideOnDemand (com.helger.commons.annotation.OverrideOnDemand)1 Nonnull (javax.annotation.Nonnull)1