|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectorg.opcfoundation.ua.transport.tcp.io.SecureChannelTcp
public class SecureChannelTcp
Client's Secure Channel connection to an endpoint.
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.
| Nested Class Summary |
|---|
| Nested classes/interfaces inherited from interface org.opcfoundation.ua.transport.tcp.io.ITransportChannel |
|---|
ITransportChannel.TransportChannelFeature |
| Constructor Summary | |
|---|---|
SecureChannelTcp()
Constructor for SecureChannelTcp. |
|
| Method Summary | |
|---|---|
void |
close()
Close the secure channel. |
AsyncResult<SecureChannel> |
closeAsync()
closeAsync. |
void |
dispose()
dispose. |
ServerConnection |
getConnection()
Get current socket connection if applicable for the binding type. |
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()
getOperationTimeout. |
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)
Initialize a secure channel with endpoint identified by the URL. |
void |
initialize(TransportChannelSettings settings,
EncoderContext ctx)
Initialize a secure channel with endpoint identified by the URL. |
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. |
ServiceResponse |
serviceRequest(ServiceRequest request)
Send a service request over the secure channel. |
ServiceResponse |
serviceRequest(ServiceRequest request,
long operationTimeout)
Send a service request over the secure channel. |
AsyncResult<ServiceResponse> |
serviceRequestAsync(ServiceRequest request)
Asynchronous operation to send a request over the secure channel. |
AsyncResult<ServiceResponse> |
serviceRequestAsync(ServiceRequest 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()
|
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
| Constructor Detail |
|---|
public SecureChannelTcp()
Constructor for SecureChannelTcp.
| Method Detail |
|---|
public void initialize(TransportChannelSettings settings,
EncoderContext ctx)
throws ServiceResultException
initialize in interface SecureChannelsettings - a TransportChannelSettings object.ctx - a EncoderContext object.
ServiceResultException - if any.
public 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(InetSocketAddress addr,
TransportChannelSettings settings,
EncoderContext ctx)
throws ServiceResultException
ServiceResultExceptionprotected long getRequestTimeout(ServiceRequest request)
getRequestTimeout.
request - a ServiceRequest object.
public ServiceResponse serviceRequest(ServiceRequest 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 ITransportChannelrequest - a ServiceRequest object.
ServiceResponse object.
ServiceResultException - if error
ServiceFaultException
public ServiceResponse serviceRequest(ServiceRequest 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 milliseconds
ServiceResponse object.
ServiceResultException - if any.
ServiceFaultExceptionpublic AsyncResult<ServiceResponse> serviceRequestAsync(ServiceRequest 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 ITransportChannelrequest - the request
public AsyncResult<ServiceResponse> serviceRequestAsync(ServiceRequest 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 time
public 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 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 SecureChannelprotected void setTransportChannel(IConnection transportChannel)
Setter for the field transportChannel.
transportChannel - the transportChannel to setpublic AsyncResult<SecureChannel> closeAsync()
closeAsync.
closeAsync in interface SecureChannelAsyncResult object.public void dispose()
dispose.
dispose in interface SecureChanneldispose in interface ITransportChannelpublic EndpointConfiguration getEndpointConfiguration()
getEndpointConfiguration.
getEndpointConfiguration in interface SecureChannelgetEndpointConfiguration in interface ITransportChannelEndpointConfiguration object.public EndpointDescription getEndpointDescription()
getEndpointDescription.
getEndpointDescription in interface SecureChannelgetEndpointDescription in interface ITransportChannelEndpointDescription object.public EncoderContext getMessageContext()
getMessageContext.
getMessageContext in interface SecureChannelgetMessageContext in interface ITransportChannelEncoderContext object.public void setOperationTimeout(int timeout)
setOperationTimeout in interface SecureChannelsetOperationTimeout in interface ITransportChanneltimeout - in millisecondspublic int getOperationTimeout()
getOperationTimeout.
getOperationTimeout in interface SecureChannelgetOperationTimeout in interface ITransportChannelpublic int getSecureChannelId()
getSecureChannelId in interface SecureChannel
public void onMessage(int requestId,
int secureChannelId,
IEncodeable message)
onMessage in interface IConnection.IMessageListenerpublic boolean isOpen()
isOpen in interface SecureChannelpublic void onClosed(ServiceResultException closeError)
onClosed in interface IConnectionListenercloseError - a ServiceResultException object.public void onOpen()
onOpen.
onOpen in interface IConnectionListenerpublic EnumSet<ITransportChannel.TransportChannelFeature> getSupportedFeatures()
getSupportedFeatures in interface ITransportChannelEnumSet object.public String getConnectURL()
getConnectURL in interface SecureChannelpublic ServerConnection getConnection()
getConnection in interface SecureChannelpublic MessageSecurityMode getMessageSecurityMode()
getMessageSecurityMode in interface SecureChannelpublic SecurityPolicy getSecurityPolicy()
getSecurityPolicy in interface SecureChannelpublic String toString()
toString in class Object
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||