org.opcfoundation.ua.transport.tcp.nio
Class OpcTcpServerConnection

java.lang.Object
  extended by org.opcfoundation.ua.utils.AbstractState<CloseableObjectState,ServiceResultException>
      extended by org.opcfoundation.ua.transport.tcp.nio.AbstractServerConnection
          extended by org.opcfoundation.ua.transport.tcp.nio.OpcTcpServerConnection
All Implemented Interfaces:
CloseableObject, ServerConnection, IStatefulObject<CloseableObjectState,ServiceResultException>

public class OpcTcpServerConnection
extends AbstractServerConnection

OpcTcpServerConnection class.

Author:
jaro

Nested Class Summary
 
Nested classes/interfaces inherited from interface org.opcfoundation.ua.transport.ServerConnection
ServerConnection.SecureChannelListener
 
Method Summary
 void addConnectionListener(IConnectionListener listener)
          Add response listener
protected  void cancelTimeoutTimer()
          cancelTimeoutTimer.
 CloseableObject close()
          close.
protected  void endChunkSend(ByteBuffer chunk)
          Flushes queued chunks (see startChunkSend())
protected  BufferMonitorState flush(long position)
          flush.
static long getHandshakeTimeout()
          Getter for the field handshakeTimeout.
 SocketAddress getLocalAddress()
          Get local socket address
 SocketAddress getRemoteAddress()
          Get remote socket address
protected  CertificateValidator getRemoteCertificateValidator()
          Remote Certificate Validator, invoked upon connect
protected  void handleAcknowledgeMessage(Acknowledge a)
          handleAcknowledgeMessage.
protected  void handleAsymmChunk(ByteBuffer chunk)
          handleAsymmChunk.
protected  void handleChunk(ByteBuffer chunk)
          handleChunk.
protected  void handleCloseChunk(ByteBuffer chunk)
          handleCloseChunk.
protected  void handleCloseSecureChannelRequest(InputMessage mb)
          handleCloseSecureChannelRequest.
protected  void handleErrorMessage(ErrorMessage e)
          handleErrorMessage.
protected  void handleHelloMessage(Hello h)
          handleHelloMessage.
protected  void handleOpenSecureChannelRequest(InputMessage mb)
          handleOpenSecureChannelRequest.
protected  void handleRawChunk(ByteBuffer chunk)
          handleRawChunk.
protected  void handleSecureMessage(InputMessage mb)
          handleSecureMessage.
protected  void handleSymmChunk(ByteBuffer chunk)
          handleSymmChunk.
protected  void onStateTransition(CloseableObjectState oldState, CloseableObjectState newState)
          Override this.
 void removeConnectionListener(IConnectionListener listener)
          Add response listener
protected  void sendAcknowledge(Acknowledge a)
          sendAcknowledge.
protected  int sendAsymmSecureMessage(AsyncWrite msg, SecurityConfiguration securityConfiguration, int secureChannelId, int requestNumber, AtomicInteger sendSequenceNumber)
          sendAsymmSecureMessage.
protected  void sendChunks(ByteBuffer... chunks)
          Send chunks.
protected  void sendError(ErrorMessage e)
          sendError.
protected  void sendHello(Hello h)
          sendHello.
protected  void sendSecureMessage(AsyncWrite msg, SecurityToken token, int requestId, int messageType, AtomicInteger sendSequenceNumber)
          sendSecureMessage.
protected  void setError(ServiceResultException e)
          setError.
static void setHandshakeTimeout(long handshakeTimeout)
          Define the handshake timeout for new connections.
protected  void startChunkSend(ByteBuffer... chunks)
          Put chunks into send queue.
 
Methods inherited from class org.opcfoundation.ua.transport.tcp.nio.AbstractServerConnection
addChannelListener, addSecureChannelListener, fireSecureChannelAttached, fireSecureChannelDetached, getConnectURL, getRemoteCertificate, getSecureChannels, onListenerException, removeChannelListener, removeSecureChannelListener, setError, setError, toString
 
