http_digest.h 1.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647
  1. #pragma once
  2. #include "httpheader.h"
  3. #include <string>
  4. #include <util/system/compat.h>
  5. #include <library/cpp/http/misc/httpcodes.h>
  6. class httpDigestHandler {
  7. private:
  8. const char* User_;
  9. const char* Password_;
  10. char* Nonce_;
  11. int NonceCount_;
  12. char* HeaderInstruction_;
  13. void clear();
  14. void digestCalcHA1(const THttpAuthHeader& hd,
  15. char* outSessionKey,
  16. const std::string& outCNonce);
  17. void digestCalcResponse(const THttpAuthHeader& hd,
  18. const char* method,
  19. const char* path,
  20. const char* nonceCount,
  21. char* outResponse,
  22. const std::string& outCNonce);
  23. public:
  24. httpDigestHandler();
  25. ~httpDigestHandler();
  26. void setAuthorization(const char* user,
  27. const char* password);
  28. bool processHeader(const THttpAuthHeader* header,
  29. const char* path,
  30. const char* method,
  31. const char* cnonce = nullptr);
  32. bool empty() const {
  33. return (!User_);
  34. }
  35. const char* getHeaderInstruction() const;
  36. };