Package com.isode.som

Class SomSession

  • Direct Known Subclasses:
    SomPumiceSession, SomQmgrSession

    public class SomSession
    extends java.lang.Object
    Class which implements a SOM connection between a client application and a SOM server - i.e. the Queue Manager or a Isode M-Store X.400 server. Functionality for opening and closing connections (including use of SASL is included.
    Author:
    tc
    • Constructor Detail

      • SomSession

        public SomSession()
        Create a new SomSession object
      • SomSession

        public SomSession​(SomHandler handler)
        Create a new SomSession object.
        Parameters:
        handler - object which will handle command responses
    • Method Detail

      • setProtocol

        public void setProtocol​(java.lang.String prot)
      • setConnectionTimeout

        public void setConnectionTimeout​(int t)
        Set connection timeout.
        Parameters:
        t - timeout in seconds
      • getErrorText

        public static java.lang.String getErrorText​(int status)
        Obtain a string representation of a given error code.
        Parameters:
        status - error code
        Returns:
        string representation of error code
      • getRights

        public java.lang.String getRights()
      • isConnected

        public boolean isConnected()
        Test whether the session is connected
        Returns:
        true if connected
      • isConnecting

        public boolean isConnecting()
        Test whether we are in the process of establishing a connection.
        Returns:
        true if we are in the middle of connection establishment
      • isDisconnected

        public boolean isDisconnected()
        Test whether the session is disconnected
        Returns:
        true if not connected
      • isAsync

        public boolean isAsync()
        Test whether session is an asynchonous one
        Returns:
        true if asynchronous
      • setAsync

        public void setAsync​(boolean async)
        Set session to be asynchronous
        Parameters:
        async - whether session should be asynchronous or not
      • getOpStatus

        public int getOpStatus()
        Get operation status value
        Returns:
        operation status
      • setOpStatus

        public void setOpStatus​(int val)
        Set operation status
        Parameters:
        val - value to set
      • open

        public void open​(java.lang.String host,
                         int port,
                         java.lang.String username,
                         java.lang.String password)
                  throws SomException
        Open a connection, using SIMPLE authentication
        Parameters:
        host - hostname or IP address to connect to
        port - port to use
        username - username to use
        password - password to use
        Throws:
        SomException - on error
      • open

        public void open​(java.lang.String host,
                         int port,
                         java.lang.String username,
                         java.lang.String password,
                         java.lang.String mechanism)
                  throws SomException
        Open a connection using a specific SASL mechanism
        Parameters:
        host - hostname or IP address to connect to
        port - port to use
        username - username to use
        password - password to use
        mechanism - SASL mechanism to use
        Throws:
        SomException - on error
      • open

        public void open​(java.lang.String host,
                         int port,
                         java.lang.String username,
                         java.lang.String password,
                         java.lang.String mechanism,
                         boolean useTls)
                  throws SomException
        Open a connection using a specific SASL mechanism over TLS
        Parameters:
        host - hostname or IP address to connect to
        port - port to use
        username - username to use
        password - password to use
        mechanism - SASL mechanism to use
        useTls - whether to use TLS or not
        Throws:
        SomException - on error
      • open

        public void open​(java.lang.String host,
                         int port,
                         java.lang.String authid,
                         java.lang.String authzid,
                         java.lang.String password,
                         java.lang.String mechanism,
                         boolean useTls)
                  throws SomException
        Open a connection using a specific SASL mechanism over TLS
        Parameters:
        host - hostname or IP address to connect to
        port - port to use
        username - username to use
        password - password to use
        mechanism - SASL mechanism to use
        useTls - whether to use TLS or not
        Throws:
        SomException - on error
      • somSessionDebugPrefix

        public void somSessionDebugPrefix​(java.lang.String prefix)
        The prefix given is used to name the SomSession thread, making it easy to indetify in a debugger.
        Parameters:
        prefix -
      • getPeerCertificates

        public java.util.List<com.isode.crypto.x509.SSLCertificate> getPeerCertificates()
        Get a list of the SSL Certificates which the server has returned when a TLS-encrypted connection is in use.
        Returns:
        list of SSLCertificates, or null if TLS not in use.
      • close

        public void close()
        Close an open connection
      • authenticated

        public boolean authenticated()
        Check whether the connection is authenticated or not
        Returns:
        true if authenticated connection
      • getSupportedMechanisms

        public java.lang.String[] getSupportedMechanisms()
        Get the list of SASL mechanisms which this Queue Manager supports.
        Returns:
        list of mechanisms, which may be null
        Since:
        16.1
      • waitForCommand

        public void waitForCommand​(long timeout)
                            throws SomException
        Wait for some sort of response to come back to a command
        Parameters:
        timeout - length of time to wait
        Throws:
        SomException - on error
      • pauseResults

        public void pauseResults​(boolean cache)
      • sendCommand

        public void sendCommand​(SomCommand commandObj)
                         throws SomException
        Send a command out over the wire
        Parameters:
        commandObj - Command object to send
        Throws:
        SomException - on error
      • sendCommand

        public void sendCommand​(SomCommand commandObj,
                                boolean withCrlfs)
                         throws SomException
        Send a command out over the wire
        Parameters:
        commandObj - Command object to send
        withCrlfs - true if the command should be followed by CRLFs before sending, false otherwise
        Throws:
        SomException - on error
      • sendResponse

        public void sendResponse​(SomCommand commandObj,
                                 java.lang.String resp)
                          throws SomException
        Send a response back to the server.
        Parameters:
        commandObj - Command object with which response is associated
        resp - Response string
        Throws:
        SomException - on error
      • registerLogMonitorCommand

        public void registerLogMonitorCommand​(SomCommand commandObj)
                                       throws SomException
        Register a persistent handler for LOGMON responses
        Parameters:
        commandObj - Command object which handler is associated with
        Throws:
        SomException - on error
      • getHostName

        public java.lang.String getHostName()
        Get the hostname for this session
        Returns:
        host name