Torc  0.1
torchttpservernonce.h
Go to the documentation of this file.
1 #ifndef TORCHTTPSERVERNONCE_H
2 #define TORCHTTPSERVERNONCE_H
3 
4 //Qt
5 #include <QMutex>
6 #include <QDateTime>
7 
8 // Torc
9 #include "torclocaldefs.h"
10 #include "torchttprequest.h"
11 
12 #define DEFAULT_NONCE_LIFETIME_SECONDS 10 // expire 10 seconds after issue or last use
13 #define DEFAULT_NONCE_LIFETIME_REQUESTS 0 // unlimited uses
14 
16 {
17  public:
18  static void ProcessDigestAuth (TorcHTTPRequest &Request, bool Check = false);
19 
21  explicit TorcHTTPServerNonce(const QDateTime &Time);
22  ~TorcHTTPServerNonce() = default;
23 
24  QString GetOpaque(void) const;
25  bool UseOnce(quint64 ClientCount, const QDateTime &Current);
26  bool IsOutOfDate(const QDateTime &Current);
27 
28  private:
29  bool m_expired;
30  QString m_opaque;
31  quint64 m_startMs;
32  QDateTime m_startTime;
33  quint64 m_useCount;
34  quint64 m_lifetimeInSeconds;
35  quint64 m_lifetimeInRequests;
36 };
37 
38 #endif // TORCHTTPSERVERNONCE_H
A class to encapsulate an incoming HTTP request.
~TorcHTTPServerNonce()=default
bool IsOutOfDate(const QDateTime &Current)
static void ProcessDigestAuth(TorcHTTPRequest &Request, bool Check=false)
A server nonce for Digest Access Authentication.
QString GetOpaque(void) const
bool UseOnce(quint64 ClientCount, const QDateTime &Current)