UA Server SDK C++ Bundle  1.4.1.271
 All Classes Namespaces Functions Variables Typedefs Enumerations Enumerator Friends Groups Pages
Session Class Reference

Class used to manage a client session in the server. More...

#include <session.h>

Inherits ReferenceCounter.

Inherited by UaSession.

Public Member Functions

 Session (OpcUa_Int32 sessionId, const UaNodeId &authenticationToken)
 construction More...
 
virtual UaStatus open (const UaString &sessionName, const UaByteString clientCertificate, OpcUa_UInt32 sessionTimeout)
 Open the session. More...
 
virtual UaStatus activate (OpcUa_UInt32 uSecureChannelId, UaUserIdentityToken *pUserIdentityToken, const UaStringArray &localeIDs)
 Activate the session. More...
 
virtual UaStatus close (OpcUa_Boolean deleteSubscriptions)
 Close the session This method is called if the Client closes the Session with the service CloseSession or if the internal clean up routine is closing the Session after a Session timeout. More...
 
virtual OpcUa_Boolean hasExpired () const
 Checks if the session timeout expired. More...
 
virtual UaStatus isValid (OpcUa_UInt32 uSecureChannelId)
 Checks if the session is valid. More...
 
virtual void setInvalid ()
 Set the state of the session to invalid.
 
OpcUa_Boolean isActivated ()
 Get flag indicating if session was activated. More...
 
UaDateTime lastTimeoutReset ()
 Get time the session timeout was reset. More...
 
virtual OpcUa_Boolean mustDelete ()
 Checks if the session must be deleted. More...
 
virtual OpcUa_Boolean isSecureChannelValid ()
 Check if the secure channel assigned to the session is valid. More...
 
virtual void setSecureChannelInvalid ()
 Invalidate the secure channel assigned to the session. More...
 
virtual UaStatus queueBrowseContext (BrowseContext *pBCP, OpcUa_ByteString *pCP)
 Queue a browse continuation point. More...
 
virtual BrowseContextgetBrowseContext (OpcUa_ByteString *pCP)
 Get a browse continuation point. More...
 
virtual OpcUa_UInt16 getMaxBrowseCPs ()
 Get the maximum number of browse continuation points. More...
 
virtual UaStatus queueQueryContext (QueryContext *pBCP, OpcUa_ByteString *pCP)
 Queue a query continuation point. More...
 
virtual QueryContextgetQueryContext (OpcUa_ByteString *pCP)
 Get a query continuation point. More...
 
virtual UaStatus queueHistoryReadCP (HistoryReadCPUserDataBase *pHistoryReadCP, OpcUa_ByteString *pCP)
 Queue a history read continuation point. More...
 
virtual HistoryReadCPUserDataBasegetHistoryReadCP (OpcUa_ByteString *pCP)
 Get a history read continuation point. More...
 
void registerSessionCallback (SessionCallback *pCallback)
 Register callback interface of object interested in the session status.
 
void unregisterSessionCallback (SessionCallback *pCallback)
 Unregister callback interface of object not longer interested in the session status.
 
void resetTimeout ()
 Reset session timeout. More...
 
void getSessionNodeId (OpcUa_NodeId &sessionId) const
 Returns the NodeId of the session. More...
 
OpcUa_Int32 getIntegerSessionId () const
 Returns the integer ID of the session. More...
 
void getAuthenticationToken (OpcUa_NodeId &authenticationToken) const
 Returns the private ID of the session This ID is private to the client and server application and must be kept private inside the management of the session in the client and server code. More...
 
OpcUa_UInt32 getSessionTimeout () const
 Returns the timeout of the session. More...
 
UaString getSessionName () const
 Returns the name of the session. More...
 
OpcUa_UInt32 getSecureChannelId () const
 Returns the ID of the SecureChannel assigned to the session. More...
 
void setSecureChannelSecurityPolicy (const UaString &sSecurityPolicy)
 Sets the security policy of the secure channel active for this session.
 
UaString getSecureChannelSecurityPolicy () const
 Returns the security policy of the secure channel active for this session.
 
void setSecureChannelMessageSecurityMode (OpcUa_MessageSecurityMode messageSecurityMode)
 Sets the message security mode of the secure channel active for this session.
 
OpcUa_MessageSecurityMode getSecureChannelMessageSecurityMode () const
 Returns the message security mode of the secure channel active for this session.
 
void setSecureChannelEndpointConfiguration (const UaEndpoint *pEndpoint)
 Sets the server endpoint configuration used by the secure channel active for this session.
 
const UaEndpointgetSecureChannelEndpointConfiguration () const
 Returns the server endpoint configuration used by the secure channel active for this session.
 
