#include <Pt/Http/Authenticator.h>
Client-side authentication. More...
Inherits NonCopyable.
Public Types | |
| typedef std::map< std::string, Credential > | Credentials |
| Credentials for realms. | |
Public Member Functions | |
| Authenticator () | |
| Default Constructor. | |
| ~Authenticator () | |
| Destructor. | |
| void | addAuthentication (Authentication &auth) |
| Adds an authentication method. | |
| void | setCredential (const std::string &realm, const Credential &cred) |
| Set credential for a realm. | |
| bool | authenticate (Request &request, const Reply &reply) |
| Authenticate a request in response to a reply. | |
Authenticator prepares a request after a 401 reply so the client can send it again. It is not the server-side authorizer. Store credentials per realm with setCredential(), then call authenticate() with the rejected request and the 401 reply. The method writes the authentication headers onto the request and returns true when that is possible. It returns false when no credentials are available for the realm, or when the challenge cannot be met.
Basic authentication is registered by default. Other Authentication methods can be added with addAuthentication(). The authenticator does not send the request; the caller sends it again through the client.
The example stores a realm credential and applies it to a request that just received 401.