Home
HTTP module

Authenticator

Maintains HTTP Basic or Digest authentication state for outbound requests.

Authenticator

#include <icy/http/authenticator.h>
class Authenticator

Defined in src/http/include/icy/http/authenticator.h:32

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.

List of all members

NameKindOwner
AuthenticatorfunctionDeclared here
AuthenticatorfunctionDeclared here
~AuthenticatorfunctionDeclared here
fromUserInfofunctionDeclared here
fromURIfunctionDeclared here
setUsernamefunctionDeclared here
usernamefunctionDeclared here
setPasswordfunctionDeclared here
passwordfunctionDeclared here
authenticatefunctionDeclared here
updateAuthInfofunctionDeclared here
proxyAuthenticatefunctionDeclared here
updateProxyAuthInfofunctionDeclared here
_usernamevariableDeclared here
_passwordvariableDeclared here
AuthenticatorfunctionDeclared here
operator=functionDeclared here

Public Methods

ReturnNameDescription
AuthenticatorCreates an empty authenticator.
AuthenticatorCreates an authenticator with the given username and password.
~AuthenticatorDestroys the authenticator.
voidfromUserInfoParses username:password std::string and sets username and password of the credentials object. Throws SyntaxException on invalid user information.
voidfromURIExtracts 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.
voidsetUsernameSets the username.
const std::string &username constReturns the username.
voidsetPasswordSets the password.
const std::string &password constReturns the password.
voidauthenticateInspects WWW-Authenticate header of the response, initializes the internal state (in case of digest authentication) and adds required information to the given http::Request.
voidupdateAuthInfoUpdates internal state (in case of digest authentication) and replaces authentication information in the request accordingly.
voidproxyAuthenticateInspects Proxy-Authenticate header of the response, initializes the internal state (in case of digest authentication) and adds required information to the given http::Request.
voidupdateProxyAuthInfoUpdates internal state (in case of digest authentication) and replaces proxy authentication information in the request accordingly.

Authenticator

Authenticator()

Defined in src/http/include/icy/http/authenticator.h:36

Creates an empty authenticator.


Authenticator

Authenticator(const std::string & username, const std::string & password)

Defined in src/http/include/icy/http/authenticator.h:39

Creates an authenticator with the given username and password.


~Authenticator

~Authenticator()

Defined in src/http/include/icy/http/authenticator.h:42

Destroys the authenticator.


fromUserInfo

void fromUserInfo(std::string_view userInfo)

Defined in src/http/include/icy/http/authenticator.h:47

Parses username:password std::string and sets username and password of the credentials object. Throws SyntaxException on invalid user information.


fromURI

void fromURI(const http::URL & uri)

Defined in src/http/include/icy/http/authenticator.h:52

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.


setUsername

void setUsername(const std::string & username)

Defined in src/http/include/icy/http/authenticator.h:55

Sets the username.


username

const

const std::string & username() const

Defined in src/http/include/icy/http/authenticator.h:58

Returns the username.


setPassword

void setPassword(const std::string & password)

Defined in src/http/include/icy/http/authenticator.h:61

Sets the password.


password

const

const std::string & password() const

Defined in src/http/include/icy/http/authenticator.h:64

Returns the password.


authenticate

void authenticate(http::Request & request, const http::Response & response)

Defined in src/http/include/icy/http/authenticator.h:69

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.


updateAuthInfo

void updateAuthInfo(http::Request & request)

Defined in src/http/include/icy/http/authenticator.h:73

Updates internal state (in case of digest authentication) and replaces authentication information in the request accordingly.


proxyAuthenticate

void proxyAuthenticate(http::Request & request, const http::Response & response)

Defined in src/http/include/icy/http/authenticator.h:78

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.


updateProxyAuthInfo

void updateProxyAuthInfo(http::Request & request)

Defined in src/http/include/icy/http/authenticator.h:83

Updates internal state (in case of digest authentication) and replaces proxy authentication information in the request accordingly.

Private Attributes

ReturnNameDescription
std::string_username
std::string_password

_username

std::string _username

Defined in src/http/include/icy/http/authenticator.h:89


_password

std::string _password

Defined in src/http/include/icy/http/authenticator.h:90

Private Methods

ReturnNameDescription
AuthenticatorDeleted constructor.

Authenticator

Authenticator(const Authenticator &) = delete

Defined in src/http/include/icy/http/authenticator.h:86

Deleted constructor.