25 #include "cpprest/asyncrt_utils.h"
30 namespace http {
namespace client {
namespace details {
34 namespace websockets {
namespace client {
namespace details {
35 class winrt_callback_client;
36 class wspp_callback_client;
45 _ASYNCRTIMP
void operator()(::utility::string_t *data)
const;
47 typedef std::unique_ptr<::utility::string_t, zero_memory_deleter> plaintext_string;
49 #if defined(_WIN32) && !defined(CPPREST_TARGET_XP)
50 #if defined(__cplusplus_winrt)
51 class winrt_encryption
55 _ASYNCRTIMP winrt_encryption(
const std::wstring &data);
56 _ASYNCRTIMP plaintext_string decrypt()
const;
61 class win32_encryption
65 _ASYNCRTIMP win32_encryption(
const std::wstring &data);
66 _ASYNCRTIMP ~win32_encryption();
67 _ASYNCRTIMP plaintext_string decrypt()
const;
69 std::vector<char> m_buffer;
70 size_t m_numCharacters;
94 m_username(std::move(username)),
102 const utility::string_t &
username()
const {
return m_username; }
108 CASABLANCA_DEPRECATED(
"This API is deprecated for security reasons to avoid unnecessary password copies stored in plaintext.")
111 #if defined(_WIN32) && !defined(CPPREST_TARGET_XP)
112 return utility::string_t(*m_password.decrypt());
122 bool is_set()
const {
return !m_username.empty(); }
125 friend class http::client::details::winhttp_client;
126 friend class http::client::details::winrt_client;
127 friend class websockets::client::details::winrt_callback_client;
128 friend class websockets::client::details::wspp_callback_client;
130 details::plaintext_string decrypt()
const
133 #if defined(_WIN32) && !defined(CPPREST_TARGET_XP)
134 return m_password.decrypt();
136 return details::plaintext_string(new ::utility::string_t(m_password));
140 ::utility::string_t m_username;
142 #if defined(_WIN32) && !defined(CPPREST_TARGET_XP)
143 #if defined(__cplusplus_winrt)
144 details::winrt_encryption m_password;
146 details::win32_encryption m_password;
149 ::utility::string_t m_password;
159 enum web_proxy_mode_internal{ use_default_, use_auto_discovery_, disabled_, user_provided_ };
161 enum web_proxy_mode{ use_default = use_default_, use_auto_discovery = use_auto_discovery_, disabled = disabled_};
166 web_proxy() : m_address(_XPLATSTR(
"")), m_mode(use_default_) {}
172 web_proxy( web_proxy_mode mode ) : m_address(_XPLATSTR(
"")), m_mode(static_cast<web_proxy_mode_internal>(mode)) {}
197 if( m_mode == disabled_ )
199 throw std::invalid_argument(
"Cannot attach credentials to a disabled proxy");
201 m_credentials = std::move(cred);
230 web_proxy_mode_internal m_mode;
const web::credentials & credentials() const
Gets the credentials used for authentication with this proxy.
Definition: web_utilities.h:190
Represents a set of user credentials (user name and password) to be used for authentication.
Definition: web_utilities.h:80
Definition: web_utilities.h:42
A flexible, protocol independent URI implementation.
Definition: base_uri.h:151
web_proxy()
Constructs a proxy with the default settings.
Definition: web_utilities.h:166
bool is_auto_discovery() const
Checks if the auto discovery protocol, WPAD, is to be used.
Definition: web_utilities.h:220
bool is_disabled() const
Checks if using a proxy is disabled.
Definition: web_utilities.h:214
The web namespace contains functionality common to multiple protocols like HTTP and WebSockets...
Definition: base_uri.h:37
bool is_specified() const
Checks if a proxy address is explicitly specified by the user.
Definition: web_utilities.h:226
const uri & address() const
Gets this proxy's URI address. Returns an empty URI if not explicitly set by user.
Definition: web_utilities.h:184
bool is_set() const
Checks if credentials have been set
Definition: web_utilities.h:122
web_proxy(uri address)
Creates a proxy explicitly with provided address.
Definition: web_utilities.h:178
web_proxy represents the concept of the web proxy, which can be auto-discovered, disabled, or specified explicitly by the user.
Definition: web_utilities.h:157
web_proxy(web_proxy_mode mode)
Creates a proxy with specified mode.
Definition: web_utilities.h:172
credentials(utility::string_t username, const utility::string_t &password)
Constructs credentials from given user name and password.
Definition: web_utilities.h:93
void set_credentials(web::credentials cred)
Sets the credentials to use for authentication with this proxy.
Definition: web_utilities.h:196
The Parallel Patterns Library (PPL) task class. A task object represents work that can be executed as...
Definition: pplxtasks.h:176
credentials()
Constructs an empty set of credentials without a user name or password.
Definition: web_utilities.h:86
const utility::string_t & username() const
The user name associated with the credentials.
Definition: web_utilities.h:102
utility::string_t password() const
The password for the user name associated with the credentials.
Definition: web_utilities.h:109
bool is_default() const
Checks if this proxy was constructed with default settings.
Definition: web_utilities.h:208
Various utilities for string conversions and date and time manipulation.
Definition: asyncrt_utils.h:50