const OpcUa_ByteString * getClientCertificate () const
 Returns the client certificate of the client created the session. More...
 
void setClientApplicationDescription (const UaApplicationDescription &clientApplicationDescription)
 Sets the client application description that contains ApplicationUri, ProductUri, ApplicationName and ApplicationType.
 
UaApplicationDescription getClientApplicationDescription () const
 Returns the client application description that contains ApplicationUri, ProductUri, ApplicationName and ApplicationType.
 
void setClientNetworkAddress (const UaString &clientNetworkAddress)
 Sets the client network address used to communicate with the server through this session.
 
UaString getClientNetworkAddress () const
 Returns the client network address used to communicate with the server through this session.
 
UaString getLocalId () const
 Get the first local Id used for the session. More...
 
const UaStringArray * getLocalIds () const
 Get the list of all local Ids used for the session. More...
 
void setClientUserId (const UaString &sClientUserId)
 Sets the client user id for the session. More...
 
UaString getClientUserId () const
 Returns the client user id for the session. More...
 
virtual OpcUa_UInt64 getSecureChannelKey () const
 Returns an unique key to identify the secure channel in the session manager. More...
 
virtual OpcUa_Boolean isUserAnAdmin () const
 Flag indicating if the session user has administration rights. More...
 
void setIsUserAnAdmin (OpcUa_Boolean isAdmin)
 Method used to set the isUserAnAdmin flag. More...
 
- Public Member Functions inherited from ReferenceCounter
 ReferenceCounter ()
 construction
 
virtual ~ReferenceCounter ()
 destruction
 

Static Public Member Functions

static OpcUa_UInt64 getSecureChannelKey (UaEndpoint *pEndpoint, OpcUa_UInt32 uSecureChannelId)
 Returns an unique key to identify the secure channel in the session manager. More...
 

Protected Member Functions

 Session ()
 Prohibit use of default constructor.
 
virtual ~Session ()
 Prohibit use of destructor. More...
 

Detailed Description

Class used to manage a client session in the server.

It manages all Session relevant settings including the lifetime of the Session. The object is reference counted and can not be deleted directly.

Constructor & Destructor Documentation

Session::~Session ( )
protectedvirtual

Prohibit use of destructor.

Prohibit use of default destructor.

Session::Session ( OpcUa_Int32  sessionId,
const UaNodeId authenticationToken 
)

construction

Parameters
sessionIdthe id of the current Session.
authenticationTokenSecret session Id created by the server application.

Member Function Documentation

UaStatus Session::activate ( OpcUa_UInt32  uSecureChannelId,
UaUserIdentityToken pUserIdentityToken,
const UaStringArray &  localeIDs 
)
virtual

Activate the session.

Sets the Session to a valid state.

Parameters
uSecureChannelIdThe if of the secure channel used for the session.
pUserIdentityTokenThe passed object can be an instance UaUserIdentityTokenAnonymous for the user type Anonymous and UaUserIdentityTokenUserPassword for the user type UserPassword
localeIDsList of locale ids in priority order for localized strings.
Returns
Error code
UaStatus Session::close ( OpcUa_Boolean  deleteSubscriptions)
virtual

Close the session This method is called if the Client closes the Session with the service CloseSession or if the internal clean up routine is closing the Session after a Session timeout.

Parameters
deleteSubscriptionsIndicates if the subscriptions should be deleted by the server
Returns
Error code

Reimplemented in UaSession.

void Session::getAuthenticationToken ( OpcUa_NodeId &  authenticationToken) const

Returns the private ID of the session This ID is private to the client and server application and must be kept private inside the management of the session in the client and server code.

Parameters
authenticationTokenSecret session Id created by the server application.
BrowseContext * Session::getBrowseContext ( OpcUa_ByteString *  pCP)
virtual

Get a browse continuation point.

Parameters
pCPthe continuation point as ByteString.
Returns
a browse continuation point.
const OpcUa_ByteString * Session::getClientCertificate ( ) const

Returns the client certificate of the client created the session.

Returns
Client certificate
UaString Session::getClientUserId ( ) const

Returns the client user id for the session.

HistoryReadCPUserDataBase * Session::getHistoryReadCP ( OpcUa_ByteString *  pCP)
virtual

Get a history read continuation point.

Parameters
pCPthe continuation point as ByteString.
Returns
The history read continuation point data pointer.
OpcUa_Int32 Session::getIntegerSessionId ( ) const

Returns the integer ID of the session.

Returns
Integer session ID of the session object
UaString Session::getLocalId ( ) const

Get the first local Id used for the session.

Returns
The first localId used for the session as UaString.
const UaStringArray * Session::getLocalIds ( ) const

Get the list of all local Ids used for the session.

