Scanframe Modular Application 0.1.0
Loading...
Searching...
No Matches
sf::Security Class Reference

Interface for regulating user access to parts of the code. This class is commonly declared as static. The boolean operator returns true if access is allowed. More...

#include <Security.h>

Collaboration diagram for sf::Security:

Public Types

enum  ERequestCall {
  rcLogout , rcLogin , rcAccess , rcGrant ,
  rcRevoke , rcPassword , rcDialog
}
 List of request call to make. More...
 
typedef bool(* ServerCallBack) (ERequestCall request, std::string s1, std::string s2)
 Type of the call back function.
 

Public Member Functions

 Security (const std::string &key_name, const std::string &description)
 Constructor passing the lock key name and its description.
 
 ~Security ()
 Destructor.
 
bool isAccessible () const
 Checks if access is allowed.
 
bool isDatabaseAccessible () const
 Checks at the server if it is accessible for a certain name. Only used for management not to be used by clients.
 
bool operator() () const
 Constant boolean operator returning true when access is given.
 
 operator bool () const
 Boolean operator returning true when access is given.
 
bool setAccess (bool grant)
 Grants the current user access to this entry.
 
std::string getKeyName () const
 Gets the at the constructor given key name.
 
std::string getDescription () const
 Gets the at the constructor given description.
 
void setData (uint64_t data)
 To link secondary data.
 
uint64_t getData () const
 Gets the linked secondary data.
 

Static Public Member Functions

static std::string getUsername ()
 Gets the username of the current logged on user.
 
static void setUsername (const std::string &name)
 Sets the username of the current logged on user.
 
static std::string getPassword ()
 Gets the password of the current user.
 
static bool setPassword (const std::string &password)
 Sets the password on the current user.
 
static bool setPassword ()
 Same as above but the server shows a dialog to allow entering the password.
 
static bool isLoggedIn ()
 Checks if a user is logged in.
 
static void setServerCallBack (ServerCallBack func)
 Sets the call back function for a security server.
 
static bool login (std::string username, std::string password)
 Logs a user in.
 
static void logout ()
 Logs the current user out.
 
static bool isAvailable ()
 Checks if a security server is available.
 
static unsigned getCount ()
 Gets the current total of items in the list of locks.
 
static SecuritygetEntry (unsigned index)
 Gets the entry at the given index from the list of entries.
 
static void setAccessToAll (bool grant)
 Grants all access temporarily to be able to set and test no access behavior.
 

Protected Member Functions

void set (const std::string &key_name, const std::string &description)
 Initializer method.
 

Protected Attributes

std::string _keyName
 Holds the key for this security entry.
 
std::string _description
 Holds the description of this security entry.
 
uint64_t _data
 Holds the data linked to this instance.
 

Detailed Description

Interface for regulating user access to parts of the code. This class is commonly declared as static. The boolean operator returns true if access is allowed.

Security MyLock("my lock", "Just a sample lock.");
void TMyClass::HandleEvent()
{
if (MyLock)
{
// your_code...
}
}
Interface for regulating user access to parts of the code. This class is commonly declared as static....
Definition Security.h:25

Member Typedef Documentation

◆ ServerCallBack

typedef bool(* sf::Security::ServerCallBack) (ERequestCall request, std::string s1, std::string s2)

Type of the call back function.

Member Enumeration Documentation

◆ ERequestCall

List of request call to make.

Enumerator
rcLogout 

Log user out.

rcLogin 

Log user in.

rcAccess 

Request access for the current user.

rcGrant 

Grants access for the current user.

rcRevoke 

Revokes access for the current user.

rcPassword 

Request for password change.

rcDialog 

Request for password change.

Constructor & Destructor Documentation

◆ Security()

sf::Security::Security ( const std::string &  key_name,
const std::string &  description 
)

Constructor passing the lock key name and its description.

Parameters
key_nameName used to store this entry in a database.
descriptionDescriptive text to make sense of it.

◆ ~Security()

sf::Security::~Security ( )

Destructor.

Member Function Documentation

◆ getCount()

static unsigned sf::Security::getCount ( )
static

Gets the current total of items in the list of locks.

◆ getData()

uint64_t sf::Security::getData ( ) const
inline

Gets the linked secondary data.

◆ getDescription()

std::string sf::Security::getDescription ( ) const
inline

Gets the at the constructor given description.

◆ getEntry()

static Security * sf::Security::getEntry ( unsigned  index)
static

Gets the entry at the given index from the list of entries.

◆ getKeyName()

std::string sf::Security::getKeyName ( ) const
inline

Gets the at the constructor given key name.

◆ getPassword()

std::string sf::Security::getPassword ( )
inlinestatic

Gets the password of the current user.

◆ getUsername()

std::string sf::Security::getUsername ( )
inlinestatic

Gets the username of the current logged on user.

◆ isAccessible()

bool sf::Security::isAccessible ( ) const

Checks if access is allowed.

Returns
True when allowed.

◆ isAvailable()

static bool sf::Security::isAvailable ( )
static

Checks if a security server is available.

Returns
True when available.

◆ isDatabaseAccessible()

bool sf::Security::isDatabaseAccessible ( ) const

Checks at the server if it is accessible for a certain name. Only used for management not to be used by clients.

◆ isLoggedIn()

bool sf::Security::isLoggedIn ( )
inlinestatic

Checks if a user is logged in.

Returns
True when logged in.

◆ login()

static bool sf::Security::login ( std::string  username,
std::string  password 
)
static

Logs a user in.

Parameters
usernameThe username.
passwordThe password.
Returns
True if login is successful.

◆ logout()

static void sf::Security::logout ( )
static

Logs the current user out.

◆ operator bool()

sf::Security::operator bool ( ) const
inline

Boolean operator returning true when access is given.

◆ operator()()

bool sf::Security::operator() ( ) const
inline

Constant boolean operator returning true when access is given.

Returns
True when access is given.

◆ set()

void sf::Security::set ( const std::string &  key_name,
const std::string &  description 
)
protected

Initializer method.

Parameters
key_nameName used to store this entry in a database.
descriptionDescriptive text to make sense of it.

◆ setAccess()

bool sf::Security::setAccess ( bool  grant)

Grants the current user access to this entry.

Parameters
grant
Returns
True when successfull.

◆ setAccessToAll()

static void sf::Security::setAccessToAll ( bool  grant)
static

Grants all access temporarily to be able to set and test no access behavior.

Parameters
grant

◆ setData()

void sf::Security::setData ( uint64_t  data)
inline

To link secondary data.

◆ setPassword() [1/2]

static bool sf::Security::setPassword ( )
static

Same as above but the server shows a dialog to allow entering the password.

Returns
True on success.

◆ setPassword() [2/2]

static bool sf::Security::setPassword ( const std::string &  password)
static

Sets the password on the current user.

Parameters
passwordThe new password.
Returns
True on success.

◆ setServerCallBack()

static void sf::Security::setServerCallBack ( ServerCallBack  func)
static

Sets the call back function for a security server.

◆ setUsername()

static void sf::Security::setUsername ( const std::string &  name)
static

Sets the username of the current logged on user.

Member Data Documentation

◆ _data

uint64_t sf::Security::_data
protected

Holds the data linked to this instance.

◆ _description

std::string sf::Security::_description
protected

Holds the description of this security entry.

◆ _keyName

std::string sf::Security::_keyName
protected

Holds the key for this security entry.


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