C++ Based OPC UA Client/Server/PubSub SDK  1.7.6.537
SessionManager Class Reference

SessionManager. More...

#include <sessionmanager.h>

Public Member Functions

 SessionManager ()
 construction
 
virtual ~SessionManager ()
 destruction
 
UaStatus startUp (ServerConfig *pServerConfig, NodeManagerRoot *pNodeManagerRoot)
 Initialize method for session manager. More...
 
UaStatus shutDown ()
 Shut down session manager. More...
 
UaStatus closeAllUaSessions (OpcUa_Boolean calledFromShutdown=OpcUa_False)
 Close all sessions created via the UA communication channel. More...
 
UaStatus createSession (const UaString &sessionName, const UaByteString &clientCertificate, const UaString &sClientApplicationUri, OpcUa_UInt32 uSecureChannelId, OpcUa_Double requestedSessionTimeout, OpcUa_Double &revisedSessionTimeout, Session **session)
 Create a session. More...
 
UaStatus activateSession (const OpcUa_NodeId *authenticationToken, OpcUa_UInt32 uSecureChannelId, const UaStringArray &localeIDs, UaUserIdentityToken *pUserIdentityToken, const UaString &sClientNetworkAddress, const OpcUa_Endpoint_SecurityPolicyConfiguration &secureChannelSecurityConfig, UaEndpoint *pEndpoint)
 Activate a session. More...
 
SessiongetSession (const OpcUa_NodeId *authenticationToken, OpcUa_Boolean updateSession)
 Get a session by authenticationToken. More...
 
UaStatus closeSession (const OpcUa_NodeId *authenticationToken, OpcUa_Boolean deleteSubscriptions)
 Close a session identified by session ID. More...
 
void secureChannelPending (OpcUa_Endpoint hEndpoint, OpcUa_UInt32 uEndpointIndex, OpcUa_UInt32 uSecureChannelId)
 Event to inform server about the creation of a secure channel for reverse connect. More...
 
void secureChannelCreated (OpcUa_Endpoint hEndpoint, OpcUa_UInt32 uEndpointIndex, OpcUa_UInt32 uSecureChannelId, const UaString &sSecurityPolicy, OpcUa_UInt16 uSecurityMode)
 Event to inform session manager about creation of a secure channel. More...
 
void secureChannelDeleted (OpcUa_UInt32 uEndpointIndex, OpcUa_UInt32 uSecureChannelId, bool &skipAuditEvent)
 Event to inform session manager about deletion of a secure channel. More...
 
bool secureChannelTransportClosed (OpcUa_Endpoint hEndpoint, OpcUa_UInt32 uEndpointIndex, OpcUa_UInt32 uSecureChannelId)
 Event to inform server that the transport connection for the secure channel was closed. More...
 
void secureChannelRenewed (OpcUa_UInt32 uEndpointIndex, OpcUa_UInt32 uSecureChannelId)
 Event to inform session manager about renew of a secure channel after transport connection loss. More...
 
bool isSecureChannelValid (OpcUa_UInt32 uEndpointIndex, OpcUa_UInt32 uSecureChannelId)
 Check if the secure channel is valid. More...
 
bool isReverseSecureChannel (OpcUa_UInt32 uEndpointIndex, OpcUa_UInt32 uSecureChannelId)
 Check if the secure channel was created with a reverse connect. More...
 
UaMutexRefCountedgetSecureChannelMutex (OpcUa_UInt32 uEndpointIndex, OpcUa_UInt32 uSecureChannelId)
 Get the mutex for the secure channel. More...
 
OpcUa_UInt32 startServerShutDown ()
 Inform the session manager about the shutdown of the server. More...
 
UaStatus purge ()
 Purge all sessions which are marked to delete. More...
 
void addReverseConnection (OpcUa_UInt32 endpointIndex, const UaString &sReverseConnectUrl)
 Add reverse connection.
 
void getPendingReverseConnections (std::list< ReverseConnection * > &listInactiveConnections)
 Returns the list of reverse connections that require a connect try.
 
OpcUa_UInt32 pendingReverseConnectionCount ()
 Returns the number of reverse connections that require a connect try.
 
void setProcessedConnection (ReverseConnection *pProcessedConnection)
 Set the currently processed reverse connection establishment.
 
void setProcessedConnectionError (ReverseConnection *pProcessedConnection)
 Set the currently processed reverse connection with error.
 
void lockSessionManager ()
 Lock access to SessionManager.
 
void unlockSessionManager ()
 Unlock access to SessionManager.
 

Static Public Member Functions

static UaDateTime getLastSystemTimeChange ()
 Returns the time when a system time change was detected.
 

Protected Member Functions

virtual void sessionOpened (Session *pSession)
 Event for derived classes indicating that a new session was opened. More...
 
virtual void sessionActivated (Session *pSession)
 Event for derived classes indicating that a session was activated. More...
 
