com.prosysopc.ua.server
Class SessionManager

java.lang.Object
  extended by com.prosysopc.ua.server.SessionManager

public class SessionManager
extends Object

The SessionManager manages the client sessions that are currently open in the client. It implements the OPC UA Session service set.


Field Summary
protected  List<SessionManagerListener> listeners
           
protected  Map<org.opcfoundation.ua.builtintypes.NodeId,Session> newSessions
           
 
Constructor Summary
SessionManager(UaServer server)
           
 
Method Summary
protected  Session activateSession(org.opcfoundation.ua.transport.ServerSecureChannel serverSecureChannel, org.opcfoundation.ua.builtintypes.NodeId authenticationToken, org.opcfoundation.ua.core.UserIdentityToken userToken, org.opcfoundation.ua.core.SignatureData clientSignature, org.opcfoundation.ua.core.SignedSoftwareCertificate[] signedSoftwareCertificates, org.opcfoundation.ua.core.SignatureData userTokenSignature, String[] localeIds)
           
protected  void activateSessionError(Session session, org.opcfoundation.ua.core.UserIdentityToken userToken, Exception e)
           
 void addListener(SessionManagerListener listener)
          Add a new SessionManagerListener.
protected  void cancelSession(org.opcfoundation.ua.builtintypes.NodeId authenticationToken)
           
protected  void close()
          Close the session manager.
protected  void closeSession(org.opcfoundation.ua.builtintypes.NodeId authenticationToken, boolean deleteSubscriptions)
           
protected  Session createSession(org.opcfoundation.ua.transport.ServerSecureChannel serverSecureChannel, byte[] clientCertificate, org.opcfoundation.ua.core.ApplicationDescription clientDescription, org.opcfoundation.ua.builtintypes.UnsignedInteger maxResponseMessageSize, Double requestedSessionTimeout, String sessionName)
           
 org.opcfoundation.ua.core.EndpointDescription[] getEndpoints()
           
 int getMaxBrowseContinuationPoints()
          The maximum number of continuation points supported by the server for browse requests.
 int getMaxHistoryContinuationPoints()
          The maximum number of continuation points supported by the server for history read requests.
 int getMaxQueryContinuationPoints()
          The maximum number of continuation points supported by the server for query requests.
 org.opcfoundation.ua.builtintypes.UnsignedInteger getMaxRequestMessageSize()
          The value is used to inform the clients that they should not send larger messages than this to the server.
 int getMaxSessionCount()
           
 double getMaxSessionTimeout()
           
 double getMinSessionTimeout()
           
 UaServer getServer()
           
 Session getSession(org.opcfoundation.ua.builtintypes.NodeId authenticationToken)
          Get a client session.
 int getSessionCount()
           
 Collection<Session> getSessions()
           
 boolean hasListener(SessionManagerListener listener)
          Check if the manager already has the specified listener.
 boolean isRunning()
           
protected  Session provideSession(String sessionName, ApplicationIdentity clientIdentity)
          Creates a Session instance for given parameters.
 void removeListener(SessionManagerListener listener)
          Remove a SessionManagerListener.
 void setMaxBrowseContinuationPoints(int maxBrowseContinuationPoints)
          The maximum number of continuation points supported by the server for browse requests.
 void setMaxBrowseContinuationPoints(org.opcfoundation.ua.builtintypes.UnsignedShort maxBrowseContinuationPoints)
          The maximum number of continuation points supported by the server for browse requests.
 void setMaxHistoryContinuationPoints(int maxHistoryContinuationPoints)
          The maximum number of continuation points supported by the server for history read requests.
 void setMaxHistoryContinuationPoints(org.opcfoundation.ua.builtintypes.UnsignedShort maxHistoryContinuationPoints)
          The maximum number of continuation points supported by the server for history read requests.
 void setMaxQueryContinuationPoints(int maxQueryContinuationPoints)
          The maximum number of continuation points supported by the server for query requests.
 void setMaxQueryContinuationPoints(org.opcfoundation.ua.builtintypes.UnsignedShort maxQueryContinuationPoints)
          The maximum number of continuation points supported by the server for query requests.
 void setMaxRequestMessageSize(int maxRequestMessageSize)
          The value is used to inform the clients that they should not send larger messages than this to the server.
 void setMaxRequestMessageSize(org.opcfoundation.ua.builtintypes.UnsignedInteger maxRequestMessageSize)
          The value is used to inform the clients that they should not send larger messages than this to the server.
 void setMaxSessionCount(int maxSessionCount)
           
 void setMaxSessionTimeout(double maxSessionTimeout)
          The maximum session timeout enabled for the clients.
 void setMinSessionTimeout(double minSessionTimeout)
          The minimum session timeout enabled for the clients.
