public class SecureChannelTcp extends Object implements IConnection.IMessageListener, IConnectionListener, ITransportChannel, SecureChannel
Secure channel creates transport channel(s) as needed. If the connection fails, and the transport channel is stateful (TCP), and the secure channel has pending service requests, it attempts to reconnect the transport channel. If the reconnect fails there is a timeout sequence of the following wait periods { 0, 1, 2, 4, 8, 16, 32, 64, 120, 120, ... }.
If error recovery state fails to re-establish new security token before the old expires, the secure channel will be closed. Despite the name SecureChannelTcp, the class is 99% implemented as transport channel agnostic. The plan is to upgrade the class to support SOAP transport and rename to SecureChannelImpl.
ITransportChannel.TransportChannelFeature| Modifier and Type | Field and Description |
|---|---|
static boolean |
disableReconnectLogic
Deprecated.
Temporary flag.
|
| Constructor and Description |
|---|
SecureChannelTcp()
Constructor for SecureChannelTcp.
|
| Modifier and Type | Method and Description |
|---|---|
void |
close()
Close the secure channel.
|
AsyncResult<SecureChannel> |
closeAsync()
closeAsync.
|
void |
dispose()
dispose.
|
String |
getConnectURL()
Return the URL of the connection.
|
EndpointConfiguration |
getEndpointConfiguration()
getEndpointConfiguration.
|
EndpointDescription |
getEndpointDescription()
getEndpointDescription.
|
EncoderContext |
getMessageContext()
getMessageContext.
|
MessageSecurityMode |
getMessageSecurityMode()
Get message security mode.
|
int |
getOperationTimeout()
Get operation timeout
|
protected long |
getRequestTimeout(ServiceRequest request)
getRequestTimeout.
|
int |
getSecureChannelId()
Get secure channel ID
|
SecurityPolicy |
getSecurityPolicy()
Get security policy
|
EnumSet<ITransportChannel.TransportChannelFeature> |
getSupportedFeatures()
Get a list of features supported by the channel.
|
void |
initialize(InetSocketAddress addr,
TransportChannelSettings settings,
EncoderContext ctx)
Configure the secure channel.
|
void |
initialize(String url,
TransportChannelSettings settings,
EncoderContext ctx)
Configure the secure channel.
|
void |
initialize(TransportChannelSettings settings,
EncoderContext ctx)
Configure the secure channel.
|
boolean |
isOpen()
Return true if the secure channel has been opened and is not (hopefully) closed on the server.
|
void |
onClosed(ServiceResultException closeError)
The connection has been closed
|
void |
onMessage(int requestId,
int secureChannelId,
IEncodeable message)
New message arrived to the connection.
|
void |
onOpen()
onOpen.
|
void |
open()
Opens a secure channel.
|
AsyncResult<SecureChannel> |
openAsync()
Asynchronous open channel.
|
<T extends ServiceResponse> |
serviceRequest(ServiceRequest<T> request)
Send a service request over the secure channel.
|
<T extends ServiceResponse> |
serviceRequest(ServiceRequest<T> request,
long operationTimeout)
Send a service request over the secure channel.
|
<T extends ServiceResponse> |
serviceRequestAsync(ServiceRequest<T> request)
Asynchronous operation to send a request over the secure channel.
|
<T extends ServiceResponse> |
serviceRequestAsync(ServiceRequest<T> request,
long operationTimeout)
Asynchronous operation to send a request over the secure channel.
|
void |
setOperationTimeout(int timeout)
Set operation timeout
|
protected void |
setTransportChannel(IConnection transportChannel)
Setter for the field
transportChannel. |
String |
toString() |
@Deprecated public static boolean disableReconnectLogic
public void close()
This method sends CloseSecureChannelRequest to the server and closes the socket connection. If sending of the message fails and thus the servers never receives notification about closed secure channel, then there is no resend attempt, instead the secure channel will eventually time out in the server.
All pending requests will fault with Bad_SecureChannelClosed
close in interface SecureChannelpublic AsyncResult<SecureChannel> closeAsync()
closeAsync.
closeAsync in interface SecureChannelAsyncResult object.public void dispose()
ITransportChanneldispose.
dispose in interface SecureChanneldispose in interface ITransportChannelpublic String getConnectURL()
SecureChannelgetConnectURL in interface SecureChannelpublic EndpointConfiguration getEndpointConfiguration()
ITransportChannelgetEndpointConfiguration.
getEndpointConfiguration in interface SecureChannelgetEndpointConfiguration in interface ITransportChannelEndpointConfiguration object.public EndpointDescription getEndpointDescription()
ITransportChannelgetEndpointDescription.
getEndpointDescription in interface SecureChannelgetEndpointDescription in interface ITransportChannelEndpointDescription object.public EncoderContext getMessageContext()
ITransportChannelgetMessageContext.
getMessageContext in interface SecureChannelgetMessageContext in interface ITransportChannelEncoderContext object.public MessageSecurityMode getMessageSecurityMode()
SecureChannelgetMessageSecurityMode in interface SecureChannelpublic int getOperationTimeout()
ITransportChannelgetOperationTimeout in interface SecureChannelgetOperationTimeout in interface ITransportChannelpublic int getSecureChannelId()
SecureChannelgetSecureChannelId in interface SecureChannelpublic SecurityPolicy getSecurityPolicy()
SecureChannelgetSecurityPolicy in interface SecureChannelpublic EnumSet<ITransportChannel.TransportChannelFeature> getSupportedFeatures()
ITransportChannelgetSupportedFeatures in interface ITransportChannelEnumSet object.public void initialize(InetSocketAddress addr, TransportChannelSettings settings, EncoderContext ctx) throws ServiceResultException
ServiceResultExceptionpublic void initialize(String url, TransportChannelSettings settings, EncoderContext ctx) throws ServiceResultException
initialize in interface SecureChannelinitialize in interface ITransportChannelurl - a String object.settings - a TransportChannelSettings object.ctx - a EncoderContext object.ServiceResultException - if any.public void initialize(TransportChannelSettings settings, EncoderContext ctx) throws ServiceResultException
initialize in interface SecureChannelsettings - a TransportChannelSettings object.ctx - a EncoderContext object.ServiceResultException - if any.public boolean isOpen()
isOpen in interface SecureChannelpublic void onClosed(ServiceResultException closeError)
onClosed in interface IConnectionListenercloseError - a ServiceResultException object.public void onMessage(int requestId,
int secureChannelId,
IEncodeable message)
onMessage in interface IConnection.IMessageListenerpublic void onOpen()
onOpen.
onOpen in interface IConnectionListenerpublic void open()
throws ServiceResultException
Thread.interrupt() a
Bad_Timeout is thrown.open in interface SecureChannelServiceResultException - if any.public AsyncResult<SecureChannel> openAsync()
openAsync in interface SecureChannelpublic <T extends ServiceResponse> T serviceRequest(ServiceRequest<T> request) throws ServiceFaultException, ServiceResultException
If the operation timeouts or the thread is interrupted a ServiceResultException is thrown with
StatusCodes.Bad_Timeout.
Send service request to the server. If the secure channel is in error recovery state, the request is put to a send queue. Message is sent upon successful reconnection.
If the transport channel fails and cannot be restablished within operation timeout period,
StatusCodes.Bad_RequestTimeout is set as error.
If the secure channel is not open, is expired or closed
StatusCodes.Bad_SecureChannelClosed is thrown.
If the thread is interrupted with Thread.interrupt(), the operation aborts and
ServiceResultException Bad_RequestCancelledByClient is thrown.
serviceRequest in interface RequestChannelserviceRequest in interface SecureChannelserviceRequest in interface ITransportChannelT - type of the response (determined automatically from the request).request - a ServiceRequest object.ServiceResponse object.ServiceResultException - if errorServiceFaultExceptionpublic <T extends ServiceResponse> T serviceRequest(ServiceRequest<T> request, long operationTimeout) throws ServiceFaultException, ServiceResultException
If the operation timeouts or the operation is interrupted and a ServiceResultException is
thrown with StatusCodes.Bad_Timeout.
serviceRequest in interface ITransportChannelrequest - a ServiceRequest object.operationTimeout - timeout time in millisecondsServiceResponse object.ServiceResultException - if any.ServiceFaultExceptionpublic <T extends ServiceResponse> AsyncResult<T> serviceRequestAsync(ServiceRequest<T> request)
If the transport channel fails and cannot be re-established within operation timeout period,
StatusCodes.Bad_RequestTimeout is set as error.
If the secure channel is not open, is expired or closed
StatusCodes.Bad_SecureChannelClosed is thrown.
Errors are written to the result object. ServiceFaultException There was a service fault in
processing of the operation in the server. ServiceResultException There was an error while
transferring the operation over network.
serviceRequestAsync in interface RequestChannelserviceRequestAsync in interface SecureChannelserviceRequestAsync in interface ITransportChannelT - type of the response (determined automatically from the request).request - the requestpublic <T extends ServiceResponse> AsyncResult<T> serviceRequestAsync(ServiceRequest<T> request, long operationTimeout)
If the transport channel fails and cannot be restablished within operation timeout period,
StatusCodes.Bad_RequestTimeout is set as error.
If the secure channel is not open, is expired or closed
StatusCodes.Bad_SecureChannelClosed is thrown.
Errors are written to the result object. ServiceFaultException There was a service fault in
processing of the operation in the server. ServiceResultException There was an error while
transferring the operation over network.
serviceRequestAsync in interface ITransportChannelrequest - the requestoperationTimeout - timeout timepublic void setOperationTimeout(int timeout)
setOperationTimeout in interface SecureChannelsetOperationTimeout in interface ITransportChanneltimeout - in millisecondsprotected long getRequestTimeout(ServiceRequest request)
getRequestTimeout.
request - a ServiceRequest object.protected void setTransportChannel(IConnection transportChannel)
Setter for the field transportChannel.
transportChannel - the transportChannel to setCopyright © 2026. All rights reserved.