S2OPC OPCUA Toolkit
Typedefs | Functions
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. More...
 

Functions

const SOPC_UserSOPC_User_GetLocal (void)
 Returns a local user, which shall not be freed nor be modified. More...
 
bool SOPC_User_IsLocal (const SOPC_User *user)
 Returns true if the user is a local user. More...
 
const SOPC_UserSOPC_User_GetAnonymous (void)
 Returns an anonymous user, which shall not be freed nor be modified. More...
 
bool SOPC_User_IsAnonymous (const SOPC_User *user)
 Returns true if the user is an anonymous user. More...
 
SOPC_UserSOPC_User_CreateUsername (SOPC_String *username)
 Creates a SOPC_User which has a usename. More...
 
SOPC_UserSOPC_User_CreateCertificate (SOPC_ByteString *certificateData)
 Creates a SOPC_User which has a X509 certificate. More...
 
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. More...
 
bool SOPC_User_IsUsername (const SOPC_User *user)
 Returns true if the type of the user is username. More...
 
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. More...
 
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. More...
 
bool SOPC_User_IsCertificate (const SOPC_User *user)
 Returns true if the type of the user is certificate. More...
 
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) More...
 
void SOPC_User_Free (SOPC_User **ppUser)
 User deletion, should not be called on local and anonymous users. More...
 
SOPC_UserSOPC_User_Copy (const SOPC_User *user)
 Copy the given user. More...
 
const char * SOPC_User_ToCString (const SOPC_User *user)
 Returns the user as a const C string description: More...
 

Detailed Description

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

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

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)