AS2 (Applicability Statement 2) is a specification [RFC4130] about how to transport data securely and reliably over the Internet. Security is achieved by using digital certificates and encryption. This articles explains a sample configuration that demonstrates some of the AS2 support built-in with the UltraESB, specifically the AS2 send support
Sending AS2 messages to a trading partner
This sample is written against the example configuration # 350, which shows how the AS2 support of the UltraESB can be used to send a message to a trading partner using AS2. The UltraESB server is configured using the AS2 identifier 'AdroitLogicAS2', and thus the corresponding configuration as per the 'Setting up the sample AS2 trading partner' article is assumed to be completed for the remote trading partner. The salient points of the sample configuration are discussed below.
<bean id="as2Manager" class="org.adroitlogic.as2.manager.AS2Manager">
<constructor-arg value="AS2UserAgent"/> <!--User Agent string to use-->
<constructor-arg value="AdroitLogicAS2"/> <!--Local AS2 Identifier-->
<constructor-arg value=" This e-mail address is being protected from spambots. You need JavaScript enabled to view it "/> <!--Local email address-->
<constructor-arg ref="ksManager"/>
<constructor-arg ref="ultra-config"/>
<constructor-arg ref="fileCache"/>
</bean>
<bean id="ksManager" class="org.adroitlogic.as2.util.KeystoreManager">
<constructor-arg value="samples/conf/keys/server1.jks"/> <!--Identity store file-->
<constructor-arg value="JKS"/> <!--Identity store type-->
<constructor-arg value="password"/> <!--Identity store password-->
<constructor-arg value="samples/conf/keys/trust.jks"/> <!--Trust store file-->
<constructor-arg value="JKS"/> <!--Trust store type -->
<constructor-arg value="password"/> <!--Trust store password-->
<property name="identityAlias" value="server1"/> <!--Alias for identity-->
<property name="identityKeypass" value="password"/> <!--Identity Key password-->
</bean>
The as2Manager and ksManager beans sets up the AS2 support on the UltraESB. The as2Manager bean is the main configuration component, and it defines the local AS2 identifier and other information, and references the global configuration bean as well as the KeyStore manager bean. The KeystoreManager bean configures the local identity key store and trust store. Trading partner certificates must be loaded to the trust store, and the local key and certificate must be configured in the identity store - as per standard AS2 and key store configuration norms.
<!-- Acts as the special proxy service which will send out AS2 requests and issue synchronous MDN receipts-->
<u:proxy id="AS2Sender">
<u:transport id="http-8280"/>
<u:target>
<u:inDestination type="single">
<u:address type="default"/>
</u:inDestination>
<u:outSequence>
<u:class name="org.adroitlogic.as2.AS2SenderOutSequence"/>
</u:outSequence>
</u:target>
</u:proxy>
The AS2Sender is a default service which is used by the AS2Manager to push AS2 messages over HTTP/S. Its definition rarely needs to be changed by the end user.
<u:proxy id="file-poller">
<u:transport id="file-rcv">
<u:property name="url" value="file:///tmp/AS2/tosend"/>
<u:property name="fileNamePattern" value=".*\.edi"/>
<u:property name="startDelay" value="1000"/>
<u:property name="repeatInterval" value="2000"/>
<!--<u:property name="concurrent" value="true"/>-->
<!--<u:property name="cronExpression" value="0/20/40 * * ? * MON-FRI"/>-->
<u:property name="moveAfterProcess" value="/tmp/AS2/sent"/>
<u:property name="moveAfterFailure" value="/tmp/AS2/senderror"/>
<u:property name="moveTimestampFormat" value="yyyy_MM_dd_'T'HH_mm_ss.SSSSZ"/>
</u:transport>
<u:target>
<u:inSequence>
<u:java import="org.adroitlogic.as2.manager.*;"><![CDATA[
Partner partner = new Partner();
partner.setAs2Identifier("mycompanyAS2");
partner.setEncryptCertAlias("server2");
partner.setRequestMDN(true);
partner.setRequestSignedMDN(true);
partner.setSignMessages(true);
partner.setEncryptMessages(true);
partner.setUrl("http://localhost:8080/as2/HttpReceiver");
//partner.setRequestAsyncMDN(true);
//partner.setAsyncReceiptURL("http://localhost:8280/service/AS2Receiver");
msg.holdCompletion();
AS2Manager as2Manager = (AS2Manager) Mediation.getSpringBean("as2Manager");
as2Manager.sendNewAS2Message(msg, partner);
]]></u:java>
</u:inSequence>
</u:target>
</u:proxy>
The 'file-poller' is just a simple File system based proxy service to demonstrate the AS2 functionality. A proxy service which accepts messages over HTTP/S, JMS, Email etc can also be configured to transfer such messages to an AS2 trading partner similarly. The above proxy service polls for files matching "*.edi" at the directory "/tmp/AS2/tosend" and forwards these to the "mycompanyAS2" trading partner. The Partner configuration is self describing, and the "holdCompletion()" is invoked on the message to hold the message processing completion until the response is received and validated for successful completion.
You can start the UltraESB configuration # 350 as follows:
asankha@asankha:~/java/ultraesb-1.0-beta-1/bin$ ./ultraesb.sh -sample 350
Now, to kick off the process, create the poll directory, and copy the sample EDI file bundled with the distribution as follows:
asankha@asankha:~/java/ultraesb-1.0-beta-1/samples/resources$ mkdir -p /tmp/AS2/tosend
asankha@asankha:~/java/ultraesb-1.0-beta-1/samples/resources$ cp input-message.edi /tmp/AS2/tosend/
Within a few seconds, the proxy service will poll and process the message, and on successful completion, the original message is moved to the 'sent' directory.
asankha@asankha:~/java/ultraesb-1.0-beta-1/samples/resources$ find /tmp/AS2/
/tmp/AS2/
/tmp/AS2/tosend
/tmp/AS2/sent
/tmp/AS2/sent/2010_01_12_T01_33_42.0269+0530_input-message.edi
The successful receipt can be verified from the sample AS2 trading partner console of the Mendelson Open Source AS2

| < Prev |
|---|