Returns
The list of all localIds used for the session as const UaStringArray*.
OpcUa_UInt16 Session::getMaxBrowseCPs ( )
virtual

Get the maximum number of browse continuation points.

Returns
maximum number of continuation points.
QueryContext * Session::getQueryContext ( OpcUa_ByteString *  pCP)
virtual

Get a query continuation point.

Parameters
pCPthe continuation point as ByteString.
Returns
a query continuation point.
OpcUa_UInt32 Session::getSecureChannelId ( ) const

Returns the ID of the SecureChannel assigned to the session.

Returns
SecureChannel ID used for the session object
OpcUa_UInt64 Session::getSecureChannelKey ( ) const
virtual

Returns an unique key to identify the secure channel in the session manager.

Returns
The default implementation returns 0.

Reimplemented in UaSession.

OpcUa_UInt64 Session::getSecureChannelKey ( UaEndpoint pEndpoint,
OpcUa_UInt32  uSecureChannelId 
)
static

Returns an unique key to identify the secure channel in the session manager.

Parameters
pEndpointThe endpoint used to create the secure channel.
uSecureChannelIdThe id of the sessions secure channel.
Returns
The key built out of the secureChannelId and the endpoint index.
UaString Session::getSessionName ( ) const

Returns the name of the session.

Returns
Name of the session object
void Session::getSessionNodeId ( OpcUa_NodeId &  sessionId) const

Returns the NodeId of the session.

Parameters
sessionIdthe NodeId of the current Session.
OpcUa_UInt32 Session::getSessionTimeout ( ) const

Returns the timeout of the session.

Returns
Timeout of the session object
OpcUa_Boolean Session::hasExpired ( ) const
virtual

Checks if the session timeout expired.

Returns
TRUE if session timeout expired FALSE if not
OpcUa_Boolean Session::isActivated ( )

Get flag indicating if session was activated.

OpcUa_Boolean Session::isSecureChannelValid ( )
virtual

Check if the secure channel assigned to the session is valid.

Returns
TRUE if valid FALSE if not.
OpcUa_Boolean Session::isUserAnAdmin ( ) const
virtual

Flag indicating if the session user has administration rights.

This flag is used internally in the SDK to detect if the user has rights to view critical diagnostic information like session or subscription related information. It may also be used to check if a user is allowed to execute configuration actions. The default value is false. It must be set by the custom user validation code.

UaStatus Session::isValid ( OpcUa_UInt32  uSecureChannelId)
virtual

Checks if the session is valid.

Returns
Error code.
UaDateTime Session::lastTimeoutReset ( )

Get time the session timeout was reset.

OpcUa_Boolean Session::mustDelete ( )
virtual

Checks if the session must be deleted.

Returns
TRUE if session is to delete FALSE if not
UaStatus Session::open ( const UaString sessionName,
const UaByteString  clientCertificate,
OpcUa_UInt32  sessionTimeout 
)
virtual

Open the session.

Sets the Session timeout and the client name. But the Session is still not valid. An additional call to activateSession is necessary to make the Session valid.

Parameters
sessionNameDisplayable string that identifies the OPC client session.
clientCertificateCertificate of the OPC client application.
sessionTimeoutMaximum number of milliseconds that the session should remain open without activity.
See Also
activate
Returns
Error code
UaStatus Session::queueBrowseContext ( BrowseContext pBCP,
OpcUa_ByteString *  pCP 
)
virtual

Queue a browse continuation point.

Parameters
pBCPthe actual BrowseContext as a pointer.
pCPthe continuation point as ByteString.
Returns
Error code
UaStatus Session::queueHistoryReadCP ( HistoryReadCPUserDataBase pHistoryReadCP,
OpcUa_ByteString *  pCP 
)
virtual

Queue a history read continuation point.

Parameters
pHistoryReadCPthe actual continuation point data as a pointer.
pCPthe continuation point as ByteString.
Returns
Error code
UaStatus Session::queueQueryContext ( QueryContext pBCP,
OpcUa_ByteString *  pCP 
)
virtual

Queue a query continuation point.

Parameters
pBCPthe actual QueryContext as a pointer.
pCPthe continuation point as ByteString.
Returns
Error code
void Session::resetTimeout ( )

Reset session timeout.

This method is called every time a valid service call is executed in the Session context.

void Session::setClientUserId ( const UaString sClientUserId)

Sets the client user id for the session.

void Session::setIsUserAnAdmin ( OpcUa_Boolean  isAdmin)

Method used to set the isUserAnAdmin flag.

It can be used by custom user validation code to set the general flag.

void Session::setSecureChannelInvalid ( )
virtual

Invalidate the secure channel assigned to the session.

Reimplemented in UaSession.


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