Methods inherited from class org.opcfoundation.ua.utils.AbstractState
addStateListener, addStateNotifiable, assertNoError, attemptSetState, clearError, getError, getState, hasError, isStateTransitionAllowed, removeStateListener, removeStateNotifiable, setState, setState, waitForState, waitForState, waitForStateUninterruptibly
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface org.opcfoundation.ua.utils.IStatefulObject
addStateListener, addStateNotifiable, getError, getState, removeStateListener, removeStateNotifiable, waitForState, waitForState, waitForStateUninterruptibly
 

Method Detail

getHandshakeTimeout

public static long getHandshakeTimeout()

Getter for the field handshakeTimeout.

Returns:
the handshakeTimeout

setHandshakeTimeout

public static void setHandshakeTimeout(long handshakeTimeout)
Define the handshake timeout for new connections. If the client does not establish a connection during the timeout, the socket is released. A smaller value might be usable to avoid DNS attacks.

Parameters:
handshakeTimeout - the handshakeTimeout to set. Default 600000 = 10 minutes.

addConnectionListener

public void addConnectionListener(IConnectionListener listener)
Add response listener

Specified by:
addConnectionListener in interface ServerConnection
Overrides:
addConnectionListener in class AbstractServerConnection
Parameters:
listener - a IConnectionListener object.

close

public CloseableObject close()

close.

Specified by:
close in interface CloseableObject
Overrides:
close in class AbstractServerConnection
Returns:
a CloseableObject object.

getLocalAddress

public SocketAddress getLocalAddress()
Get local socket address

Returns:
socket address

getRemoteAddress

public SocketAddress getRemoteAddress()
Get remote socket address

Returns:
remote socket address

removeConnectionListener

public void removeConnectionListener(IConnectionListener listener)
Add response listener

Specified by:
removeConnectionListener in interface ServerConnection
Overrides:
removeConnectionListener in class AbstractServerConnection
Parameters:
listener - a IConnectionListener object.

cancelTimeoutTimer

protected void cancelTimeoutTimer()

cancelTimeoutTimer.


endChunkSend

protected void endChunkSend(ByteBuffer chunk)
Flushes queued chunks (see startChunkSend())

Parameters:
chunk - chunk to send

flush

protected BufferMonitorState flush(long position)
                            throws InterruptedException,
                                   IOException

flush.

Parameters:
position - a long.
Returns:
a BufferMonitorState object.
Throws:
InterruptedException - if any.
IOException - if any.

getRemoteCertificateValidator

protected CertificateValidator getRemoteCertificateValidator()
Remote Certificate Validator, invoked upon connect

Specified by:
getRemoteCertificateValidator in class AbstractServerConnection
Returns:
a CertificateValidator object.

handleAcknowledgeMessage

protected void handleAcknowledgeMessage(Acknowledge a)
                                 throws ServiceResultException

handleAcknowledgeMessage.

Parameters:
a - a Acknowledge object.
Throws:
ServiceResultException - if any.

handleAsymmChunk

protected void handleAsymmChunk(ByteBuffer chunk)
                         throws ServiceResultException

handleAsymmChunk.

Parameters:
chunk - a ByteBuffer object.
Throws:
ServiceResultException - if any.

handleChunk

protected void handleChunk(ByteBuffer chunk)
                    throws ServiceResultException

handleChunk.

Parameters:
chunk - a ByteBuffer object.
Throws:
ServiceResultException - if any.

handleCloseChunk

protected void handleCloseChunk(ByteBuffer chunk)
                         throws ServiceResultException

handleCloseChunk.

Parameters:
chunk - a ByteBuffer object.
Throws:
ServiceResultException - if any.

handleCloseSecureChannelRequest

protected void handleCloseSecureChannelRequest(InputMessage mb)
                                        throws ServiceResultException

