OpenVPN 3 Core Library
Loading...
Searching...
No Matches
proxyauth.hpp
Go to the documentation of this file.
1// OpenVPN -- An application to securely tunnel IP networks
2// over a single port, with support for SSL/TLS-based
3// session authentication and key exchange,
4// packet encryption, packet authentication, and
5// packet compression.
6//
7// Copyright (C) 2012- OpenVPN Inc.
8//
9// SPDX-License-Identifier: MPL-2.0 OR AGPL-3.0-only WITH openvpn3-openssl-exception
10//
11
12#ifndef OPENVPN_PROXY_PROXYAUTH_H
13#define OPENVPN_PROXY_PROXYAUTH_H
14
15#include <vector>
16
17#include <openvpn/common/rc.hpp>
20
21namespace openvpn::HTTPProxy {
22
23// parse the Proxy-Authenticate HTTP header
24class ProxyAuthenticate : public RC<thread_unsafe_refcount>
25{
26 public:
28
30 {
31 }
32
33 ProxyAuthenticate(const std::string &line)
34 {
35 do_parse(line);
36 }
37
38 void parse(const std::string &line)
39 {
40 method = "";
41 parms.clear();
42 do_parse(line);
43 }
44
45 std::string to_string() const
46 {
47 std::ostringstream out;
48 out << "Proxy-Authenticate header" << std::endl;
49 out << "method=" << method << std::endl;
50 out << parms.to_string();
51 return out.str();
52 }
53
54 std::string method;
56
57 private:
58 void do_parse(const std::string &line)
59 {
60 std::vector<std::string> tuple = Split::by_char<std::vector<std::string>, StandardLex, Split::NullLimit>(line, ' ', 0, 1);
61 if (tuple.size() >= 1)
62 method = tuple[0];
63 if (tuple.size() == 2)
64 {
65 std::vector<std::string> list = Split::by_char<std::vector<std::string>, StandardLex, Split::NullLimit>(tuple[1], ',', Split::TRIM_LEADING_SPACES | Split::TRIM_SPECIAL);
66 for (std::vector<std::string>::const_iterator i = list.begin(); i != list.end(); ++i)
67 {
68 std::vector<std::string> pair = Split::by_char<std::vector<std::string>, StandardLex, Split::NullLimit>(*i, '=', 0, 1);
69 if (pair.size() == 2)
70 parms.push_back(HTTP::Header(pair[0], pair[1]));
71 }
72 }
73 }
74};
75} // namespace openvpn::HTTPProxy
76
77#endif
RCPtr< ProxyAuthenticate > Ptr
Definition proxyauth.hpp:27
void parse(const std::string &line)
Definition proxyauth.hpp:38
void do_parse(const std::string &line)
Definition proxyauth.hpp:58
ProxyAuthenticate(const std::string &line)
Definition proxyauth.hpp:33
The smart pointer class.
Definition rc.hpp:119
Reference count base class for objects tracked by RCPtr. Disallows copying and assignment.
Definition rc.hpp:912
@ TRIM_LEADING_SPACES
Definition split.hpp:34
std::string to_string() const
Definition header.hpp:94
static std::stringstream out
Definition test_path.cpp:10