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.
  • Field Details

    • 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:
    • 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:
    • 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:
    • P772_OID

      public static final String P772_OID
      See Also:
  • Constructor Details

    • X400Msg

      public X400Msg(P3BindSession p3bind)
    • X400Msg

      public X400Msg(P3BindSession p3bind, boolean probe)
    • X400Msg

      public X400Msg(Session session_obj, boolean probe)
  • Method Details

    • 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 Throwable
      Overrides:
      finalize in class Object
      Throws:
      Throwable
    • setRecipient

      public Recip setRecipient(int r_type, 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 address
      rep_request - int: Integer value for the Delivery Report request
      ipn_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, String oraddress, X400Msg.DR_Request rep_request, int ipn_request) throws X400APIException
      Set a message recipient
      Parameters:
      envelope - boolean : include it in the envelope too
      r_type - int : Recipient type (see below)
      oraddress - String: String encoded X.400 O/R address
      rep_request - int: Integer value for the Delivery Report request
      ipn_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(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 recipient
      rep_request - Delivery Report Request for this recipient
      ipn_request - IPN Request for this recipient
      Throws:
      X400APIException
    • setIPMHeadingPrimaryRecipient

      public Recip setIPMHeadingPrimaryRecipient(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 recipient
      rep_request - Delivery Report Request for this recipient
      ipn_request - IPN Request for this recipient
      Throws:
      X400APIException
    • setIPMHeadingCopyRecipient

      public Recip setIPMHeadingCopyRecipient(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 recipient
      rep_request - Delivery Report Request for this recipient
      ipn_request - IPN Request for this recipient
      Throws:
      X400APIException
    • setIPMHeadingBlindCopyRecipient

      public Recip setIPMHeadingBlindCopyRecipient(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 recipient
      rep_request - Delivery Report Request for this recipient
      ipn_request - IPN Request for this recipient
      Throws:
      X400APIException
    • setTo

      public Recip setTo(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 recipient
      rep_request - Delivery Report Request for this recipient
      ipn_request - IPN Request for this recipient
      Throws:
      X400APIException
    • setCc

      public Recip setCc(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 recipient
      rep_request - Delivery Report Request for this recipient
      ipn_request - IPN Request for this recipient
      Throws:
      X400APIException
    • setBcc

      public Recip setBcc(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 recipient
      rep_request - Delivery Report Request for this recipient
      ipn_request - IPN Request for this recipient
      Throws:
      X400APIException
    • setFrom

      public Recip setFrom(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, String ffn) throws X400APIException
      Set the free form name of a recipient (or sender)
      Parameters:
      ms_recip_obj -
      ffn -
      Throws:
      X400APIException
    • getFreeFormName

      public 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(String subject) throws X400APIException
      Set the message Subject: field
      Parameters:
      subject - String: Subject of the message
      Throws:
      X400APIException
    • setMessageIPMIdentifier

      public void setMessageIPMIdentifier(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 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(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, 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 parameter
      param - 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 anyway
      Build 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 Store

      The 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 String getMessageIdentifier() throws X400APIException
      Returns the Message Identifier: field

      After 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 String getContentIdentifier() throws X400APIException
      Returns the Content Identifier: field

      After 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 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(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(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(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 ArrayList<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 ArrayList<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