protected  void start()
          Start the session manager.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

listeners

protected List<SessionManagerListener> listeners

newSessions

protected final Map<org.opcfoundation.ua.builtintypes.NodeId,Session> newSessions
Constructor Detail

SessionManager

public SessionManager(UaServer server)
Method Detail

addListener

public void addListener(SessionManagerListener listener)
Add a new SessionManagerListener.

Parameters:
listener -

getEndpoints

public org.opcfoundation.ua.core.EndpointDescription[] getEndpoints()
Returns:
the endpoints

getMaxBrowseContinuationPoints

public int getMaxBrowseContinuationPoints()
The maximum number of continuation points supported by the server for browse requests.

Returns:
the maxBrowseContinuationPoints

getMaxHistoryContinuationPoints

public int getMaxHistoryContinuationPoints()
The maximum number of continuation points supported by the server for history read requests.

Returns:
the maxHistoryContinuationPoints

getMaxQueryContinuationPoints

public int getMaxQueryContinuationPoints()
The maximum number of continuation points supported by the server for query requests.

Returns:
the maxQueryContinuationPoints

getMaxRequestMessageSize

public org.opcfoundation.ua.builtintypes.UnsignedInteger getMaxRequestMessageSize()
The value is used to inform the clients that they should not send larger messages than this to the server.

Returns:
the maximum request message size in bytes. Default is null

getMaxSessionCount

public int getMaxSessionCount()
Returns:
the maxSessionCount

getMaxSessionTimeout

public double getMaxSessionTimeout()
Returns:
the maxSessionTimeout

getMinSessionTimeout

public double getMinSessionTimeout()
Returns:
the minSessionTimeout

getServer

public UaServer getServer()
Returns:
the server

getSession

public Session getSession(org.opcfoundation.ua.builtintypes.NodeId authenticationToken)
                   throws ServiceException
Get a client session. You need the authenticationToken to access the session.

Parameters:
authenticationToken - the token used to identify a client session
Returns:
the respective session.
Throws:
ServiceException - if the session is not found, with ServiceResult=Bad_SessionClosed
See Also:
getSessionCount()

getSessionCount

public int getSessionCount()

getSessions

public Collection<Session> getSessions()
Returns:

hasListener

public boolean hasListener(SessionManagerListener listener)
Check if the manager already has the specified listener.

Parameters:
listener - the listener to check
Returns:
true if the listener is already defined for the manager

isRunning

public boolean isRunning()
Returns:
the running

removeListener

public void removeListener(SessionManagerListener listener)
Remove a SessionManagerListener.

Parameters:
listener -

setMaxBrowseContinuationPoints

public void setMaxBrowseContinuationPoints(int maxBrowseContinuationPoints)
The maximum number of continuation points supported by the server for browse requests.

Default: 0 (=unlimited)

Parameters:
maxBrowseContinuationPoints - the maxBrowseContinuationPoints to set, the value must be in the range of UnsignedShort

setMaxBrowseContinuationPoints

public void setMaxBrowseContinuationPoints(org.opcfoundation.ua.builtintypes.UnsignedShort maxBrowseContinuationPoints)
The maximum number of continuation points supported by the server for browse requests.

Default: 0 (=unlimited)

Parameters:
maxBrowseContinuationPoints - the maxBrowseContinuationPoints to set

setMaxHistoryContinuationPoints

public void setMaxHistoryContinuationPoints(int maxHistoryContinuationPoints)
The maximum number of continuation points supported by the server for history read requests.

Default: 0 (=unlimited)

Parameters:
maxHistoryContinuationPoints - the maxHistoryContinuationPoints to set, the value must be in the range of UnsignedShort

setMaxHistoryContinuationPoints

public void setMaxHistoryContinuationPoints(org.opcfoundation.ua.builtintypes.UnsignedShort maxHistoryContinuationPoints)
The maximum number of continuation points supported by the server for history read requests.

Default: 0 (=unlimited)

