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
typedef
RCPtr<ProxyAuthenticate>
Ptr
;
28
29
ProxyAuthenticate
()
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
;
55
HTTP::HeaderList
parms
;
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
openvpn::HTTPProxy::ProxyAuthenticate
Definition
proxyauth.hpp:25
openvpn::HTTPProxy::ProxyAuthenticate::parms
HTTP::HeaderList parms
Definition
proxyauth.hpp:55
openvpn::HTTPProxy::ProxyAuthenticate::Ptr
RCPtr< ProxyAuthenticate > Ptr
Definition
proxyauth.hpp:27
openvpn::HTTPProxy::ProxyAuthenticate::parse
void parse(const std::string &line)
Definition
proxyauth.hpp:38
openvpn::HTTPProxy::ProxyAuthenticate::to_string
std::string to_string() const
Definition
proxyauth.hpp:45
openvpn::HTTPProxy::ProxyAuthenticate::do_parse
void do_parse(const std::string &line)
Definition
proxyauth.hpp:58
openvpn::HTTPProxy::ProxyAuthenticate::method
std::string method
Definition
proxyauth.hpp:54
openvpn::HTTPProxy::ProxyAuthenticate::ProxyAuthenticate
ProxyAuthenticate()
Definition
proxyauth.hpp:29
openvpn::HTTPProxy::ProxyAuthenticate::ProxyAuthenticate
ProxyAuthenticate(const std::string &line)
Definition
proxyauth.hpp:33
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:54
openvpn::HTTP::HeaderList::to_string
std::string to_string() const
Definition
header.hpp:94
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