Class P3BindSession

  • Direct Known Subclasses:
    P7BindSession

    public class P3BindSession
    extends Session
    Abstracts the connection used for submission to a P3 channel and/or P7 message store The documentation in the examples here refer to P3 channel. The class MStore extends this class and adds P7 Message Store specific methods, like listing the content of a mailbox, deleting messages, etc.
    • Field Summary

      Fields 
      Modifier and Type Field Description
      protected static java.util.concurrent.Semaphore available  
      protected boolean bound
      Boolean value that represents if the session is bound or not
      protected java.lang.String credentials
      The password for the P3 user
      protected boolean disable_config_requests
      Disable configuration requests in MS bind operations
      protected java.lang.String pa
      Presentation Address of the P3 channel
      protected boolean sec_init
      Boolean value that represents if the security environment has been initialized or not
      protected java.lang.String user_dn
      P3 user DN
      protected java.lang.String user_oraddr
      P3 user O/R address
    • Constructor Summary

      Constructors 
      Constructor Description
      P3BindSession​(java.lang.String presentation_address, java.lang.String or_addr, java.lang.String passwd)
      Create a P3BindSession
      P3BindSession​(java.lang.String presentation_address, java.lang.String or_addr, java.lang.String passwd, boolean submit_only)
      Create a P3BindSession, specifying whether the session should be used for Submission only or not.
    • Field Detail

      • pa

        protected java.lang.String pa
        Presentation Address of the P3 channel
      • user_oraddr

        protected java.lang.String user_oraddr
        P3 user O/R address
      • user_dn

        protected java.lang.String user_dn
        P3 user DN
      • credentials

        protected java.lang.String credentials
        The password for the P3 user
      • disable_config_requests

        protected boolean disable_config_requests
        Disable configuration requests in MS bind operations
      • bound

        protected boolean bound
        Boolean value that represents if the session is bound or not
      • sec_init

        protected boolean sec_init
        Boolean value that represents if the security environment has been initialized or not
      • available

        protected static final java.util.concurrent.Semaphore available
    • Constructor Detail

      • P3BindSession

        public P3BindSession​(java.lang.String presentation_address,
                             java.lang.String or_addr,
                             java.lang.String passwd)
        Create a P3BindSession
        Parameters:
        presentation_address - the P3 channel's Presentation Address Typical values are "593"/Internet=myserver.mycompany.com
        or_addr - the string encoded O/R address of the P3 channel user. For example /"cn=John Smith, o=Address Book, o=Isode, c=GB"
        passwd - the P3 channel's password that correspond to the user
      • P3BindSession

        public P3BindSession​(java.lang.String presentation_address,
                             java.lang.String or_addr,
                             java.lang.String passwd,
                             boolean submit_only)
        Create a P3BindSession, specifying whether the session should be used for Submission only or not.
        Parameters:
        presentation_address - the P3 channel's Presentation Address Typical values are "593"/Internet=myserver.mycompany.com
        or_addr - the string encoded O/R address of the P3 channel user. For example /"cn=John Smith, o=Address Book, o=Isode, c=GB"
        passwd - the P3 channel's password that correspond to the user
        submit_only - Set to true if this session is only to be used for submission
    • Method Detail

      • setUserDN

        public void setUserDN​(java.lang.String my_user_dn)
                       throws BadDNException
        Set the P3 channel user's DN

        This is the string encoded O/R address of the user. For example /"cn=John Smith, o=Address Book, o=Isode, c=GB"

        Throws:
        BadDNException
      • setDisableConfigRequest

        public void setDisableConfigRequest​(boolean b)
        Enables or disables the request of configuration from the MTA or Message Store. This will be needed by some non-Isode Message Stores or MTAs, like the Deutsche Telekom service.
        Parameters:
        b -
      • acquireSemaphore

        protected void acquireSemaphore()
                                 throws java.lang.InterruptedException
        Throws:
        java.lang.InterruptedException
      • releaseSemaphore

        protected void releaseSemaphore()
      • getSession

        public Session getSession()
        Retrieve the Session object
        Returns:
        A Session object. This is the object that is need to, for example, read or create a message
      • isBound

        public boolean isBound()
        Check if this session is bound or not.

        This means that the application think it is still bound to the server, but bear in mind that the connection may have been dropped by the server for any number of reasons, and this application won't be informed.

        Returns:
        Returns true if the session bind() was successful and unbind() was not called.
      • unbind

        public void unbind()
                    throws X400APIException
        Unbind from the P3 channel or P7 Message Store.

        Closes the connection to the the P3 channel or P7 Message Store. No more messages can be sent or received until a new connection is open.

        Throws:
        X400APIException
      • unbind

        public void unbind​(boolean force)
                    throws X400APIException
        Unbind from the P3 channel or P7 Message Store.

        Closes the connection to the the P3 channel or P7 Message Store. No more messages can be sent or received until a new connection is open.

        Parameters:
        force - ignore InterruptedException when acquiring semaphore
        Throws:
        X400APIException
      • setSecurityEnv

        public void setSecurityEnv​(java.lang.String id,
                                   java.lang.String id_dn,
                                   java.lang.String pass)
                            throws X400APIException
        Set the session's security environment data.

        The information is passed on to the underlying API, but is not checked at this stage. This means that the information may be invalid, but won't be noticed until later on.

        Parameters:
        pkcs12file - - The absolute path of the PKCS#12 file with the user certificate
        pkcs12password - - The password for the PKCS#12 user certificate
        sec_trusted_ca_cert_dir - - The directory where the trusted certificates for the CAs are kept
        Throws:
        X400APIException
      • setSecurityEnvPKCS12

        public void setSecurityEnvPKCS12​(java.lang.String pkcs12FileName,
                                         java.lang.String password,
                                         java.lang.String sec_trusted_ca_cert_dir)
                                  throws X400APIException
        Set the session's security environment data.

        The information is passed on to the underlying API, but is not checked at this stage. This means that the information may be invalid, but won't be noticed until later on.

        Parameters:
        pkcs12FileName - String : The PKCS#12 file that corresponds to this user, containing it's O/R address
        password - String : Passphrase to open the PKCS#12 file
        sec_trusted_ca_cert_dir - : the directory where the CA's trusted certificates are kept (optional)
        Throws:
        X400APIException
        Since:
        15.0
      • waitForNewMessages

        public int waitForNewMessages​(int seconds)
                               throws X400APIException
        Wait for a new message the specified number of seconds. If seconds is 0, then there's no wait. If seconds is negative, then the delay is indefinite.
        Parameters:
        seconds -
        Returns:

        X400_att.X400_E_NOERROR if there were no errors and a message is ready to be read

        X400_att.X400_E_TIMED_OUT: if no messages arrived in the specified number of seconds

        X400_att.X400_E_NO_MESSAGE: if there are no more messages to read

        Throws:
        X400APIException