handleCloseSecureChannelRequest.

Parameters:
mb - a InputMessage object.
Throws:
ServiceResultException - if any.

handleErrorMessage

protected void handleErrorMessage(ErrorMessage e)

handleErrorMessage.

Parameters:
e - a ErrorMessage object.

handleHelloMessage

protected void handleHelloMessage(Hello h)
                           throws ServiceResultException

handleHelloMessage.

Parameters:
h - a Hello object.
Throws:
ServiceResultException - if any.

handleOpenSecureChannelRequest

protected void handleOpenSecureChannelRequest(InputMessage mb)
                                       throws ServiceResultException

handleOpenSecureChannelRequest.

Parameters:
mb - a InputMessage object.
Throws:
ServiceResultException - if any.

handleRawChunk

protected void handleRawChunk(ByteBuffer chunk)

handleRawChunk.

Parameters:
chunk - a ByteBuffer object.

handleSecureMessage

protected void handleSecureMessage(InputMessage mb)
                            throws ServiceResultException

handleSecureMessage.

Parameters:
mb - a InputMessage object.
Throws:
ServiceResultException - if any.

handleSymmChunk

protected void handleSymmChunk(ByteBuffer chunk)
                        throws ServiceResultException

handleSymmChunk.

Parameters:
chunk - a ByteBuffer object.
Throws:
ServiceResultException - if any.

onStateTransition

protected void onStateTransition(CloseableObjectState oldState,
                                 CloseableObjectState newState)
Override this.

Overrides:
onStateTransition in class AbstractServerConnection
Parameters:
oldState - a StateType object.
newState - a StateType object.

sendAcknowledge

protected void sendAcknowledge(Acknowledge a)
                        throws ServiceResultException

sendAcknowledge.

Parameters:
a - a Acknowledge object.
Throws:
ServiceResultException - if any.

sendAsymmSecureMessage

protected int sendAsymmSecureMessage(AsyncWrite msg,
                                     SecurityConfiguration securityConfiguration,
                                     int secureChannelId,
                                     int requestNumber,
                                     AtomicInteger sendSequenceNumber)
                              throws ServiceResultException

sendAsymmSecureMessage.

Send asymmetric secure message.

Specified by:
sendAsymmSecureMessage in class AbstractServerConnection
Parameters:
msg - a AsyncWrite object.
securityConfiguration - a SecurityConfiguration object.
secureChannelId - a int.
requestNumber - a int.
sendSequenceNumber - a AtomicInteger object.
Returns:
a int.
Throws:
ServiceResultException - if any.

sendChunks

protected void sendChunks(ByteBuffer... chunks)
Send chunks.

Parameters:
chunks - a ByteBuffer object.

sendError

protected void sendError(ErrorMessage e)
                  throws ServiceResultException

sendError.

Parameters:
e - a ErrorMessage object.
Throws:
ServiceResultException - if any.

sendHello

protected void sendHello(Hello h)

sendHello.

Parameters:
h - a Hello object.

sendSecureMessage

protected void sendSecureMessage(AsyncWrite msg,
                                 SecurityToken token,
                                 int requestId,
                                 int messageType,
                                 AtomicInteger sendSequenceNumber)

sendSecureMessage.

Send symmetric secure message

Specified by:
sendSecureMessage in class AbstractServerConnection
Parameters:
msg - a AsyncWrite object.
token - a SecurityToken object.
requestId - a int.
messageType - a int.
sendSequenceNumber - a AtomicInteger object.

setError

protected void setError(ServiceResultException e)

setError.

Overrides:
setError in class AbstractServerConnection
Parameters:
e - a ServiceResultException object.

startChunkSend

protected void startChunkSend(ByteBuffer... chunks)
Put chunks into send queue. Chunks will be given a sequence number but will be flushed in endChunkSend().

Parameters:
chunks - a ByteBuffer object.


Copyright © 2018. All rights reserved.