Parameters:
maxHistoryContinuationPoints - the maxHistoryContinuationPoints to set

setMaxQueryContinuationPoints

public void setMaxQueryContinuationPoints(int maxQueryContinuationPoints)
The maximum number of continuation points supported by the server for query requests.

Default: 0 (=unlimited)

Parameters:
maxQueryContinuationPoints - the maxQueryContinuationPoints to set, the value must be in the range of UnsignedShort

setMaxQueryContinuationPoints

public void setMaxQueryContinuationPoints(org.opcfoundation.ua.builtintypes.UnsignedShort maxQueryContinuationPoints)
The maximum number of continuation points supported by the server for query requests.

Default: 0 (=unlimited)

Parameters:
maxQueryContinuationPoints - the maxQueryContinuationPoints to set

setMaxRequestMessageSize

public void setMaxRequestMessageSize(int maxRequestMessageSize)
The value is used to inform the clients that they should not send larger messages than this to the server.

Parameters:
maxRequestMessageSize - the maximum request message size to set in bytes. Default is null, which means that the value is not used. May not be a negative value.

setMaxRequestMessageSize

public void setMaxRequestMessageSize(org.opcfoundation.ua.builtintypes.UnsignedInteger maxRequestMessageSize)
The value is used to inform the clients that they should not send larger messages than this to the server.

Parameters:
maxRequestMessageSize - the maximum request message size to set in bytes. Default is null, which means that the value is not used.

setMaxSessionCount

public void setMaxSessionCount(int maxSessionCount)
Parameters:
maxSessionCount - the maxSessionCount to set

setMaxSessionTimeout

public void setMaxSessionTimeout(double maxSessionTimeout)
The maximum session timeout enabled for the clients.

Default: 3600000 (ms)

Parameters:
maxSessionTimeout - the maxSessionTimeout to set in milliseconds

setMinSessionTimeout

public void setMinSessionTimeout(double minSessionTimeout)
The minimum session timeout enabled for the clients.

Default: 100 (ms)

Parameters:
minSessionTimeout - the minSessionTimeout to set in milliseconds

activateSession

protected Session activateSession(org.opcfoundation.ua.transport.ServerSecureChannel serverSecureChannel,
                                  org.opcfoundation.ua.builtintypes.NodeId authenticationToken,
                                  org.opcfoundation.ua.core.UserIdentityToken userToken,
                                  org.opcfoundation.ua.core.SignatureData clientSignature,
                                  org.opcfoundation.ua.core.SignedSoftwareCertificate[] signedSoftwareCertificates,
                                  org.opcfoundation.ua.core.SignatureData userTokenSignature,
                                  String[] localeIds)
                           throws ServiceException
Throws:
ServiceException

activateSessionError

protected void activateSessionError(Session session,
                                    org.opcfoundation.ua.core.UserIdentityToken userToken,
                                    Exception e)
Parameters:
session -
userToken -
e -
Throws:
ServiceException

cancelSession

protected void cancelSession(org.opcfoundation.ua.builtintypes.NodeId authenticationToken)
                      throws ServiceException
Throws:
ServiceException

close

protected void close()
Close the session manager. All sessions are removed and no more connections are accepted.


closeSession

protected void closeSession(org.opcfoundation.ua.builtintypes.NodeId authenticationToken,
                            boolean deleteSubscriptions)
                     throws ServiceException
Parameters:
authenticationToken -
Throws:
ServiceException

createSession

protected Session createSession(org.opcfoundation.ua.transport.ServerSecureChannel serverSecureChannel,
                                byte[] clientCertificate,
                                org.opcfoundation.ua.core.ApplicationDescription clientDescription,
                                org.opcfoundation.ua.builtintypes.UnsignedInteger maxResponseMessageSize,
                                Double requestedSessionTimeout,
                                String sessionName)
                         throws ServiceException
Throws:
ServiceException

provideSession

protected Session provideSession(String sessionName,
                                 ApplicationIdentity clientIdentity)
Creates a Session instance for given parameters. Override this if you want to use a subclass of Session, but don't want to override the complete createSession method.

Parameters:
sessionName - name for the Session
clientIdentity - client identity for the Session
Returns:
the new Session object for given parameters

start

protected void start()
              throws StatusException
Start the session manager. All sessions are removed and no more connections are accepted.

Throws:
StatusException


Copyright © 2018. All rights reserved.