virtual void sessionClosed (Session *pSession, OpcUa_Boolean deleteSubscriptions)
 Event for derived classes indicating that a session was closed. More...
 
virtual OpcUa_Int32 getNewSessionId ()
 Returns a new unique session id The method can be overwritten by a derived class.
 

Protected Attributes

UaMutex m_mutex
 Mutex to control access to the SessionManager object.
 
std::map< OpcUa_Int32, Session * > m_mapSessions
 Map of session objects based on session Id.
 
std::map< OpcUa_UInt64,
SecureChannelStatus * > 
m_mapSecureChannels
 Map of session objects based on secure channel Id.
 
OpcUa_Int32 m_lastSessionID
 Last used session ID. More...
 
OpcUa_Boolean m_isStarted
 Flag that indicates the status of the manager.
 
ServerConfigm_pServerConfig
 Server configuration object.
 
NodeManagerRootm_pNodeManagerRoot
 Root node manager.
 
OpcUa_UInt16 m_SessionIdNamespaceIndex
 Namespace index used for the session node ids.
 
OpcUa_Boolean m_isShutdownStarted
 Flag that indicates that the shutdown of the server was started.
 

Static Protected Attributes

static OpcUa_DateTime s_lastPurge
 Time of the last purge call.
 
static OpcUa_DateTime s_timeOfLastSystemTimeChangeDetected
 The time when a system time change was detected.
 

Detailed Description

SessionManager.

Class definition of the SessionManager. Manages the Sessions and creates Secure Channels. It is not possible to create shallow copies of this Class.

Member Function Documentation

UaStatus SessionManager::activateSession ( const OpcUa_NodeId authenticationToken,
OpcUa_UInt32  uSecureChannelId,
const UaStringArray localeIDs,
UaUserIdentityToken pUserIdentityToken,
const UaString sClientNetworkAddress,
const OpcUa_Endpoint_SecurityPolicyConfiguration &  secureChannelSecurityConfig,
UaEndpoint pEndpoint 
)

Activate a session.

Parameters
localeIDsList of locale ids in priority order for localized strings.
authenticationTokenSecret session Id created by the server application.
uSecureChannelIdthe SecureChannelId to be deleted.
pUserIdentityTokenUser identity token contained in an ExtensionObject used to handle different types of user identity tokens like user/password or an X509 certificate. It provides the credentials of the user associated with the Client application. The implementation of this method must use these credentials to determine whether the Client should be allowed to activate a Session and what resources the Client has access to during this Session. If the method is not able to validate the user or if the user has no right to access the server, the method must return the status code OpcUa_BadUserAccessDenied.
sClientNetworkAddressThe client network address used to communicate with the server through this session
secureChannelSecurityConfigThe security configuration for the secure channel used to activate the session
pEndpointUaEndpoint object used to activate the session
Returns
Error code
UaStatus SessionManager::closeAllUaSessions ( OpcUa_Boolean  calledFromShutdown = OpcUa_False)

Close all sessions created via the UA communication channel.

Parameters
calledFromShutdownIndicates if the close is called from server shutdown
Returns
Error code
UaStatus SessionManager::closeSession ( const OpcUa_NodeId authenticationToken,
OpcUa_Boolean  deleteSubscriptions 
)

Close a session identified by session ID.

Parameters
authenticationTokenSecret session Id created by the server application.
deleteSubscriptionsIndicates if the subscriptions should be deleted by the server
Returns
Error code.
UaStatus SessionManager::createSession ( const UaString sessionName,
const UaByteString clientCertificate,
const UaString sClientApplicationUri,
OpcUa_UInt32  uSecureChannelId,
OpcUa_Double  requestedSessionTimeout,
OpcUa_Double &  revisedSessionTimeout,
Session **  session 
)

Create a session.

Parameters
sessionNamethe name of the Session to be build.
clientCertificatethe certificate the Client sends to the Server.
sClientApplicationUrithe application instance URI the Client sends to the Server.
requestedSessionTimeoutRequested number of milliseconds that the session should remain open without activity.
revisedSessionTimeoutReturned number of milliseconds that the session remains open without activity.
sessionInterface to the Session context for the method call
Returns
Error code
UaMutexRefCounted * SessionManager::getSecureChannelMutex ( OpcUa_UInt32  uEndpointIndex,
OpcUa_UInt32  uSecureChannelId 
)

Get the mutex for the secure channel.

Parameters
uEndpointIndexthe SDK index of the endpoint used to create the secure channel
uSecureChannelIdthe SecureChannelId of the channel where the transport connection was closed
Returns
Mutex of the secure channel or NULL if the secure channel cannot be found
Session * SessionManager::getSession ( const OpcUa_NodeId authenticationToken,
OpcUa_Boolean  updateSession 
)

Get a session by authenticationToken.

