| Line |
Branch |
Exec |
Source |
| 1 |
|
|
/***************************************************************************** |
| 2 |
|
|
* |
| 3 |
|
|
* Copyright (C) 2021 Bjarne von Horn (vh at igh dot de). |
| 4 |
|
|
* |
| 5 |
|
|
* This file is part of the PdCom library. |
| 6 |
|
|
* |
| 7 |
|
|
* The PdCom library is free software: you can redistribute it and/or modify |
| 8 |
|
|
* it under the terms of the GNU Lesser General Public License as published by |
| 9 |
|
|
* the Free Software Foundation, either version 3 of the License, or (at your |
| 10 |
|
|
* option) any later version. |
| 11 |
|
|
* |
| 12 |
|
|
* The PdCom library is distributed in the hope that it will be useful, but |
| 13 |
|
|
* WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY |
| 14 |
|
|
* or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public |
| 15 |
|
|
* License for more details. |
| 16 |
|
|
* |
| 17 |
|
|
* You should have received a copy of the GNU Lesser General Public License |
| 18 |
|
|
* along with the PdCom library. If not, see <http://www.gnu.org/licenses/>. |
| 19 |
|
|
* |
| 20 |
|
|
*****************************************************************************/ |
| 21 |
|
|
|
| 22 |
|
|
#ifndef PDCOM5_SASL_H |
| 23 |
|
|
#define PDCOM5_SASL_H |
| 24 |
|
|
|
| 25 |
|
|
#include <pdcom5_export.h> |
| 26 |
|
|
|
| 27 |
|
|
namespace PdCom { |
| 28 |
|
|
namespace impl { |
| 29 |
|
|
class Process; |
| 30 |
|
|
} |
| 31 |
|
|
|
| 32 |
|
|
/** SASL Interface for PdCom. |
| 33 |
|
|
* |
| 34 |
|
|
* With the help of this interface, a SASL library can communicate with the |
| 35 |
|
|
* server and perfom authentification. |
| 36 |
|
|
* |
| 37 |
|
|
* The authentification class needs to be registered in the process with |
| 38 |
|
|
* Process::setAuthManager(). |
| 39 |
|
|
* |
| 40 |
|
|
*/ |
| 41 |
|
29 |
class PDCOM5_PUBLIC Sasl |
| 42 |
|
|
{ |
| 43 |
|
|
public: |
| 44 |
|
|
Sasl(); |
| 45 |
|
|
Sasl(Sasl const &) = delete; |
| 46 |
|
|
Sasl(Sasl &&) noexcept; |
| 47 |
|
|
Sasl &operator=(Sasl &&) noexcept; |
| 48 |
|
|
Sasl &operator=(Sasl const &) = delete; |
| 49 |
|
|
|
| 50 |
|
|
protected: |
| 51 |
|
|
/** Perform SASL login step. |
| 52 |
|
|
* |
| 53 |
|
|
* @param mech SASL mechanism |
| 54 |
|
|
* @param clientData Base64 encoded SASL output data to server |
| 55 |
|
|
* |
| 56 |
|
|
* Setting both \p mech and \p clientData to NULL will initate the |
| 57 |
|
|
* login process. |
| 58 |
|
|
* |
| 59 |
|
|
* Every call to login() is answered by a loginReply(), unless |
| 60 |
|
|
* login is not supported. When login is mandatory, loginReply() |
| 61 |
|
|
* will be called automatically. |
| 62 |
|
|
* |
| 63 |
|
|
* @return false if login is not supported |
| 64 |
|
|
*/ |
| 65 |
|
|
bool loginStep(const char *mech, const char *clientData); |
| 66 |
|
|
/** Logout from server |
| 67 |
|
|
*/ |
| 68 |
|
|
void logout(); |
| 69 |
|
|
~Sasl(); |
| 70 |
|
|
|
| 71 |
|
|
|
| 72 |
|
|
private: |
| 73 |
|
|
friend impl::Process; |
| 74 |
|
|
std::weak_ptr<impl::Process> process_; |
| 75 |
|
|
|
| 76 |
|
|
/** SASL server reply to login() |
| 77 |
|
|
* |
| 78 |
|
|
* loginReply() may be called without calling login() in the case |
| 79 |
|
|
* where login is mandatory. In this case, it is called before |
| 80 |
|
|
* Process::connected(). |
| 81 |
|
|
* |
| 82 |
|
|
* @param mechlist Space separated list of supported mechanisms |
| 83 |
|
|
* @param serverData Base64 encoded SASL data from server |
| 84 |
|
|
* @param finished |
| 85 |
|
|
* \parblock |
| 86 |
|
|
* > 0: Login successful\n |
| 87 |
|
|
* 0: Login process not finished; another login() step is required\n |
| 88 |
|
|
* < 0: Login failed |
| 89 |
|
|
* \endparblock |
| 90 |
|
|
*/ |
| 91 |
|
|
virtual void |
| 92 |
|
|
loginReply(const char *mechlist, const char *serverData, int finished) = 0; |
| 93 |
|
|
}; |
| 94 |
|
|
} // namespace PdCom |
| 95 |
|
|
|
| 96 |
|
|
#endif // PDCOM5_SASL_H |
| 97 |
|
|
|