use of com.helger.as2servlet.util.AS2ServletMDNReceiverModule 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;
}
use of com.helger.as2servlet.util.AS2ServletMDNReceiverModule in project as2-lib by phax.
the class AbstractAS2MDNReceiveXServletHandler method onServletInit.
@Override
public void onServletInit(@Nonnull final ICommonsMap<String, String> aInitParams) throws ServletException {
super.onServletInit(aInitParams);
try {
m_aReceiver = getSession().getMessageProcessor().getModuleOfClass(AS2ServletMDNReceiverModule.class);
if (m_aReceiver == null)
throw new ServletException("Failed to retrieve 'AS2ServletMDNReceiverModule' which is a mandatory module! Please ensure your configuration file contains at least the module '" + AS2ServletMDNReceiverModule.class.getName() + "'");
} catch (final AS2Exception ex) {
throw new ServletException("Failed to init AS2 configuration", ex);
}
LOGGER.info("Successfully initialized AS2 configuration");
}
Aggregations