Parameters
authenticationTokenServer unique node id that identifies the session.
updateSessionIndicates if the timeout of the returned session should be updated.
Returns
Corresponding session for passed session ID
bool SessionManager::isReverseSecureChannel ( OpcUa_UInt32  uEndpointIndex,
OpcUa_UInt32  uSecureChannelId 
)

Check if the secure channel was created with a reverse connect.

Parameters
uEndpointIndexthe SDK index of the endpoint used to create the secure channel
uSecureChannelIdthe SecureChannelId of the channel
Returns
flag indicating if the secure channel was created with a reverse connect
bool SessionManager::isSecureChannelValid ( OpcUa_UInt32  uEndpointIndex,
OpcUa_UInt32  uSecureChannelId 
)

Check if the secure channel is valid.

Parameters
uEndpointIndexthe SDK index of the endpoint used to create the secure channel
uSecureChannelIdthe SecureChannelId of the channel
Returns
flag indicating if the secure channel is valid
UaStatus SessionManager::purge ( )

Purge all sessions which are marked to delete.

Returns
Error code
void SessionManager::secureChannelCreated ( OpcUa_Endpoint  hEndpoint,
OpcUa_UInt32  uEndpointIndex,
OpcUa_UInt32  uSecureChannelId,
const UaString sSecurityPolicy,
OpcUa_UInt16  uSecurityMode 
)

Event to inform session manager about creation of a secure channel.

Parameters
hEndpointthe stack endpoint handle
uEndpointIndexthe SDK index of the endpoint used to create the secure channel
uSecureChannelIdthe SecureChannelId of the new secure channel.
sSecurityPolicythe policy used for the secure channel.
uSecurityModethe message security mode used for the secure channel.
void SessionManager::secureChannelDeleted ( OpcUa_UInt32  uEndpointIndex,
OpcUa_UInt32  uSecureChannelId,
bool &  skipAuditEvent 
)

Event to inform session manager about deletion of a secure channel.

Parameters
uEndpointIndexthe index of the endpoint used to create the secure channel
uSecureChannelIdthe SecureChannelId to be deleted.
skipAuditEventFlag indicating that this is was not a valid channel.
void SessionManager::secureChannelPending ( OpcUa_Endpoint  hEndpoint,
OpcUa_UInt32  uEndpointIndex,
OpcUa_UInt32  uSecureChannelId 
)

Event to inform server about the creation of a secure channel for reverse connect.

Parameters
hEndpointthe stack endpoint handle
uEndpointIndexthe index of the endpoint used to initiate the invers connect.
uSecureChannelIdthe SecureChannelId of the pending SecureChannel.
void SessionManager::secureChannelRenewed ( OpcUa_UInt32  uEndpointIndex,
OpcUa_UInt32  uSecureChannelId 
)

Event to inform session manager about renew of a secure channel after transport connection loss.

Parameters
uEndpointIndexthe index of the endpoint used to create the secure channel
uSecureChannelIdthe SecureChannelId renewed.
bool SessionManager::secureChannelTransportClosed ( OpcUa_Endpoint  hEndpoint,
OpcUa_UInt32  uEndpointIndex,
OpcUa_UInt32  uSecureChannelId 
)

Event to inform server that the transport connection for the secure channel was closed.

Parameters
hEndpointthe stack endpoint handle
uEndpointIndexthe SDK index of the endpoint used to create the secure channel
uSecureChannelIdthe SecureChannelId of the channel where the transport connection was closed
Returns
flag indicating if the secure channel was closed
void SessionManager::sessionActivated ( Session pSession)
protectedvirtual

Event for derived classes indicating that a session was activated.

Parameters
pSessionInterface pointer of the activated Session.
void SessionManager::sessionClosed ( Session pSession,
OpcUa_Boolean  deleteSubscriptions 
)
protectedvirtual

Event for derived classes indicating that a session was closed.

Parameters
pSessionInterface pointer of the closed Session.
deleteSubscriptionsFlag indicating if subscriptions are also deleted.
void SessionManager::sessionOpened ( Session pSession)
protectedvirtual

Event for derived classes indicating that a new session was opened.

Parameters
pSessionInterface pointer of the new Session.
UaStatus SessionManager::shutDown ( )

Shut down session manager.

Shut down method for session manager.

Returns
Error code
OpcUa_UInt32 SessionManager::startServerShutDown ( )

Inform the session manager about the shutdown of the server.

Returns
Number of active client connections.
UaStatus SessionManager::startUp ( ServerConfig pServerConfig,
NodeManagerRoot pNodeManagerRoot 
)

Initialize method for session manager.

Parameters
pServerConfigServer configuration object.
pNodeManagerRoota pointer to the root NodeManager.
Returns
Error code

Member Data Documentation

OpcUa_Int32 SessionManager::m_lastSessionID
protected

Last used session ID.

Session ID must be unique in the server instance


The documentation for this class was generated from the following files: