UA Server SDK C++ Bundle  1.4.1.271
 All Classes Namespaces Functions Variables Typedefs Enumerations Enumerator Friends Groups Pages
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 ()
 Close all sessions created via the UA communication channel. More...
 
UaStatus createSession (const UaString &sessionName, const UaByteString &clientCertificate, const UaString &sClientApplicationUri, 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 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)
 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...
 
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...
 

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 plane 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 ( )

Close all sessions created via the UA communication channel.

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_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
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
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 to be deleted.
sSecurityPolicythe policies needed for the secure channel.
uSecurityModethe security mode, if the event type refers to a secure channel.
void SessionManager::secureChannelDeleted ( OpcUa_UInt32  uEndpointIndex,
OpcUa_UInt32  uSecureChannelId 
)

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.
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: