Isode Messaging APIs
Summary : These examples programs show how to use X.400 Java Gateway API to transfer messages in and out of a gateway. Typically this API is used for transferring messages to a protocol other than X.400.X.400 Java API - Example Application
- Application Features
- Messaging Configuration
- Configuring the Application
- Configure logging
- Compiling the Application
- Running the Application
Application Features
The Java MT example does the following using the X.400 MT Java API
- Transfer out X.400 Messages including attachments that are
- IA5
- General_Text (8859-1, 8859-2)
- Binary
- Message Body Part
- P772 ADATP3
- P772 Corrections
- P772 ACP127Data
- P772 Military Message bodypart
- P772 Forwarded Encrypted bodypart
- Transfer out probes*
- Transfer out reports*
- Transfer in X.400 Messages
* requires code to be uncommented within X400_mttest.java
Note that there is only one example application to do all of this.
Full specification of the MT Java API is here.Messaging Configuration
Before running the P3/P7 applications you need run Mconsole to configure and run a messaging configuration including, (if you are using P7) an Isode Message Store.
You also need to configure a P3 or P7 user using the X.400 Mailbox View in Mconsole.
Configuring the Application
The example application needs to be configured to use the values you have configured using Mconsole for the MTA and P3/P7 Users. There are 2 main string variables that need to be adjusted. These are kept within the config.java class in com/isode/x400api/test/config.java.
public static final String mt_rcvoraddr = "/CN=GatewayUser/OU=Sales/O=" + hostname + "/PRMD=TestPRMD/ADMD=TestADMD/C=GB/";
public static final String mt_sendoraddr = "/CN=GatewayUser/OU=Sales/O=" + hostname + "/PRMD=TestPRMD/ADMD=TestADMD/C=GB/";
With these two values set to your own config then other values such will be setup automatically.
There are many other values that can be set in config.java to change the message that is transferred into the MTA by the Gateway.
Configuring Logging
Isode logging is controlled via xml files. Isode applications look for these xml files in ETCDIR (C:\Isode\etc on Windows and /etc/isode on unix.). Should an xml file called "logtailor.xml" be present, then this file will be used.
It is however possible to override this behaviour by manually specifying an xml file with a different name. In order to do this a session object must be created, and populated. Thus once a connection to the message store (or MTA) needs to occur before the following function call.
status = com.isode.x400mtapi.X400mt.x400_mt_setstrdefault(session_obj, X400_att.X400_S_LOG_CONFIGURATION_FILE, "x400api.xml", -1);
Once called the X.400api will use the configuration information within the x400api.xml file. Logging xml files may be created or altered using the logconfig tool located within the BINDIR (C:\Program Files\Isode\bin on Windows, /opt/isode/bin on unix). There is an example x400api.xml file located within the x400api C exmaple directory.
Compiling the Application
To build the application you must have a JDK installed. You should also make sure that there are no pre-compiled classes in your build tree.
Unix
This command assumes that the JDK is installed in /usr/lib/jvm/java/bin/
# cd /opt/isode/share/x400sdk/example/java # rm *.class ; rm com/isode/x400mtapi/test/*.class # /usr/lib/jvm/java/bin/javac -sourcepath . -classpath -classpath /opt/isode/lib/java/classes/isode-x400mt.jar X400_mttest.java # ./run_test.sh
Windows
This command assumes that the JDK is installed in E:\j2sdk1.5.0_08
C:> E:\jdk1.8.0_08\bin\javac -sourcepath . -verbose -classpath ".;c:\progra~1\Isode\bin\java\classes\isode-x400mt.jar;C:\Program Files\Isode\share\x400sdk\example\java" -g X400_mttest.java
(Note that the line should not be broken)
Running the Application
Unix
To run the application you simply run the wrapper script run_mttest.sh (unix) or run_mttest.bat (Windows) from the command line. No arguments are required.
Windows
java -Djava.library.path="C:\PROGRA~1\Isode\bin" -classpath .;
"c:\progra~1\Isode\bin\java\classes\isode-x400mt.jar;
C:\Program Files\Isode\share\x400sdk\example\java" -verbose:jni -Xms20m X400_mttest
When executed the sample application should output something like this:
X400_att.X400_API_VERSN = 14030000 Transfer Message ================================================= Opened MT session successfully Building message envelope Adding Traceinfo Traceinfo add X400_S_GLOBAL_DOMAIN_ID Traceinfo add X400_S_DSI_ARRIVAL_TIME Adding Internal Traceinfo Adding dl expansion history Adding DL Exp History Adding DL Exp History Adding content correlator Adding MOAC Reading in 148 bytes Finished read_bin_file: Adding MOAC bytes Adding originator cert Reading in 2261 bytes Finished read_bin_file: Adding orig cert bytes Adding X.411 security label Reading in 120 bytes Finished read_bin_file: Adding X.411 security label Building message content Building message for message bodypart Added recipient /CN=fwd msg orig/OU=lppt/O=dhcp-250/PRMD=TestPRMD/ADMD=TestADMD/C=GB/ successfully Added recipient /CN=forwarded msg recip/O=dhcp-250/PRMD=TestPRMD/ADMD=TestADMD/C=GB/ successfully Added recipient /CN=invalid/OU=lppt/O=dhcp-250/PRMD=TestPRMD/ADMD=TestADMD/C=GB/ successfully Adding P772 attributes Adding P772 Codress Adding P772 primary precedence Adding P772 Copy precedence Adding P772 message type Adding P772 Ext Auth info Adding P772 ACP127 Msg ID Adding P772 Orig PLAD Adding Pilot forwarding info Reading in 388 bytes Finished read_bin_file: Adding pilot forwarding info bytes Adding security info label Reading in 623 bytes Finished read_bin_file: Adding security info label bytes Adding originator Adding Redirection history Adding redihist X400_S_REDIRECTION_TIME Adding redihist X400_S_OR_ADDRESS Adding redihist X400_S_DIRECTORY_NAME Adding Redirection history Adding redihist X400_S_REDIRECTION_TIME Adding redihist X400_S_OR_ADDRESS Adding redihist X400_S_DIRECTORY_NAME Added recipient /CN=GatewayUser/OU=Sales/O=dhcp-250/PRMD=TestPRMD/ADMD=TestADMD/C=GB/to MT Message Adding recipients Adding Redirection history Adding redihist X400_S_REDIRECTION_TIME Adding redihist X400_S_OR_ADDRESS Adding redihist X400_S_DIRECTORY_NAME Adding Redirection history Adding redihist X400_S_REDIRECTION_TIME Adding redihist X400_S_OR_ADDRESS Adding redihist X400_S_DIRECTORY_NAME Added recipient /CN=GatewayUser/OU=Sales/O=dhcp-250/PRMD=TestPRMD/ADMD=TestADMD/C=GB/to MT Message Adding Redirection history Adding redihist X400_S_REDIRECTION_TIME Adding redihist X400_S_OR_ADDRESS Adding redihist X400_S_DIRECTORY_NAME Adding Redirection history Adding redihist X400_S_REDIRECTION_TIME Adding redihist X400_S_OR_ADDRESS Adding redihist X400_S_DIRECTORY_NAME Added recipient /CN=invalid/O=GatewayMTA/PRMD=TestPRMD/ADMD=TestADMD/C=GB/to MT Message Adding Redirection history Adding redihist X400_S_REDIRECTION_TIME Adding redihist X400_S_OR_ADDRESS Adding redihist X400_S_DIRECTORY_NAME Adding Redirection history Adding redihist X400_S_REDIRECTION_TIME Adding redihist X400_S_OR_ADDRESS Adding redihist X400_S_DIRECTORY_NAME Added recipient /CN=dlexempted/O=GatewayMTA/PRMD=TestPRMD/ADMD=TestADMD/C=GB/to MT Message Submitted message successfully Closed MT Session successfully Sent Message. Now try to receive it Opened MT session successfully, 1 messages waiting Retrieved MT Message successfully - displaying Retrieved msg (not ipn) successfully - displaying Message Envelope: ---------------- Originator address (69) /CN=GatewayUser/OU=Sales/O=dhcp-250/PRMD=TestPRMD/ADMD=TestADMD/C=GB/ Message ID(67) [/PRMD=TestPRMD/ADMD=TestADMD/C=GB/;dhcp-250.2810401-030924.140212] Content ID(13) 030924.140212 Orig EITs(74) undefined ia5-text 1.0.10021.7.1.0.100 1.0.10021.7.1.0.6 1.0.10021.7.1.0.1 Message submission time(13) 070927120000Z Latest delivery time(13) 090927120000Z Orig return address(59) /CN=SendUser/O=GatewayMTA/PRMD=TestPRMD/ADMD=TestADMD/C=GB/ Getting content type Content type: 22 Num attachments 6 Priority 2 Disclosure of recips prohibited 1 Implicit conversion prohibited 1 Content return request 1 Recipient reassignment prohibited 1 Distribution List expansion prohibited 1 Conversion with loss prohibited 1 Number of recipients is 2 Redirection History found 0 redirection history redirection time: 080427120000Z redirection history redirection address: /CN=redihist1/O=GatewayMTA/PRMD=TestPRMD/ADMD=TestADMD/C=GB/ redirection history redirection DN: cn=redihist1,c=gb Got redirection history redirection reason: 4 Redirection History found 0 redirection history redirection time: 080527120000Z redirection history redirection address: /CN=redihist2/O=GatewayMTA/PRMD=TestPRMD/ADMD=TestADMD/C=GB/ redirection history redirection DN: cn=redihist2,c=gb Got redirection history redirection reason: 3 no redirection history found 24 get_mt_redihist failed 24 -------------- Recipient 1-------------- oraddress(69)/CN=GatewayUser/OU=Sales/O=dhcp-250/PRMD=TestPRMD/ADMD=TestADMD/C=GB/ envelope: 1(69)/CN=GatewayUser/OU=Sales/O=dhcp-250/PRMD=TestPRMD/ADMD=TestADMD/C=GB/ Responsibility 1 MTA report request 3 Originator report request 2 Redirection History found 0 redirection history redirection time: 080427120000Z redirection history redirection address: /CN=redihist1/O=GatewayMTA/PRMD=TestPRMD/ADMD=TestADMD/C=GB/ redirection history redirection DN: cn=redihist1,c=gb Got redirection history redirection reason: 4 Redirection History found 0 redirection history redirection time: 080527120000Z redirection history redirection address: /CN=redihist2/O=GatewayMTA/PRMD=TestPRMD/ADMD=TestADMD/C=GB/ redirection history redirection DN: cn=redihist2,c=gb Got redirection history redirection reason: 3 no redirection history found 24 get_mt_redihist failed 24 -------------- Recipient 2-------------- oraddress(58)/CN=invalid/O=GatewayMTA/PRMD=TestPRMD/ADMD=TestADMD/C=GB/ envelope: 2(58)/CN=invalid/O=GatewayMTA/PRMD=TestPRMD/ADMD=TestADMD/C=GB/ Responsibility 1 MTA report request 3 Originator report request 2 no more recips ... no redirection history found 24 get_mt_redihist failed 24 -------------- Recipient 1-------------- oraddress(61)/CN=dlexempted/O=GatewayMTA/PRMD=TestPRMD/ADMD=TestADMD/C=GB/ no int value for notification req(223) failed 24 no int value for reply requested(224) failed 24 no string value for Free form name(221) failed 24 no string value for Telephone Number(222) failed 24 no more recips ... DLEH found 0 DLExpansion List entry OR Address: /CN=dlexphist1/O=GatewayMTA/PRMD=TestPRMD/ADMD=TestADMD/C=GB/ DLExpansion List entry DN: cn=dlexphisty1,c=gb DLExpansion List exp hist time: 070801120000+0100 DLEH found 0 DLExpansion List entry OR Address: /CN=dlexphist2/O=GatewayMTA/PRMD=TestPRMD/ADMD=TestADMD/C=GB/ DLExpansion List entry DN: cn=dlexphisty2,c=gb DLExpansion List exp hist time: 080801120000+0100 no DLEH found 24 get_mt_dleh failed 24 Get_mt_traceinfo Traceinfo found 0 Trace info GDI: /PRMD=GDI1/ADMD=TestADMD/C=GB/ Trace info arrival time: 070927120000Z Trace info attempted domain: /PRMD=attempteddomain1/ADMD=TestADMD/C=GB/ Trace info deferred delivery time : 080427120000Z Trace info CEIT : ia5-text Trace info routing action: 1 no int value for redirection24 no int value for dloperation24 Traceinfo found 0 Trace info GDI: /PRMD=intGDI1/ADMD=TestADMD/C=GB/ Trace info arrival time: 080427120000Z no string value for trace info attempted domain 24 Trace info deferred delivery time : 070427120000Z Trace info CEIT : ia5-text Trace info routing action: 0 Trace info redirected: 1 Trace info dloperation: 1 Traceinfo found 0 Trace info GDI: /PRMD=TestPRMD/ADMD=TestADMD/C=GB/ Trace info arrival time: 090122120236Z no string value for trace info attempted domain 24 no string value for trace info deferred delivery time 24 Trace info CEIT : ia5-text Trace info routing action: 0 no int value for redirection24 no int value for dloperation24 no trace info found 24 get_mt_traceinfo failed 24 Internal Traceinfo found 0 Internal Trace info GDI: /PRMD=intGDI1/ADMD=TestADMD/C=GB/ Internal Trace info MTA Name: /cn=mtaname/PRMD=intGDI1/ADMD=Te Internal Trace info MTA SI Time: 080427120000Z Got trace info routing action: SI routing action 1 :relayed Internal Trace info attempted action: Internal Trace info Attempted MTA Name: /cn=attemptedmta/PRMD=intGDI1/AD Internal Trace info additional action deferred time: 070427120000Z Internal Trace info additional action CEIT: ia5-text Trace info other action: 3 SI Other Action 1 : redirected SI Other Action 1 : DL operation Internal Traceinfo found 0 Internal Trace info GDI: /PRMD=TestPRMD/ADMD=TestADMD/C=GB/ Internal Trace info MTA Name: dhcp-250.isode.net Internal Trace info MTA SI Time: 090122120236Z Got trace info routing action: SI routing action 2 :relayed no int value for attempted action24 no string value for internal trace info X400_S_MTA_SI_DEFERRED_TIME 24 Internal Trace info additional action CEIT: ia5-text Trace info other action: 0 no trace info found 24 get_mt_internaltraceinfo failed 24 Cont correlator: (7)ABCDEFG MOAC: Binary data (148) Finished write_bin_file: Originator cert: Binary data (2261) Finished write_bin_file: X411 secuirty label: Binary data (120) Finished write_bin_file: Message Content: ---------------- IPM IDentifier(17) 1064400656.24922* Subject(22) Test message from Java Replied-to-identifier(17) 1064400656.24922* Obsoleted IPMs(17) 1064400656.24922* Related IPMs(17) 1064400656.24922* Expiry Time(12) 050924120000 Reply Time(12) 050924120000 no string value for auth time(320) result is 24 no string value for orig ref(321) result is 24 Importance 2 Sensitivity 3 no int value for autoforwarded (309) number of attachments 6 no redirection history found 24 get_mt_redihist failed 24 -------------- Recipient 1-------------- oraddress(69)/CN=GatewayUser/OU=Sales/O=dhcp-250/PRMD=TestPRMD/ADMD=TestADMD/C=GB/ no int value for notification req(223) failed 24 no int value for reply requested(224) failed 24 Free form name(69)/CN=GatewayUser/OU=Sales/O=dhcp-250/PRMD=TestPRMD/ADMD=TestADMD/C=GB/ Telephone Number(11)02087830203 no more recips ... no redirection history found 24 get_mt_redihist failed 24 -------------- Recipient 1-------------- oraddress(69)/CN=GatewayUser/OU=Sales/O=dhcp-250/PRMD=TestPRMD/ADMD=TestADMD/C=GB/ Responsibility 7 Reply Request 1 Free form name(69)/CN=GatewayUser/OU=Sales/O=dhcp-250/PRMD=TestPRMD/ADMD=TestADMD/C=GB/ Telephone Number(11)02087830203 no redirection history found 24 get_mt_redihist failed 24 -------------- Recipient 2-------------- oraddress(58)/CN=invalid/O=GatewayMTA/PRMD=TestPRMD/ADMD=TestADMD/C=GB/ Responsibility 7 Reply Request 1 Free form name(58)/CN=invalid/O=GatewayMTA/PRMD=TestPRMD/ADMD=TestADMD/C=GB/ Telephone Number(11)02087830203 no more recips ... ------ Content number of attachments 6 ------------------------ Reading IA5 Attachment IA5 Text (37)IA5 content from Java Line 1 Line 2 Attachment 1(41) IA5 att content from Java Line 1 Line 2 BodyPart 2 is complex ---------------- Reading MT BodyPart 2 Got BodyPart int value : bp type is 407 Got BodyPart string value(44): bp value is 8859_1 content from Java Line 1 Line 2\ufffd\ufffd\ufffd\ufffd BodyPart 3 is complex ---------------- Reading MT BodyPart 3 Got BodyPart int value : bp type is 407 Got BodyPart string value(44): bp value is 8859_2 content from Java Line 1 Line 2\ufffd\ufffd\ufffd\ufffd BodyPart 4 is a message ------------------------ Reading Message BodyPart 4 Read Message BodyPart successfully Got BodyPart string object type successfully ++++++++++++++++++++++++++++++++++++++ Message body part (ie forwarded message) X400 Message Content: ---------------- IPM IDentifier(17) 1064400656.24922* Subject(33) Forwarded: Test message from Java Replied-to-identifier(17) 1064400656.24923* Obsoleted IPMs(17) 1064400656.24924* Related IPMs(17) 1064400656.24925* Expiry Time(12) 050924120000 Reply Time(12) 050924120000 no string value for auth time(320) result is 24 no string value for orig ref(321) result is 24 Importance 2 Sensitivity 3 no int value for 309 number of attachments 5 no string value for orig(65540) result is 3 -------------- X.400 Recipient 1-------------- orig: 1(69)/CN=fwd msg orig/OU=lppt/O=dhcp-250/PRMD=TestPRMD/ADMD=TestADMD/C=GB/ x400_recipgetintparam(223) failed 24 x400_recipgetintparam(224) failed 24 x400_recipgetstrparam(221) failed 24 x400_recipgetstrparam(222) failed 24 x400_recipgetstrparam(111) failed 22 x400_recipgetintparam(611) failed 22 x400_recipgetstrparam(610) failed 22 x400_recipgetintparam(613) failed 22 x400_recipgetintparam(614) failed 22 no more recips ... -------------- X.400 Recipient 1-------------- primary: 1(68)/CN=forwarded msg recip/O=dhcp-250/PRMD=TestPRMD/ADMD=TestADMD/C=GB/ x400_recipgetintparam(223) failed 24 Reply Request 5 x400_recipgetstrparam(221) failed 24 x400_recipgetstrparam(222) failed 24 x400_recipgetstrparam(111) failed 22 x400_recipgetintparam(611) failed 22 x400_recipgetstrparam(610) failed 22 x400_recipgetintparam(613) failed 22 x400_recipgetintparam(614) failed 22 -------------- X.400 Recipient 2-------------- primary: 2(64)/CN=invalid/OU=lppt/O=dhcp-250/PRMD=TestPRMD/ADMD=TestADMD/C=GB/ x400_recipgetintparam(223) failed 24 Reply Request 5 x400_recipgetstrparam(221) failed 24 x400_recipgetstrparam(222) failed 24 x400_recipgetstrparam(111) failed 22 x400_recipgetintparam(611) failed 22 x400_recipgetstrparam(610) failed 22 x400_recipgetintparam(613) failed 22 x400_recipgetintparam(614) failed 22 no more recips ... Reading all attachments as bodyparts number of attachments 5 ---------------- Reading X.400 BodyPart 1 Got BodyPart int value : bp type is 401 Got BodyPart string value(52): bp value is Forwarded: IA5 att content from Java Line 1 Line 2 ---------------- Reading X.400 BodyPart 2 Got BodyPart int value : bp type is 407 Got BodyPart string value(55): bp value is Forwarded: 8859_1 content from Java Line 1 Line 2\ufffd\ufffd\ufffd\ufffd ---------------- Reading X.400 BodyPart 3 Got BodyPart int value : bp type is 407 Got BodyPart string value(55): bp value is Forwarded: 8859_2 content from Java Line 1 Line 2\ufffd\ufffd\ufffd\ufffd ---------------- Reading X.400 BodyPart 4 Got BodyPart int value : bp type is 404 Binary Attachment (404), len = 45 97 97 98 105 110 97 114 121 32 99 111 110 116 101 110 116 32 102 114 111 109 32 74 97 118 97 13 10 76 105 110 101 32 49 13 10 76 105 110 101 32 50 0 97 0 ---------------- Reading X.400 BodyPart 5 x400_msggetbodypart failed 20 No more bodyparts ++++++++++++++++++++++++++++++++++++++ Binary Attachment (404), len = 42 98 105 110 97 114 121 32 99 111 110 116 101 110 116 32 102 114 111 109 32 74 97 118 97 13 10 76 105 110 101 32 49 13 10 76 105 110 101 32 50 0 97 Read 6 attachments ------------------------ Fetching P772 Coderess 0 Primary precedence 0 Primary precedence 0 Message type 0 Ext auth info (13) ext auth info ACP127 MSG ID (11) ACP127msgid ORIG PLAD (8) origplad pilot fwd info: Binary data (388) Finished write_bin_file: security info labels: Binary data (623) Finished write_bin_file: Finished fetching messages Closed Session successfully