#include <icy/http/authenticator.h>Maintains HTTP Basic or Digest authentication state for outbound requests.
Note: Do not forget to read the entire response stream from the 401 response before sending the authenticated request, otherwise there may be problems if a persistent connection is used.
| Return | Name | Description |
|---|---|---|
Authenticator | Creates an empty authenticator. | |
Authenticator | Creates an authenticator with the given username and password. | |
~Authenticator | Destroys the authenticator. | |
void | fromUserInfo | Parses username:password std::string and sets username and password of the credentials object. Throws SyntaxException on invalid user information. |
void | fromURI | Extracts username and password from the given URI and sets username and password of the credentials object. Does nothing if URI has no user info part. |
void | setUsername | Sets the username. |
const std::string & | username const | Returns the username. |
void | setPassword | Sets the password. |
const std::string & | password const | Returns the password. |
void | authenticate | Inspects WWW-Authenticate header of the response, initializes the internal state (in case of digest authentication) and adds required information to the given http::Request. |
void | updateAuthInfo | Updates internal state (in case of digest authentication) and replaces authentication information in the request accordingly. |
void | proxyAuthenticate | Inspects Proxy-Authenticate header of the response, initializes the internal state (in case of digest authentication) and adds required information to the given http::Request. |
void | updateProxyAuthInfo | Updates internal state (in case of digest authentication) and replaces proxy authentication information in the request accordingly. |
Authenticator()Creates an empty authenticator.
Authenticator(const std::string & username, const std::string & password)Creates an authenticator with the given username and password.
~Authenticator()Destroys the authenticator.
void fromUserInfo(std::string_view userInfo)Parses username:password std::string and sets username and password of the credentials object. Throws SyntaxException on invalid user information.
void fromURI(const http::URL & uri)Extracts username and password from the given URI and sets username and password of the credentials object. Does nothing if URI has no user info part.
void setUsername(const std::string & username)Sets the username.
const
const std::string & username() constReturns the username.
void setPassword(const std::string & password)Sets the password.
const
const std::string & password() constReturns the password.
void authenticate(http::Request & request, const http::Response & response)Inspects WWW-Authenticate header of the response, initializes the internal state (in case of digest authentication) and adds required information to the given http::Request.
void updateAuthInfo(http::Request & request)Updates internal state (in case of digest authentication) and replaces authentication information in the request accordingly.
void proxyAuthenticate(http::Request & request, const http::Response & response)Inspects Proxy-Authenticate header of the response, initializes the internal state (in case of digest authentication) and adds required information to the given http::Request.
void updateProxyAuthInfo(http::Request & request)Updates internal state (in case of digest authentication) and replaces proxy authentication information in the request accordingly.
std::string _usernamestd::string _password| Return | Name | Description |
|---|---|---|
Authenticator | Deleted constructor. |
Authenticator(const Authenticator &) = deleteDeleted constructor.