HTTP module

BasicAuthenticator

Encodes and decodes HTTP Basic authentication credentials.

BasicAuthenticator

#include <icy/http/authenticator.h>

Encodes and decodes HTTP Basic authentication credentials.

Public Methods

ReturnNameDescription
BasicAuthenticatorCreates an empty basic authenticator.
BasicAuthenticatorCreates a basic authenticator with the given username and password.
BasicAuthenticator explicitExtracts basic authentication credentials from the given request.
BasicAuthenticator explicitParses a raw Basic authentication payload string. The value can be extracted from a request via [Request::getCredentials()](icy-http-Request.html#getcredentials).
~BasicAuthenticatorDestroys the basic authenticator.
voidsetUsernameSets the username.
const std::string &username constReturns the username.
voidsetPasswordSets the password.
const std::string &password constReturns the password.
voidauthenticate constAdds authentication information to the given http::Request.
voidproxyAuthenticate constAdds proxy authentication information to the given http::Request.

BasicAuthenticator

BasicAuthenticator()

Creates an empty basic authenticator.


BasicAuthenticator

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

Creates a basic authenticator with the given username and password.


BasicAuthenticator

explicit

explicit BasicAuthenticator(const http::Request & request)

Extracts basic authentication credentials from the given request.

Throws a NotAuthenticatedException if the request does not contain basic authentication information.


BasicAuthenticator

explicit

explicit BasicAuthenticator(const std::string & authInfo)

Parses a raw Basic authentication payload string. The value can be extracted from a request via [Request::getCredentials()](icy-http-Request.html#getcredentials).


~BasicAuthenticator

~BasicAuthenticator()

Destroys the basic authenticator.


setUsername

void setUsername(const std::string & username)

Sets the username.


username

const

const std::string & username() const

Returns the username.


setPassword

void setPassword(const std::string & password)

Sets the password.


password

const

const std::string & password() const

Returns the password.


authenticate

const

void authenticate(http::Request & request) const

Adds authentication information to the given http::Request.


proxyAuthenticate

const

void proxyAuthenticate(http::Request & request) const

Adds proxy authentication information to the given http::Request.

Protected Methods

ReturnNameDescription
voidparseAuthInfoExtracts username and password from Basic authentication info by base64-decoding authInfo and splitting the resulting std::string at the ':' delimiter.

parseAuthInfo

void parseAuthInfo(std::string_view authInfo)

Extracts username and password from Basic authentication info by base64-decoding authInfo and splitting the resulting std::string at the ':' delimiter.

Private Attributes

ReturnNameDescription
std::string_username
std::string_password

_username

std::string _username

_password

std::string _password

Private Methods

ReturnNameDescription
BasicAuthenticatorDeleted constructor.

BasicAuthenticator

BasicAuthenticator(const BasicAuthenticator &) = delete

Deleted constructor.