forked from pocoproject/poco
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathHTTPAuthenticationParams.h
More file actions
105 lines (78 loc) · 3.14 KB
/
HTTPAuthenticationParams.h
File metadata and controls
105 lines (78 loc) · 3.14 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
//
// HTTPAuthenticationParams.h
//
// $Id: //poco/1.4/Net/include/Poco/Net/HTTPAuthenticationParams.h#2 $
//
// Library: Net
// Package: HTTP
// Module: HTTPAuthenticationParams
//
// Definition of the HTTPAuthenticationParams class.
//
// Copyright (c) 2011, Anton V. Yabchinskiy (arn at bestmx dot ru).
// Copyright (c) 2012, Applied Informatics Software Engineering GmbH.
// and Contributors.
//
// SPDX-License-Identifier: BSL-1.0
//
#ifndef Net_HTTPAuthenticationParams_INCLUDED
#define Net_HTTPAuthenticationParams_INCLUDED
#include "Poco/Net/NameValueCollection.h"
namespace Poco {
namespace Net {
class HTTPRequest;
class HTTPResponse;
class Net_API HTTPAuthenticationParams: public NameValueCollection
/// Collection of name-value pairs of HTTP authentication header (i.e.
/// "realm", "qop", "nonce" in case of digest authentication header).
{
public:
HTTPAuthenticationParams();
/// Creates an empty authentication parameters collection.
explicit HTTPAuthenticationParams(const std::string& authInfo);
/// See fromAuthInfo() documentation.
explicit HTTPAuthenticationParams(const HTTPRequest& request);
/// See fromRequest() documentation.
HTTPAuthenticationParams(const HTTPResponse& response, const std::string& header = WWW_AUTHENTICATE);
/// See fromResponse() documentation.
virtual ~HTTPAuthenticationParams();
/// Destroys the HTTPAuthenticationParams.
HTTPAuthenticationParams& operator = (const HTTPAuthenticationParams& authParams);
/// Assigns the content of another HTTPAuthenticationParams.
void fromAuthInfo(const std::string& authInfo);
/// Creates an HTTPAuthenticationParams by parsing authentication
/// information.
void fromRequest(const HTTPRequest& request);
/// Extracts authentication information from the request and creates
/// HTTPAuthenticationParams by parsing it.
///
/// Throws a NotAuthenticatedException if no authentication
/// information is contained in request.
/// Throws a InvalidArgumentException if authentication scheme is
/// unknown or invalid.
void fromResponse(const HTTPResponse& response, const std::string& header = WWW_AUTHENTICATE);
/// Extracts authentication information from the response and creates
/// HTTPAuthenticationParams by parsing it.
///
/// Throws a NotAuthenticatedException if no authentication
/// information is contained in response.
/// Throws a InvalidArgumentException if authentication scheme is
/// unknown or invalid.
void setRealm(const std::string& realm);
/// Sets the "realm" parameter to the provided string.
const std::string& getRealm() const;
/// Returns value of the "realm" parameter.
///
/// Throws NotFoundException is there is no "realm" set in the
/// HTTPAuthenticationParams.
std::string toString() const;
/// Formats the HTTPAuthenticationParams for inclusion in HTTP
/// request or response authentication header.
static const std::string REALM;
static const std::string WWW_AUTHENTICATE;
static const std::string PROXY_AUTHENTICATE;
private:
void parse(std::string::const_iterator first, std::string::const_iterator last);
};
} } // namespace Poco::Net
#endif // Net_HTTPAuthenticationParams_INCLUDED