PdCom  5.3
Process data communication client
Classes | Public Types | Public Member Functions | Static Public Member Functions | Protected Member Functions | Friends | List of all members
PdCom::SimpleLoginManager Class Referenceabstract

Wrapper for Cyrus SASL library. More...

#include <SimpleLoginManager.h>

Inheritance diagram for PdCom::SimpleLoginManager:
PdCom::Sasl

Classes

struct  Cancel
 Exception for callback cancelation. More...
 

Public Types

enum  LoginResult { Success, Error, Canceled, LoginResult::NoSaslMechanism }
 Result of login operation. More...
 

Public Member Functions

 SimpleLoginManager (const char *remote_host, sasl_callback *additional_callbacks=nullptr)
 Constructor. More...
 
 SimpleLoginManager (SimpleLoginManager &&) noexcept
 
SimpleLoginManageroperator= (SimpleLoginManager &&) noexcept
 
- Public Member Functions inherited from PdCom::Sasl
 Sasl (Sasl const &)=delete
 
 Sasl (Sasl &&) noexcept
 
Sasloperator= (Sasl &&) noexcept
 
Sasloperator= (Sasl const &)=delete
 

Static Public Member Functions

static void InitLibrary (const char *plugin_path=nullptr)
 Sasl global initialization. More...
 
static void FinalizeLibrary ()
 Sasl global finalization.
 

Protected Member Functions

bool login ()
 Perform SASL login step. More...
 
virtual std::string getAuthname ()
 Callback to get login name.
 
virtual std::string getPassword ()
 Callback to get password.
 
virtual std::string getRealm (const std::vector< const char *> &)
 Callback to get realm.
 
virtual std::string getOption (const char *, const char *)
 SASL get option callback.
 
virtual std::string interact (unsigned long, const char *, const char *, const char *)
 SASL interact callback.
 
virtual void completed (LoginResult result)=0
 Authentification completed callback. More...
 
virtual void log (int level, const char *message)
 Log callback. More...
 
void logout ()
 Logout from server.
 
- Protected Member Functions inherited from PdCom::Sasl
bool loginStep (const char *mech, const char *clientData)
 Perform SASL login step. More...
 
void logout ()
 Logout from server.
 

Friends

class impl::SimpleLoginManager
 

Detailed Description

Wrapper for Cyrus SASL library.

This class provides a nice interface to enable simple authentification. All you have to do is overriding some of the callbacks below. First, register your instance to the Process using Process::setAuthManager(). After that, call login(). Then, call Process::asyncData() until completed() is called. During this process, you're being asked to enter credentials via the given callbacks.

Examples:
sasl_example.cpp.

Member Enumeration Documentation

◆ LoginResult

Result of login operation.

Enumerator
NoSaslMechanism 

No matching SASL Mechanism found on client machine.

Constructor & Destructor Documentation

◆ SimpleLoginManager()

PdCom::SimpleLoginManager::SimpleLoginManager ( const char *  remote_host,
sasl_callback *  additional_callbacks = nullptr 
)

Constructor.

Parameters
remote_hostRemote hostname.
additional_callbacksNULL-terminated list of additional callback handlers.

Member Function Documentation

◆ completed()

virtual void PdCom::SimpleLoginManager::completed ( LoginResult  result)
protectedpure virtual

Authentification completed callback.

Parameters
resultOutcome of login operation.
Examples:
sasl_example.cpp.

◆ InitLibrary()

static void PdCom::SimpleLoginManager::InitLibrary ( const char *  plugin_path = nullptr)
static

Sasl global initialization.

Call this at startup of your application to initialize the underlying sasl library.

Exceptions
PdCom::ExceptionInitialization failed.
Examples:
sasl_example.cpp.

◆ log()

virtual void PdCom::SimpleLoginManager::log ( int  level,
const char *  message 
)
protectedvirtual

Log callback.

Parameters
levelLog level, 0 to 7. 7 may contain passwords.
messageMessage.

◆ login()

bool PdCom::SimpleLoginManager::login ( )
protected

Perform SASL login step.

Parameters
mechSASL mechanism
clientDataBase64 encoded SASL output data to server

Setting both mech and clientData to NULL will initate the login process.

Every call to login() is answered by a loginReply(), unless login is not supported. When login is mandatory, loginReply() will be called automatically.

Returns
false if login is not supported
Examples:
sasl_example.cpp.

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