Package com.isode.som
Class SomSession
- java.lang.Object
-
- com.isode.som.SomSession
-
- Direct Known Subclasses:
SomPumiceSession,SomQmgrSession
public class SomSession extends java.lang.ObjectClass 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 classSomSession.SomRights
-
Field Summary
Fields Modifier and Type Field Description static java.lang.StringACP127_PROTOCOLprotected longconnectionTimeoutstatic java.lang.StringGSSAPIcom.isode.som.SomThreadlistenerThreadstatic java.lang.StringOTAM_PROTOCOLstatic intSOM_ERROR_ABORTstatic intSOM_ERROR_AUTHFAILEDstatic intSOM_ERROR_FAILEDstatic intSOM_ERROR_INTERNALstatic intSOM_ERROR_LIMITREACHEDstatic intSOM_ERROR_MOREstatic intSOM_ERROR_NETWORKError codes which can be returned.static intSOM_ERROR_OKstatic intSOM_ERROR_PROTOCOLstatic java.lang.StringSOM_PROTOCOLUseful 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 booleanauthenticated()Check whether the connection is authenticated or notvoidclose()Close an open connectionstatic java.lang.StringgetErrorText(int status)Obtain a string representation of a given error code.java.lang.StringgetHostName()Get the hostname for this sessionintgetOpStatus()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.StringgetRights()java.lang.String[]getSupportedMechanisms()Get the list of SASL mechanisms which this Queue Manager supports.booleanhasRight(SomSession.SomRights r)booleanisAsync()Test whether session is an asynchonous onebooleanisConnected()Test whether the session is connectedbooleanisConnecting()Test whether we are in the process of establishing a connection.booleanisDisconnected()Test whether the session is disconnectedvoidopen(java.lang.String host, int port, java.lang.String username, java.lang.String password)Open a connection, using SIMPLE authenticationvoidopen(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 mechanismvoidopen(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 TLSvoidopen(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 TLSvoidpauseResults(boolean cache)voidregisterACP127AnonStatusCommand(SomCommand commandObj)voidregisterACP127CircuitCreateCommand(SomCommand commandObj)voidregisterACP127CircuitDeleteCommand(SomCommand commandObj)voidregisterACP127CircuitUpdate(SomCommand commandObj)voidregisterACP127MonitorDataSameCommand(SomCommand commandObj)voidregisterACP127MonitorMsgStatusCommand(SomCommand commandObj)voidregisterACP127MonitorRateCommand(SomCommand commandObj)voidregisterACP127MonitorReadCommand(SomCommand commandObj)voidregisterACP127MonitorReadMissCommand(SomCommand commandObj)voidregisterACP127MonitorWriteCommand(SomCommand commandObj)voidregisterACP127MonitorWriteMissCommand(SomCommand commandObj)voidregisterACP127MonStatusCommand(SomCommand commandObj)voidregisterACP127NewMsgOutCommand(SomCommand commandObj)voidregisterACP127OTAMStatusCommand(SomCommand commandObj)voidregisterLogMonitorCommand(SomCommand commandObj)Register a persistent handler for LOGMON responsesvoidregisterRecapListCommand(SomCommand commandObj)voidregisterStoreMonitorCommand(SomCommand commandObj)voidsendCommand(SomCommand commandObj)Send a command out over the wirevoidsendCommand(SomCommand commandObj, boolean withCrlfs)Send a command out over the wirevoidsendResponse(SomCommand commandObj, java.lang.String resp)Send a response back to the server.voidsetAsync(boolean async)Set session to be asynchronousvoidsetConnectionTimeout(int t)Set connection timeout.voidsetOpStatus(int val)Set operation statusvoidsetProtocol(java.lang.String prot)voidsomSessionDebugPrefix(java.lang.String prefix)The prefix given is used to name the SomSession thread, making it easy to indetify in a debugger.voidwaitForCommand(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 SomExceptionOpen 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 SomExceptionOpen 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 SomExceptionOpen 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 SomExceptionOpen 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 SomExceptionWait 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
-
-