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()
23  {
24  }
25 
26  virtual void setRequest(HttpRequest* request) = 0;
27 
28  virtual void setResponse(HttpResponse* response)
29  {
30  }
31 };
32 
33 class HttpBasicAuth : public AuthAdapter
34 {
35 public:
36  HttpBasicAuth(const String& username, const String& password) : username(username), password(password)
37  {
38  }
39 
40  void setRequest(HttpRequest* request) override;
41 
42 private:
43  String username;
44  String password;
45 };
46 
48 {
49 public:
50  HttpDigestAuth(const String& username, const String& password) : username(username), password(password)
51  {
52  }
53 
54  void setRequest(HttpRequest* request) override
55  {
56  this->request = request;
57  }
58 
59  void setResponse(HttpResponse* response) override;
60 
61 private:
62  String username;
63  String password;
64  HttpRequest* request = nullptr;
65 };
Definition: HttpRequestAuth.h:20
virtual void setRequest(HttpRequest *request)=0
virtual void setResponse(HttpResponse *response)
Definition: HttpRequestAuth.h:28
virtual ~AuthAdapter()
Definition: HttpRequestAuth.h:22
Definition: HttpRequestAuth.h:34
void setRequest(HttpRequest *request) override
HttpBasicAuth(const String &username, const String &password)
Definition: HttpRequestAuth.h:36
Definition: HttpRequestAuth.h:48
void setResponse(HttpResponse *response) override
HttpDigestAuth(const String &username, const String &password)
Definition: HttpRequestAuth.h:50
void setRequest(HttpRequest *request) override
Definition: HttpRequestAuth.h:54
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:137