Directory: | ./ |
---|---|
File: | pdcom5/src/Sasl.cpp |
Date: | 2024-12-15 04:08:34 |
Exec | Total | Coverage | |
---|---|---|---|
Lines: | 12 | 26 | 46.2% |
Branches: | 10 | 28 | 35.7% |
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 | 58 | Sasl::~Sasl() | |
53 | { | ||
54 |
2/2✓ Branch 3 taken 25 times.
✓ Branch 4 taken 4 times.
|
58 | if (const auto p = process_.lock()) |
55 | 25 | p->setAuthManager(nullptr); | |
56 | 29 | } | |
57 | |||
58 | 65 | bool Sasl::loginStep(const char *mech, const char *clientData) | |
59 | { | ||
60 |
2/2✓ Branch 3 taken 64 times.
✓ Branch 4 taken 1 times.
|
130 | if (const auto p = process_.lock()) |
61 |
2/4✓ Branch 5 taken 64 times.
✗ Branch 6 not taken.
✓ Branch 13 taken 64 times.
✗ Branch 14 not taken.
|
128 | return p->protocolHandler().login(mech, clientData); |
62 | else | ||
63 |
1/2✓ Branch 2 taken 1 times.
✗ Branch 3 not taken.
|
1 | throw ProcessGoneAway(); |
64 | } | ||
65 | |||
66 | 1 | void Sasl::logout() | |
67 | { | ||
68 |
1/2✓ Branch 3 taken 1 times.
✗ Branch 4 not taken.
|
2 | if (const auto p = process_.lock()) |
69 |
2/4✓ Branch 5 taken 1 times.
✗ Branch 6 not taken.
✓ Branch 13 taken 1 times.
✗ Branch 14 not taken.
|
1 | p->protocolHandler().logout(); |
70 | else | ||
71 | ✗ | throw ProcessGoneAway(); | |
72 | 1 | } | |
73 |