Package com.isode.som
Class SomSession
- java.lang.Object
-
- com.isode.som.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
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static class
SomSession.SomRights
-
Field Summary
Fields Modifier and Type Field Description static java.lang.String
ACP127_PROTOCOL
protected long
connectionTimeout
static java.lang.String
GSSAPI
com.isode.som.SomThread
listenerThread
static java.lang.String
OTAM_PROTOCOL
static int
SOM_ERROR_ABORT
static int
SOM_ERROR_AUTHFAILED
static int
SOM_ERROR_FAILED
static int
SOM_ERROR_INTERNAL
static int
SOM_ERROR_LIMITREACHED
static int
SOM_ERROR_MORE
static int
SOM_ERROR_NETWORK
Error codes which can be returned.static int
SOM_ERROR_OK
static int
SOM_ERROR_PROTOCOL
static java.lang.String
SOM_PROTOCOL
Useful string values
-
Constructor Summary
Constructors Constructor Description SomSession()
Create a new SomSession objectSomSession(SomHandler handler)
Create a new SomSession object.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description boolean
authenticated()
Check whether the connection is authenticated or notvoid
close()
Close an open connectionstatic java.lang.String
getErrorText(int status)
Obtain a string representation of a given error code.java.lang.String
getHostName()
Get the hostname for this sessionint
getOpStatus()
Get operation status valuejava.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.java.lang.String
getRights()
java.lang.String[]
getSupportedMechanisms()
Get the list of SASL mechanisms which this Queue Manager supports.boolean
hasRight(SomSession.SomRights r)
boolean
isAsync()
Test whether session is an asynchonous oneboolean
isConnected()
Test whether the session is connectedboolean
isConnecting()
Test whether we are in the process of establishing a connection.boolean
isDisconnected()
Test whether the session is disconnectedvoid
open(java.lang.String host, int port, java.lang.String username, java.lang.String password)
Open a connection, using SIMPLE authenticationvoid
open(java.lang.String host, int port, java.lang.String username, java.lang.String password, java.lang.String mechanism)
Open a connection using a specific SASL mechanismvoid
open(java.lang.String host, int port, java.lang.String username, java.lang.String password, java.lang.String mechanism, boolean useTls)
Open a connection using a specific SASL mechanism over TLSvoid
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)
Open a connection using a specific SASL mechanism over TLSvoid
pauseResults(boolean cache)
void
registerACP127AnonStatusCommand(SomCommand commandObj)
void
registerACP127CircuitCreateCommand(SomCommand commandObj)
void
registerACP127CircuitDeleteCommand(SomCommand commandObj)
void
registerACP127CircuitUpdate(SomCommand commandObj)
void
registerACP127MonitorDataSameCommand(SomCommand commandObj)
void
registerACP127MonitorMsgStatusCommand(SomCommand commandObj)
void
registerACP127MonitorRateCommand(SomCommand commandObj)
void
registerACP127MonitorReadCommand(SomCommand commandObj)
void
registerACP127MonitorReadMissCommand(SomCommand commandObj)
void
registerACP127MonitorWriteCommand(SomCommand commandObj)
void
registerACP127MonitorWriteMissCommand(SomCommand commandObj)
void
registerACP127MonStatusCommand(SomCommand commandObj)
void
registerACP127NewMsgOutCommand(SomCommand commandObj)
void
registerACP127OTAMStatusCommand(SomCommand commandObj)
void
registerLogMonitorCommand(SomCommand commandObj)
Register a persistent handler for LOGMON responsesvoid
registerRecapListCommand(SomCommand commandObj)
void
registerStoreMonitorCommand(SomCommand commandObj)
void
sendCommand(SomCommand commandObj)
Send a command out over the wirevoid
sendCommand(SomCommand commandObj, boolean withCrlfs)
Send a command out over the wirevoid
sendResponse(SomCommand commandObj, java.lang.String resp)
Send a response back to the server.void
setAsync(boolean async)
Set session to be asynchronousvoid
setConnectionTimeout(int t)
Set connection timeout.void
setOpStatus(int val)
Set operation statusvoid
setProtocol(java.lang.String prot)
void
somSessionDebugPrefix(java.lang.String prefix)
The prefix given is used to name the SomSession thread, making it easy to indetify in a debugger.void
waitForCommand(long timeout)
Wait for some sort of response to come back to a command
-
-
-
Field Detail
-
SOM_ERROR_NETWORK
public static final int SOM_ERROR_NETWORK
Error codes which can be returned.- See Also:
- Constant Field Values
-
SOM_ERROR_ABORT
public static final int SOM_ERROR_ABORT
- See Also:
- Constant Field Values
-
SOM_ERROR_INTERNAL
public static final int SOM_ERROR_INTERNAL
- See Also:
- Constant Field Values
-
SOM_ERROR_PROTOCOL
public static final int SOM_ERROR_PROTOCOL
- See Also:
- Constant Field Values
-
SOM_ERROR_LIMITREACHED
public static final int SOM_ERROR_LIMITREACHED
- See Also:
- Constant Field Values
-
SOM_ERROR_AUTHFAILED
public static final int SOM_ERROR_AUTHFAILED
- See Also:
- Constant Field Values
-
SOM_ERROR_MORE
public static final int SOM_ERROR_MORE
- See Also:
- Constant Field Values
-
SOM_ERROR_FAILED
public static final int SOM_ERROR_FAILED
- See Also:
- Constant Field Values
-
SOM_ERROR_OK
public static final int SOM_ERROR_OK
- See Also:
- Constant Field Values
-
SOM_PROTOCOL
public static final java.lang.String SOM_PROTOCOL
Useful string values- See Also:
- Constant Field Values
-
ACP127_PROTOCOL
public static final java.lang.String ACP127_PROTOCOL
- See Also:
- Constant Field Values
-
OTAM_PROTOCOL
public static final java.lang.String OTAM_PROTOCOL
- See Also:
- Constant Field Values
-
GSSAPI
public static final java.lang.String GSSAPI
- See Also:
- Constant Field Values
-
connectionTimeout
protected long connectionTimeout
-
listenerThread
public com.isode.som.SomThread listenerThread
-
-
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
-
hasRight
public boolean hasRight(SomSession.SomRights r)
-
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 toport
- port to useusername
- username to usepassword
- 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 toport
- port to useusername
- username to usepassword
- password to usemechanism
- 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 toport
- port to useusername
- username to usepassword
- password to usemechanism
- SASL mechanism to useuseTls
- 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 toport
- port to useusername
- username to usepassword
- password to usemechanism
- SASL mechanism to useuseTls
- 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 sendwithCrlfs
- 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 associatedresp
- 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
-
registerStoreMonitorCommand
public void registerStoreMonitorCommand(SomCommand commandObj) throws SomException
- Throws:
SomException
-
registerRecapListCommand
public void registerRecapListCommand(SomCommand commandObj) throws SomException
- Throws:
SomException
-
registerACP127MonitorWriteCommand
public void registerACP127MonitorWriteCommand(SomCommand commandObj) throws SomException
- Throws:
SomException
-
registerACP127CircuitDeleteCommand
public void registerACP127CircuitDeleteCommand(SomCommand commandObj) throws SomException
- Throws:
SomException
-
registerACP127CircuitCreateCommand
public void registerACP127CircuitCreateCommand(SomCommand commandObj) throws SomException
- Throws:
SomException
-
registerACP127CircuitUpdate
public void registerACP127CircuitUpdate(SomCommand commandObj) throws SomException
- Throws:
SomException
-
registerACP127MonitorReadCommand
public void registerACP127MonitorReadCommand(SomCommand commandObj) throws SomException
- Throws:
SomException
-
registerACP127MonitorRateCommand
public void registerACP127MonitorRateCommand(SomCommand commandObj) throws SomException
- Throws:
SomException
-
registerACP127MonitorReadMissCommand
public void registerACP127MonitorReadMissCommand(SomCommand commandObj) throws SomException
- Throws:
SomException
-
registerACP127MonitorWriteMissCommand
public void registerACP127MonitorWriteMissCommand(SomCommand commandObj) throws SomException
- Throws:
SomException
-
registerACP127MonitorMsgStatusCommand
public void registerACP127MonitorMsgStatusCommand(SomCommand commandObj) throws SomException
- Throws:
SomException
-
registerACP127MonitorDataSameCommand
public void registerACP127MonitorDataSameCommand(SomCommand commandObj) throws SomException
- Throws:
SomException
-
registerACP127OTAMStatusCommand
public void registerACP127OTAMStatusCommand(SomCommand commandObj) throws SomException
- Throws:
SomException
-
registerACP127MonStatusCommand
public void registerACP127MonStatusCommand(SomCommand commandObj) throws SomException
- Throws:
SomException
-
registerACP127AnonStatusCommand
public void registerACP127AnonStatusCommand(SomCommand commandObj) throws SomException
- Throws:
SomException
-
registerACP127NewMsgOutCommand
public void registerACP127NewMsgOutCommand(SomCommand commandObj) throws SomException
- Throws:
SomException
-
getHostName
public java.lang.String getHostName()
Get the hostname for this session- Returns:
- host name
-
-