Search in sources :

Example 1 with AsynchMDNSenderModule

use of com.helger.as2lib.processor.sender.AsynchMDNSenderModule 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)

Aggregations

CertificateFactory (com.helger.as2lib.cert.CertificateFactory)1 SelfFillingPartnershipFactory (com.helger.as2lib.partner.SelfFillingPartnershipFactory)1 DefaultMessageProcessor (com.helger.as2lib.processor.DefaultMessageProcessor)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 Nonnull (javax.annotation.Nonnull)1