C++ Based OPC UA Client/Server SDK
1.5.3.346
|
#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... | |
Session * | getSession (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... | |
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... | |
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 | 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. | |
ServerConfig * | m_pServerConfig |
Server configuration object. | |
NodeManagerRoot * | m_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. | |
Class definition of the SessionManager. Manages the Sessions and creates Secure Channels. It is not possible to create shallow copies of this Class.
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.
localeIDs | List of locale ids in priority order for localized strings. |
authenticationToken | Secret session Id created by the server application. |
uSecureChannelId | the SecureChannelId to be deleted. |
pUserIdentityToken | User 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. |
sClientNetworkAddress | The client network address used to communicate with the server through this session |
secureChannelSecurityConfig | The security configuration for the secure channel used to activate the session |
pEndpoint | UaEndpoint object used to activate the session |
UaStatus SessionManager::closeAllUaSessions | ( | ) |
Close all sessions created via the UA communication channel.
UaStatus SessionManager::closeSession | ( | const OpcUa_NodeId * | authenticationToken, |
OpcUa_Boolean | deleteSubscriptions | ||
) |
Close a session identified by session ID.
authenticationToken | Secret session Id created by the server application. |
deleteSubscriptions | Indicates if the subscriptions should be deleted by the server |
UaStatus SessionManager::createSession | ( | const UaString & | sessionName, |
const UaByteString & | clientCertificate, | ||
const UaString & | sClientApplicationUri, | ||
OpcUa_Double | requestedSessionTimeout, | ||
OpcUa_Double & | revisedSessionTimeout, | ||
Session ** | session | ||
) |
Create a session.
sessionName | the name of the Session to be build. |
clientCertificate | the certificate the Client sends to the Server. |
sClientApplicationUri | the application instance URI the Client sends to the Server. |
requestedSessionTimeout | Requested number of milliseconds that the session should remain open without activity. |
revisedSessionTimeout | Returned number of milliseconds that the session remains open without activity. |
session | Interface to the Session context for the method call |
Session * SessionManager::getSession | ( | const OpcUa_NodeId * | authenticationToken, |
OpcUa_Boolean | updateSession | ||
) |
Get a session by authenticationToken.
authenticationToken | Server unique node id that identifies the session. |
updateSession | Indicates if the timeout of the returned session should be updated. |
bool SessionManager::isSecureChannelValid | ( | OpcUa_UInt32 | uEndpointIndex, |
OpcUa_UInt32 | uSecureChannelId | ||
) |
Check if the secure channel is valid.
uEndpointIndex | the SDK index of the endpoint used to create the secure channel |
uSecureChannelId | the SecureChannelId of the channel where the transport connection was closed |
UaStatus SessionManager::purge | ( | ) |
Purge all sessions which are marked to delete.
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.
hEndpoint | the stack endpoint handle |
uEndpointIndex | the SDK index of the endpoint used to create the secure channel |
uSecureChannelId | the SecureChannelId of the new secure channel. |
sSecurityPolicy | the policy used for the secure channel. |
uSecurityMode | the message security mode used for the secure channel. |
void SessionManager::secureChannelDeleted | ( | OpcUa_UInt32 | uEndpointIndex, |
OpcUa_UInt32 | uSecureChannelId | ||
) |
Event to inform session manager about deletion of a secure channel.
uEndpointIndex | the index of the endpoint used to create the secure channel |
uSecureChannelId | the SecureChannelId to be deleted. |
void SessionManager::secureChannelRenewed | ( | OpcUa_UInt32 | uEndpointIndex, |
OpcUa_UInt32 | uSecureChannelId | ||
) |
Event to inform session manager about renew of a secure channel after transport connection loss.
uEndpointIndex | the index of the endpoint used to create the secure channel |
uSecureChannelId | the 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.
hEndpoint | the stack endpoint handle |
uEndpointIndex | the SDK index of the endpoint used to create the secure channel |
uSecureChannelId | the SecureChannelId of the channel where the transport connection was closed |
|
protectedvirtual |
Event for derived classes indicating that a session was activated.
pSession | Interface pointer of the activated Session. |
|
protectedvirtual |
Event for derived classes indicating that a session was closed.
pSession | Interface pointer of the closed Session. |
deleteSubscriptions | Flag indicating if subscriptions are also deleted. |
|
protectedvirtual |
Event for derived classes indicating that a new session was opened.
pSession | Interface pointer of the new Session. |
UaStatus SessionManager::shutDown | ( | ) |
Shut down session manager.
Shut down method for session manager.
OpcUa_UInt32 SessionManager::startServerShutDown | ( | ) |
Inform the session manager about the shutdown of the server.
UaStatus SessionManager::startUp | ( | ServerConfig * | pServerConfig, |
NodeManagerRoot * | pNodeManagerRoot | ||
) |
Initialize method for session manager.
pServerConfig | Server configuration object. |
pNodeManagerRoot | a pointer to the root NodeManager. |
|
protected |
Last used session ID.
Session ID must be unique in the server instance