S2OPC OPCUA Toolkit
Loading...
Searching...
No Matches
sopc_user.h File Reference

Defines the logged-in (server-side) user. More...

#include <stdbool.h>
#include "sopc_builtintypes.h"

Go to the source code of this file.

Typedefs

typedef struct SOPC_User SOPC_User
 Logged in (successfully) user structure.
 

Functions

const SOPC_UserSOPC_User_GetLocal (void)
 Returns a local user, which shall not be freed nor be modified.
 
bool SOPC_User_IsLocal (const SOPC_User *user)
 Returns true if the user is a local user.
 
const SOPC_UserSOPC_User_GetAnonymous (void)
 Returns an anonymous user, which shall not be freed nor be modified.
 
bool SOPC_User_IsAnonymous (const SOPC_User *user)
 Returns true if the user is an anonymous user.
 
SOPC_UserSOPC_User_CreateUsername (SOPC_String *username)
 Creates a SOPC_User which has a usename.
 
SOPC_UserSOPC_User_CreateCertificate (SOPC_ByteString *certificateData)
 Creates a SOPC_User which has a X509 certificate.
 
const SOPC_StringSOPC_User_GetUsername (const SOPC_User *user)
 Returns a reference to the internal storage of the username. The user must be a user with a username.
 
bool SOPC_User_IsUsername (const SOPC_User *user)
 Returns true if the type of the user is username.
 
const SOPC_ByteStringSOPC_User_GetCertificate (const SOPC_User *user)
 Returns a reference to the internal storage of the DER certificate. The user shall be a user with a certificate.
 
const SOPC_StringSOPC_User_GetCertificate_Thumbprint (const SOPC_User *user)
 Returns a reference to the internal storage of the thumbprint certificate (SHA1 hexadecimal format). The user shall be a user with a certificate.
 
bool SOPC_User_IsCertificate (const SOPC_User *user)
 Returns true if the type of the user is certificate.
 
bool SOPC_User_Equal (const SOPC_User *left, const SOPC_User *right)
 Returns true if the users are the same type and content (if applicable)
 
void SOPC_User_Free (SOPC_User **ppUser)
 User deletion, should not be called on local and anonymous users.
 
SOPC_UserSOPC_User_Copy (const SOPC_User *user)
 Copy the given user.
 
const char * SOPC_User_ToCString (const SOPC_User *user)
 Returns the user as a const C string description:
 

Detailed Description

Defines the logged-in (server-side) user.

The user bears data specific to its type. The following user types are supported:

  • the "local user" is used to verify local operations (see SOPC_ToolkitServer_AsyncLocalServiceRequest), and has no data,
  • the "anonymous user" corresponds to an OpcUa_AnonymousIdentityToken and has no data,
  • the "username user" corresponds to an OpcUa_UserNameIdentityToken and has a username (see SOPC_User_GetUsername).

Typedef Documentation

◆ SOPC_User

typedef struct SOPC_User SOPC_User

Logged in (successfully) user structure.

Function Documentation

◆ SOPC_User_GetLocal()

const SOPC_User * SOPC_User_GetLocal ( void )

Returns a local user, which shall not be freed nor be modified.

◆ SOPC_User_IsLocal()

bool SOPC_User_IsLocal ( const SOPC_User * user)

Returns true if the user is a local user.

◆ SOPC_User_GetAnonymous()

const SOPC_User * SOPC_User_GetAnonymous ( void )

Returns an anonymous user, which shall not be freed nor be modified.

◆ SOPC_User_IsAnonymous()

bool SOPC_User_IsAnonymous ( const SOPC_User * user)

Returns true if the user is an anonymous user.

◆ SOPC_User_CreateUsername()

SOPC_User * SOPC_User_CreateUsername ( SOPC_String * username)

Creates a SOPC_User which has a usename.

Parameters
usernameA valid pointer to the username of the user to create.
Returns
An instance of SOPC_User if successful, otherwise NULL.

◆ SOPC_User_CreateCertificate()

SOPC_User * SOPC_User_CreateCertificate ( SOPC_ByteString * certificateData)

Creates a SOPC_User which has a X509 certificate.

Parameters
certificateDataA valid pointer to the certificate of the user to create.
Returns
An instance of SOPC_User if successful, otherwise NULL.

◆ SOPC_User_GetUsername()

const SOPC_String * SOPC_User_GetUsername ( const SOPC_User * user)

Returns a reference to the internal storage of the username. The user must be a user with a username.

◆ SOPC_User_IsUsername()

bool SOPC_User_IsUsername ( const SOPC_User * user)

Returns true if the type of the user is username.

◆ SOPC_User_GetCertificate()

const SOPC_ByteString * SOPC_User_GetCertificate ( const SOPC_User * user)

Returns a reference to the internal storage of the DER certificate. The user shall be a user with a certificate.

◆ SOPC_User_GetCertificate_Thumbprint()

const SOPC_String * SOPC_User_GetCertificate_Thumbprint ( const SOPC_User * user)

Returns a reference to the internal storage of the thumbprint certificate (SHA1 hexadecimal format). The user shall be a user with a certificate.

◆ SOPC_User_IsCertificate()

bool SOPC_User_IsCertificate ( const SOPC_User * user)

Returns true if the type of the user is certificate.

◆ SOPC_User_Equal()

bool SOPC_User_Equal ( const SOPC_User * left,
const SOPC_User * right )

Returns true if the users are the same type and content (if applicable)

◆ SOPC_User_Free()

void SOPC_User_Free ( SOPC_User ** ppUser)

User deletion, should not be called on local and anonymous users.

◆ SOPC_User_Copy()

SOPC_User * SOPC_User_Copy ( const SOPC_User * user)

Copy the given user.

◆ SOPC_User_ToCString()

const char * SOPC_User_ToCString ( const SOPC_User * user)

Returns the user as a const C string description:

  • No user (no session involved): 'NULL'
  • Local user (server local service context): '[local_user]'
  • Anonymous: '[anonymous]'
  • UserName: '<user_name>' (replaced by actual username)
  • Certificate: the hexadecimal format of the certificate thumbprint (SHA1)