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
>
18
#include <
openvpn/common/split.hpp
>
19
#include <
openvpn/http/header.hpp
>
20
21
namespace
openvpn::HTTPProxy
{
22
23
// parse the Proxy-Authenticate HTTP header
24
class
ProxyAuthenticate
:
public
RC
<thread_unsafe_refcount>
25
{
26
public
:
27
using
Ptr
=
RCPtr<ProxyAuthenticate>
;
28
29
ProxyAuthenticate
() =
default
;
30
31
ProxyAuthenticate
(
const
std::string &line)
32
{
33
do_parse
(line);
34
}
35
36
void
parse
(
const
std::string &line)
37
{
38
method
=
""
;
39
parms
.clear();
40
do_parse
(line);
41
}
42
43
std::string
to_string
()
const
44
{
45
std::ostringstream
out
;
46
out
<<
"Proxy-Authenticate header\n"
;
47
out
<<
"method="
<<
method
<<
'\n'
;
48
out
<<
parms
.
to_string
();
49
return
out
.str();
50
}
51
52
std::string
method
;
53
HTTP::HeaderList
parms
;
54
55
private
:
56
void
do_parse
(
const
std::string &line)
57
{
58
std::vector<std::string> tuple = Split::by_char<std::vector<std::string>,
StandardLex
,
Split::NullLimit
>(line,
' '
, 0, 1);
59
if
(!tuple.empty())
60
method
= tuple[0];
61
if
(tuple.size() == 2)
62
{
63
std::vector<std::string> list = Split::by_char<std::vector<std::string>,
StandardLex
,
Split::NullLimit
>(tuple[1],
','
,
Split::TRIM_LEADING_SPACES
|
Split::TRIM_SPECIAL
);
64
for
(std::vector<std::string>::const_iterator i = list.begin(); i != list.end(); ++i)
65
{
66
std::vector<std::string> pair = Split::by_char<std::vector<std::string>,
StandardLex
,
Split::NullLimit
>(*i,
'='
, 0, 1);
67
if
(pair.size() == 2)
68
parms
.push_back(
HTTP::Header
(pair[0], pair[1]));
69
}
70
}
71
}
72
};
73
}
// namespace openvpn::HTTPProxy
74
75
#endif
openvpn::HTTPProxy::ProxyAuthenticate
Definition
proxyauth.hpp:25
openvpn::HTTPProxy::ProxyAuthenticate::parms
HTTP::HeaderList parms
Definition
proxyauth.hpp:53
openvpn::HTTPProxy::ProxyAuthenticate::parse
void parse(const std::string &line)
Definition
proxyauth.hpp:36
openvpn::HTTPProxy::ProxyAuthenticate::to_string
std::string to_string() const
Definition
proxyauth.hpp:43
openvpn::HTTPProxy::ProxyAuthenticate::do_parse
void do_parse(const std::string &line)
Definition
proxyauth.hpp:56
openvpn::HTTPProxy::ProxyAuthenticate::method
std::string method
Definition
proxyauth.hpp:52
openvpn::HTTPProxy::ProxyAuthenticate::ProxyAuthenticate
ProxyAuthenticate()=default
openvpn::HTTPProxy::ProxyAuthenticate::ProxyAuthenticate
ProxyAuthenticate(const std::string &line)
Definition
proxyauth.hpp:31
openvpn::RCPtr
The smart pointer class.
Definition
rc.hpp:119
openvpn::RC
Reference count base class for objects tracked by RCPtr. Disallows copying and assignment.
Definition
rc.hpp:912
openvpn::StandardLex
Definition
lex.hpp:84
header.hpp
openvpn::HTTPProxy
Definition
httpdigest.hpp:22
openvpn::Split::TRIM_LEADING_SPACES
@ TRIM_LEADING_SPACES
Definition
split.hpp:34
openvpn::Split::TRIM_SPECIAL
@ TRIM_SPECIAL
Definition
split.hpp:35
rc.hpp
split.hpp
openvpn::HTTP::HeaderList
Definition
header.hpp:53
openvpn::HTTP::HeaderList::to_string
std::string to_string() const
Definition
header.hpp:93
openvpn::HTTP::Header
Definition
header.hpp:28
openvpn::Split::NullLimit
Definition
split.hpp:39
out
static std::stringstream out
Definition
test_path.cpp:10
openvpn
proxy
proxyauth.hpp
Generated by
1.9.8