HttpRequestAuth.h
Go to the documentation of this file.
1 /****
2  * Sming Framework Project - Open Source framework for high efficiency native ESP8266 development.
3  * Created 2015 by Skurydin Alexey
4  * http://github.com/SmingHub/Sming
5  * All files of the Sming Core are provided under the LGPL v3 license.
6  *
7  * HttpRequestAuth.h
8  *
9  * @author: 2017 - Slavey Karadzhov <slav@attachix.com>
10  *
11  ****/
12 
13 #pragma once
14 
15 #include "HttpResponse.h"
16 
17 class HttpRequest;
18 
20 {
21 public:
22  virtual ~AuthAdapter() = default;
23 
24  virtual void setRequest(HttpRequest* request) = 0;
25 
26  virtual void setResponse(HttpResponse*)
27  {
28  }
29 };
30 
31 class HttpBasicAuth : public AuthAdapter
32 {
33 public:
34  HttpBasicAuth(const String& username, const String& password) : username(username), password(password)
35  {
36  }
37 
38  void setRequest(HttpRequest* request) override;
39 
40 private:
41  String username;
42  String password;
43 };
44 
46 {
47 public:
48  HttpDigestAuth(const String& username, const String& password) : username(username), password(password)
49  {
50  }
51 
52  void setRequest(HttpRequest* request) override
53  {
54  this->request = request;
55  }
56 
57  void setResponse(HttpResponse* response) override;
58 
59 private:
60  String username;
61  String password;
62  HttpRequest* request = nullptr;
63 };
Definition: HttpRequestAuth.h:20
virtual void setResponse(HttpResponse *)
Definition: HttpRequestAuth.h:26
virtual void setRequest(HttpRequest *request)=0
virtual ~AuthAdapter()=default
Definition: HttpRequestAuth.h:32
void setRequest(HttpRequest *request) override
HttpBasicAuth(const String &username, const String &password)
Definition: HttpRequestAuth.h:34
Definition: HttpRequestAuth.h:46
void setResponse(HttpResponse *response) override
HttpDigestAuth(const String &username, const String &password)
Definition: HttpRequestAuth.h:48
void setRequest(HttpRequest *request) override
Definition: HttpRequestAuth.h:52
Encapsulates an incoming or outgoing request.
Definition: HttpRequest.h:37
Represents either an incoming or outgoing response to a HTTP request.
Definition: HttpResponse.h:26
The String class.
Definition: WString.h:133