GCC Code Coverage Report


Directory: ./
File: src/Sasl.cpp
Date: 2024-11-05 15:23:15
Exec Total Coverage
Lines: 0 24 0.0%
Branches: 0 28 0.0%

Line Branch Exec Source
1 /*****************************************************************************
2 * vim:tw=78
3 *
4 * Copyright (C) 2021 Bjarne von Horn (vh at igh dot de).
5 *
6 * This file is part of the PdCom library.
7 *
8 * The PdCom library is free software: you can redistribute it and/or modify
9 * it under the terms of the GNU Lesser General Public License as published by
10 * the Free Software Foundation, either version 3 of the License, or (at your
11 * option) any later version.
12 *
13 * The PdCom library is distributed in the hope that it will be useful, but
14 * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
15 * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
16 * License for more details.
17 *
18 * You should have received a copy of the GNU Lesser General Public License
19 * along with the PdCom library. If not, see <http://www.gnu.org/licenses/>.
20 *
21 *****************************************************************************/
22
23 #include "Process.h"
24 #include "ProtocolHandler.h"
25
26 #include <pdcom5/Exception.h>
27 #include <pdcom5/Sasl.h>
28
29
30 using PdCom::Sasl;
31
32 Sasl::Sasl() = default;
33 Sasl::Sasl(Sasl &&o) noexcept : process_(std::move(o.process_))
34 {
35 if (const auto p = process_.lock()) {
36 if (p->auth_manager_ == &o) {
37 p->auth_manager_ = this;
38 }
39 }
40 }
41 Sasl &Sasl::operator=(Sasl &&o) noexcept
42 {
43 if (&o == this)
44 return *this;
45 if (const auto my_process = process_.lock())
46 my_process->auth_manager_ = nullptr;
47 process_ = std::move(o.process_);
48 if (const auto my_process = process_.lock())
49 my_process->auth_manager_ = this;
50 return *this;
51 }
52 Sasl::~Sasl()
53 {
54 if (const auto p = process_.lock())
55 p->setAuthManager(nullptr);
56 }
57
58 bool Sasl::loginStep(const char *mech, const char *clientData)
59 {
60 if (const auto p = process_.lock())
61 return p->protocolHandler().login(mech, clientData);
62 else
63 throw ProcessGoneAway();
64 }
65
66 void Sasl::logout()
67 {
68 if (const auto p = process_.lock())
69 p->protocolHandler().logout();
70 else
71 throw ProcessGoneAway();
72 }
73