Class X400Msg
- java.lang.Object
-
- com.isode.x400api.MSMessage
-
- com.isode.x400.highlevel.X400Msg
-
public class X400Msg extends MSMessage
Creates an X.400 message, preparing it to send it to the P3 channel or the P7 Message Store.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static class
X400Msg.DR_Request
The originator or a message can request the MTA to generate a delivery report for a particular recipient.static class
X400Msg.Military_Priority
There are six standard values for military message priority in X.400.static class
X400Msg.X400_Message_Type
Represents one of the message types (message, report, probe or submitted message).static class
X400Msg.X400_Priority
There are three standard values for message priority in X.400.
-
Field Summary
Fields Modifier and Type Field Description static int
IPN_NON_RECEIPT_NOTIFICATION
Request the receiving User Agent (UA) to send an IPN when the message can't be read by this recipient.static int
IPN_RECEIPT_NOTIFICATION
Request the receiving User Agent (UA) to send an IPN when the message is read by this recipient.static int
IPN_RETURN_REQUEST
Request the receiving User Agent (UA) to return the content of the original message in case the message can't be read by the recipientstatic java.lang.String
P772_OID
-
Constructor Summary
Constructors Constructor Description X400Msg(P3BindSession p3bind)
X400Msg(P3BindSession p3bind, boolean probe)
X400Msg(Session session_obj, boolean probe)
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Deprecated Methods Modifier and Type Method Description void
addBodypart(Bodypart new_bodypart)
Add a newly created bodypart to a message, this is typically used when composing.void
addExistingBodypart(BodyPart existing_bodypart)
Add an existing bodypart to a message, typically a bodypart that was extracted from a received message.void
addMessageForwardBodypart(BodypartForwardedMessage fwd)
Create a new Message Forward Bodypartvoid
addSecurityLabelAsBER(java.lang.String sec_label_file)
Add a security label, from a file that contains a BER encoded byte arrayvoid
addSecurityLabelAsXMLFileName(java.lang.String sec_label_file)
Add a security label, providing a file name that contains a security label encoded in an XML filevoid
addSecurityLabelAsXMLString(java.lang.String sec_label_xml)
Add a security label as an XML encoded Stringvoid
buildMsg(Session session_obj)
Deprecated.this function does not do anything any more; the underlying C API will generate an IPMIdentifier if you have not added one anywayvoid
delete(boolean retainInStore)
Delete message objectprotected void
finalize()
byte[]
getContentBytes()
Get the content of the message, as a byte[]java.lang.String
getContentIdentifier()
Returns the Content Identifier: fieldint
getContentType()
Returns the Content Type, or -1 if it cannot be foundjava.lang.String
getFreeFormName(Recip ms_recip_obj)
java.util.ArrayList<java.lang.String>
getInvalidRecipients()
Returns the message invalid recipients, if any, as an array list of Strings.java.lang.String
getMessageIdentifier()
Returns the Message Identifier: fieldjava.lang.String
getMessageIPMIdentifier()
Returns the message IPM identifierstatic int
getPrecedenceFromPriority(X400Msg.Military_Priority mp)
Return an integer value that is equivalent to the military priorityjava.util.ArrayList<java.lang.String>
getPrintableStringParam(int param)
Get a message parameter that has a Printable String format.static X400Msg.Military_Priority
getPriorityFromPrecedence(int precedence)
Return a military priority based on an integer that represents the precedencejava.lang.String
getSubmissionTime()
Returns the Message Submission time: field X.400 Message Submission Time: UTCTime format YYMMDDHHMMSS<zone>boolean
isMilitaryContentType()
Returns true if the message's external content type is P772 (1.3.26.0.4406.0.4.1)void
sendMsg(Session session_obj)
Submit a message into the Message Storevoid
setAllRecipPrecedence(int p)
Set the message precedence, a single value that applies to all recipients.Recip
setBcc(java.lang.String bcc, X400Msg.DR_Request rep_request, int ipn_request)
Add a blind copy recipient (BCc:), just to the message envelope (not the header)void
setBoolparam(int param, boolean value)
Set a message parameter that has a Boolean format.Recip
setCc(java.lang.String cc, X400Msg.DR_Request rep_request, int ipn_request)
Add a copy recipient (Cc:), both to the message envelope and headerRecip
setEnvelopRecipient(java.lang.String to, X400Msg.DR_Request rep_request, int ipn_request)
Add a recipient to envelope onlyvoid
setFreeFormName(Recip ms_recip_obj, java.lang.String ffn)
Set the free form name of a recipient (or sender)Recip
setFrom(java.lang.String from)
Set the message FROM: addressvoid
setIntParam(int param, int value)
There are attributes of an X.400 message that can be set that are not commonly used.Recip
setIPMHeadingBlindCopyRecipient(java.lang.String to, X400Msg.DR_Request rep_request, int ipn_request)
Add a blind-copy recipient to IPM Heading only, not the envelope.Recip
setIPMHeadingCopyRecipient(java.lang.String to, X400Msg.DR_Request rep_request, int ipn_request)
Add a copy recipient to IPM Heading only, not the envelope.Recip
setIPMHeadingPrimaryRecipient(java.lang.String to, X400Msg.DR_Request rep_request, int ipn_request)
Add a primary recipient to IPM Heading only, not the envelope.void
setMessageIPMIdentifier(java.lang.String mii)
Set the IPM Identifier field of a message.void
setMilitaryContentType()
Set the message external content type to be P772 (1.3.26.0.4406.0.4.1)void
setPriority(X400Msg.Military_Priority primary, X400Msg.Military_Priority copy)
Set the message priority, using the standard military message priorities values for the primary and the copy precedencevoid
setPriority(X400Msg.X400_Priority pr)
Set the message priority, using one of the standard X.400 message prioritiesRecip
setRecipient(boolean envelope, int r_type, java.lang.String oraddress, X400Msg.DR_Request rep_request, int ipn_request)
Set a message recipientRecip
setRecipient(int r_type, java.lang.String oraddress, X400Msg.DR_Request rep_request, int ipn_request)
Set a message recipientvoid
setSecurityLabel(com.isode.rbac.swig.JRSecurityLabel sec_label)
Add a security label as a JRSecurityLabel objectvoid
setStringparam(int param, java.lang.String value)
There are attributes of an X.400 message that can be set that are not commonly used.void
setSubject(java.lang.String subject)
Set the message Subject: fieldvoid
setTextBody(java.lang.String textbody)
Set the message content (as a single IA5 text bodypart)Recip
setTo(java.lang.String to, X400Msg.DR_Request rep_request, int ipn_request)
Add a primary recipient (TO:), both to the message envelope and header-
Methods inherited from class com.isode.x400api.MSMessage
GetAttLen, GetAttType, GetIntValue, GetNumRecips, GetType
-
-
-
-
Field Detail
-
IPN_RECEIPT_NOTIFICATION
public static final int IPN_RECEIPT_NOTIFICATION
Request the receiving User Agent (UA) to send an IPN when the message is read by this recipient.
Note that you want to also receive an IPN when it's not read, you have to add the numeric value of IPN_NON_RECEIPT_NOTIFICATION- See Also:
- Constant Field Values
-
IPN_NON_RECEIPT_NOTIFICATION
public static final int IPN_NON_RECEIPT_NOTIFICATION
Request the receiving User Agent (UA) to send an IPN when the message can't be read by this recipient.
Note that you want to also receive an IPN when its read, you have to add the numeric value of IPN_RECEIPT_NOTIFICATION- See Also:
- Constant Field Values
-
IPN_RETURN_REQUEST
public static final int IPN_RETURN_REQUEST
Request the receiving User Agent (UA) to return the content of the original message in case the message can't be read by the recipient- See Also:
- Constant Field Values
-
P772_OID
public static final java.lang.String P772_OID
- See Also:
- Constant Field Values
-
-
Constructor Detail
-
X400Msg
public X400Msg(P3BindSession p3bind)
-
X400Msg
public X400Msg(P3BindSession p3bind, boolean probe)
-
X400Msg
public X400Msg(Session session_obj, boolean probe)
-
-
Method Detail
-
getPriorityFromPrecedence
public static X400Msg.Military_Priority getPriorityFromPrecedence(int precedence)
Return a military priority based on an integer that represents the precedence- Parameters:
precedence
-- Returns:
-
getPrecedenceFromPriority
public static int getPrecedenceFromPriority(X400Msg.Military_Priority mp)
Return an integer value that is equivalent to the military priority- Parameters:
mp
-- Returns:
-
delete
public void delete(boolean retainInStore) throws X400APIException
Delete message object- Parameters:
retainInStore
- boolean : Retain in P7 Message Store (i.e. no P7 Delete) if true- Throws:
X400APIException
-
finalize
protected void finalize() throws java.lang.Throwable
- Overrides:
finalize
in classjava.lang.Object
- Throws:
java.lang.Throwable
-
setRecipient
public Recip setRecipient(int r_type, java.lang.String oraddress, X400Msg.DR_Request rep_request, int ipn_request) throws X400APIException
Set a message recipient- Parameters:
r_type
- int : Recipient type (see below)oraddress
- String: String encoded X.400 O/R addressrep_request
- int: Integer value for the Delivery Report requestipn_request
- int: Integer value for the IPN request Current accepted values for r_type are:
X400_RECIP_PRIMARY
X400_RECIP_CC
X400_RECIP_BCC- Throws:
X400APIException
-
setRecipient
public Recip setRecipient(boolean envelope, int r_type, java.lang.String oraddress, X400Msg.DR_Request rep_request, int ipn_request) throws X400APIException
Set a message recipient- Parameters:
envelope
- boolean : include it in the envelope toor_type
- int : Recipient type (see below)oraddress
- String: String encoded X.400 O/R addressrep_request
- int: Integer value for the Delivery Report requestipn_request
- int: Integer value for the IPN request Current accepted values for r_type are:
X400_RECIP_PRIMARY
X400_RECIP_CC
X400_RECIP_BCC- Throws:
X400APIException
-
setEnvelopRecipient
public Recip setEnvelopRecipient(java.lang.String to, X400Msg.DR_Request rep_request, int ipn_request) throws X400APIException
Add a recipient to envelope only- Parameters:
to
- String: String encoded X.400 O/R address of this recipientrep_request
- Delivery Report Request for this recipientipn_request
- IPN Request for this recipient- Throws:
X400APIException
-
setIPMHeadingPrimaryRecipient
public Recip setIPMHeadingPrimaryRecipient(java.lang.String to, X400Msg.DR_Request rep_request, int ipn_request) throws X400APIException
Add a primary recipient to IPM Heading only, not the envelope. Not that the message will *not* be sent to this recipient- Parameters:
to
- String: String encoded X.400 O/R address of this recipientrep_request
- Delivery Report Request for this recipientipn_request
- IPN Request for this recipient- Throws:
X400APIException
-
setIPMHeadingCopyRecipient
public Recip setIPMHeadingCopyRecipient(java.lang.String to, X400Msg.DR_Request rep_request, int ipn_request) throws X400APIException
Add a copy recipient to IPM Heading only, not the envelope. Not that the message will *not* be sent to this recipient- Parameters:
to
- String: String encoded X.400 O/R address of this recipientrep_request
- Delivery Report Request for this recipientipn_request
- IPN Request for this recipient- Throws:
X400APIException
-
setIPMHeadingBlindCopyRecipient
public Recip setIPMHeadingBlindCopyRecipient(java.lang.String to, X400Msg.DR_Request rep_request, int ipn_request) throws X400APIException
Add a blind-copy recipient to IPM Heading only, not the envelope. Not that the message will *not* be sent to this recipient- Parameters:
to
- String: String encoded X.400 O/R address of this recipientrep_request
- Delivery Report Request for this recipientipn_request
- IPN Request for this recipient- Throws:
X400APIException
-
setTo
public Recip setTo(java.lang.String to, X400Msg.DR_Request rep_request, int ipn_request) throws X400APIException
Add a primary recipient (TO:), both to the message envelope and header- Parameters:
to
- String: String encoded X.400 O/R address of this recipientrep_request
- Delivery Report Request for this recipientipn_request
- IPN Request for this recipient- Throws:
X400APIException
-
setCc
public Recip setCc(java.lang.String cc, X400Msg.DR_Request rep_request, int ipn_request) throws X400APIException
Add a copy recipient (Cc:), both to the message envelope and header- Parameters:
cc
- String: String encoded X.400 O/R address of this recipientrep_request
- Delivery Report Request for this recipientipn_request
- IPN Request for this recipient- Throws:
X400APIException
-
setBcc
public Recip setBcc(java.lang.String bcc, X400Msg.DR_Request rep_request, int ipn_request) throws X400APIException
Add a blind copy recipient (BCc:), just to the message envelope (not the header)- Parameters:
bcc
- String encoded X.400 O/R address of the recipientrep_request
- Delivery Report Request for this recipientipn_request
- IPN Request for this recipient- Throws:
X400APIException
-
setFrom
public Recip setFrom(java.lang.String from) throws X400APIException
Set the message FROM: address- Parameters:
from
- String encoded X.400 O/R address with the originator address, as it will appear in the message header. Note that the address that appears in the envelope will be the one use of the user that binded to the Message Store.- Throws:
X400APIException
-
setFreeFormName
public void setFreeFormName(Recip ms_recip_obj, java.lang.String ffn) throws X400APIException
Set the free form name of a recipient (or sender)- Parameters:
ms_recip_obj
-ffn
-- Throws:
X400APIException
-
getFreeFormName
public java.lang.String getFreeFormName(Recip ms_recip_obj) throws X400APIException
- Parameters:
ms_recip_obj
-- Returns:
- the free form name of a recipient, if available
- Throws:
X400APIException
-
setSubject
public void setSubject(java.lang.String subject) throws X400APIException
Set the message Subject: field- Parameters:
subject
- String: Subject of the message- Throws:
X400APIException
-
setMessageIPMIdentifier
public void setMessageIPMIdentifier(java.lang.String mii) throws X400APIException
Set the IPM Identifier field of a message.This method allows the user agent to assign the message being composed an IPM Identifier. This can be used later on, to correlate a Read Receipt (Inter Personal Notification = IPN).
If this value is not set, a random unique value will be assigned.
- Parameters:
mii
-The IPM Identifier must be in RFC2156 format:
<user-relative-identifier> '*' <std-or-address> ['<' dn '>']
e.g. the string:
"123456-XXXX* /I=T/S=Costen/O=Isode limited/P=Isode/A= /C=gb/<cn=tim costen,o=isode limited,c=gb>
- Throws:
X400APIException
-
getMessageIPMIdentifier
public java.lang.String getMessageIPMIdentifier()
Returns the message IPM identifier
-
setMilitaryContentType
public void setMilitaryContentType() throws X400APIException
Set the message external content type to be P772 (1.3.26.0.4406.0.4.1)- Throws:
X400APIException
-
isMilitaryContentType
public boolean isMilitaryContentType() throws X400APIException
Returns true if the message's external content type is P772 (1.3.26.0.4406.0.4.1)- Throws:
X400APIException
-
setTextBody
public void setTextBody(java.lang.String textbody) throws X400APIException
Set the message content (as a single IA5 text bodypart)- Parameters:
textbody
- The string representation of the content of the message, in a simple IA5 string.- Throws:
X400APIException
-
addExistingBodypart
public void addExistingBodypart(BodyPart existing_bodypart) throws X400APIException
Add an existing bodypart to a message, typically a bodypart that was extracted from a received message.- Parameters:
existing_bodypart
-- Throws:
X400APIException
-
addBodypart
public void addBodypart(Bodypart new_bodypart) throws X400APIException
Add a newly created bodypart to a message, this is typically used when composing.- Parameters:
new_bodypart
- existing Bodypart object- Throws:
X400APIException
-
addMessageForwardBodypart
public void addMessageForwardBodypart(BodypartForwardedMessage fwd) throws X400APIException
Create a new Message Forward Bodypart- Parameters:
fwd
- Forwarded Message object to be used a the forward bodypart- Throws:
X400APIException
-
setStringparam
public void setStringparam(int param, java.lang.String value) throws X400APIException
There are attributes of an X.400 message that can be set that are not commonly used. This method allows setting of these attributes that have String values using a single method. Please refer to the X.400 recommendations for the documentation of these parameters. Set a message parameter that has a String format.- Parameters:
value
- String: String value of the parameterparam
- int: One of the X400_att constants (see below) Current accepted values, taken from the X400_att, constants are:
X400_S_REPLIED_TO_IDENTIFIER
X400_S_OBSOLETED_IPMS
X400_S_RELATED_IPMS
X400_S_EXPIRY_TIME
X400_S_SEC_IDENTITY
X400_S_SEC_IDENTITY_DN
X400_S_SEC_IDENTITY_FILE
X400_S_SEC_IDENTITY_PASSPHRASE
X400_S_SEC_TRUSTED_CERTS_DIR
X400_S_CONTENT_IDENTIFIER
X400_S_CONTENT_FILENAME
X400_S_EXTERNAL_CONTENT_TYPE
X400_S_AUTHORIZATION_TIME:
X400_S_PRECEDENCE_POLICY_ID:
X400_S_ORIGINATORS_REFERENCE:
X400_S_LATEST_DELIVERY_TIME:
X400_S_DEFERRED_DELIVERY_TIME:Current accepted values, taken from the AMHS_att, constants are:
ATS_S_PRIORITY_INDICATOR:
ATS_S_FILING_TIME:
ATS_S_OPTIONAL_HEADING_INFO:
ATS_S_TEXT:- Throws:
X400APIException
-
setIntParam
public void setIntParam(int param, int value) throws X400APIException
There are attributes of an X.400 message that can be set that are not commonly used. This method allows setting of these attributes that have int values using a single method. Please refer to the X.400 recommendations for the documentation of these parameters.- Parameters:
param
- int: One of the X400_att constants (see below)value
- int: Integer value of the parameter Current accepted values, taken from the X400_att, constants are:
X400_N_MTA_REPORT_REQUEST
X400_N_REPORT_REQUEST // Should be per-recipient
X400_N_REPLY_REQUESTED // Should be per-recipient
X400_N_PRIORITY
X400_N_DISCLOSURE
X400_N_IMPLICIT_CONVERSION_PROHIBITED
X400_N_RECIPIENT_REASSIGNMENT_PROHIBITED
X400_N_CONTENT_RETURN_REQUEST
X400_N_DL_EXPANSION_PROHIBITED
X400_N_CONVERSION_WITH_LOSS_PROHIBITED
X400_N_ALTERNATE_RECIPIENT_ALLOWED
X400_N_IMPORTANCE
X400_N_SENSITIVITY
X400_N_AUTOFORWARDED
X400_B_SEC_GEN_MOAC
X400_N_CONTENT_TYPE
X400_N_MMTS_PRIORITY_QUALIFIER
X400_N_EXT_PRIM_PREC
X400_N_EXT_COPY_PREC
X400_N_S4406_SINGLE_WRAP
X400_N_S4406- Throws:
X400APIException
-
setBoolparam
public void setBoolparam(int param, boolean value) throws X400APIException
Set a message parameter that has a Boolean format.- Parameters:
param
- int: One of the X400_att constants (see below)value
- boolean: Boolean value of the parameter- Throws:
X400APIException
-
buildMsg
public void buildMsg(Session session_obj) throws X400APIException
Deprecated.this function does not do anything any more; the underlying C API will generate an IPMIdentifier if you have not added one anywayBuild the message- Parameters:
session_obj
- Session: This is session object, as returned by the MStore getSession() method. Before you call this method, you need to bind to the Message Store, and obtain the session_object that represents the connection. This method is now deprecated - it does not do anything any more.- Throws:
X400APIException
-
sendMsg
public void sendMsg(Session session_obj) throws X400APIException
Submit a message into the Message StoreThe session object is the one returned by the relevant getSession() method. Before you call this method, you need to bind to the Message Store, and obtain the session_object that represents the connection.
- Parameters:
session_obj
- Session:- Throws:
X400APIException
-
getMessageIdentifier
public java.lang.String getMessageIdentifier() throws X400APIException
Returns the Message Identifier: fieldAfter a message is sent, the MTA assigns a message identifier to the object. This method allows the sender to retrieve the Message Identifier that was assigned, so it can be used for correlation with an incoming delivery report.
- Throws:
X400APIException
-
getContentIdentifier
public java.lang.String getContentIdentifier() throws X400APIException
Returns the Content Identifier: fieldAfter a message is sent, the MTA assigns a message identifier to the object. This method allows the sender to retrieve the Message Identifier that was assigned, so it can be used for correlation with an incoming delivery report.
- Throws:
X400APIException
-
getContentType
public int getContentType() throws X400APIException
Returns the Content Type, or -1 if it cannot be found- Throws:
X400APIException
-
getSubmissionTime
public java.lang.String getSubmissionTime() throws X400APIException
Returns the Message Submission time: field X.400 Message Submission Time: UTCTime format YYMMDDHHMMSS<zone>- Throws:
X400APIException
-
setAllRecipPrecedence
public void setAllRecipPrecedence(int p)
Set the message precedence, a single value that applies to all recipients.- Parameters:
p
- : The precedence value to use for all recipients
-
setPriority
public void setPriority(X400Msg.X400_Priority pr) throws X400APIException
Set the message priority, using one of the standard X.400 message priorities- Parameters:
pr
-- Throws:
X400APIException
-
setPriority
public void setPriority(X400Msg.Military_Priority primary, X400Msg.Military_Priority copy) throws X400APIException
Set the message priority, using the standard military message priorities values for the primary and the copy precedence- Parameters:
primary
-copy
-- Throws:
X400APIException
-
addSecurityLabelAsXMLFileName
public void addSecurityLabelAsXMLFileName(java.lang.String sec_label_file) throws X400APIException
Add a security label, providing a file name that contains a security label encoded in an XML file- Parameters:
sec_label_file
-- Throws:
X400APIException
-
addSecurityLabelAsXMLString
public void addSecurityLabelAsXMLString(java.lang.String sec_label_xml) throws X400APIException
Add a security label as an XML encoded String- Parameters:
sec_label_xml
-- Throws:
X400APIException
-
addSecurityLabelAsBER
public void addSecurityLabelAsBER(java.lang.String sec_label_file) throws X400APIException
Add a security label, from a file that contains a BER encoded byte array- Parameters:
sec_label_file
-- Throws:
X400APIException
-
setSecurityLabel
public void setSecurityLabel(com.isode.rbac.swig.JRSecurityLabel sec_label) throws X400APIException
Add a security label as a JRSecurityLabel object- Parameters:
sec_label
-- Throws:
X400APIException
-
getPrintableStringParam
public java.util.ArrayList<java.lang.String> getPrintableStringParam(int param) throws X400APIException
Get a message parameter that has a Printable String format.- Parameters:
param
- int: One of the X400_att constants- Throws:
X400APIException
-
getContentBytes
public byte[] getContentBytes()
Get the content of the message, as a byte[]- Returns:
-
getInvalidRecipients
public java.util.ArrayList<java.lang.String> getInvalidRecipients() throws X400APIException
Returns the message invalid recipients, if any, as an array list of Strings. This only works for IPMs, not for Delivery Reports or IPNs- Parameters:
type
-- Returns:
- an empty ArrayList if there are no invalid recipients, or if the message is a DR or IPN. For IPMs, return an ArrayList of Strings with the O/R addresses of the invalid recipients (if any)
- Throws:
X400APIException
-
-