http_auth_handler_basic.h 2.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657
  1. // Copyright (c) 2011 The Chromium Authors. All rights reserved.
  2. // Use of this source code is governed by a BSD-style license that can be
  3. // found in the LICENSE file.
  4. #ifndef NET_HTTP_HTTP_AUTH_HANDLER_BASIC_H_
  5. #define NET_HTTP_HTTP_AUTH_HANDLER_BASIC_H_
  6. #include <memory>
  7. #include <string>
  8. #include "net/base/completion_once_callback.h"
  9. #include "net/base/net_export.h"
  10. #include "net/http/http_auth_handler.h"
  11. #include "net/http/http_auth_handler_factory.h"
  12. namespace net {
  13. // Code for handling http basic authentication.
  14. class NET_EXPORT_PRIVATE HttpAuthHandlerBasic : public HttpAuthHandler {
  15. public:
  16. class NET_EXPORT_PRIVATE Factory : public HttpAuthHandlerFactory {
  17. public:
  18. Factory();
  19. ~Factory() override;
  20. int CreateAuthHandler(HttpAuthChallengeTokenizer* challenge,
  21. HttpAuth::Target target,
  22. const SSLInfo& ssl_info,
  23. const NetworkIsolationKey& network_isolation_key,
  24. const url::SchemeHostPort& scheme_host_port,
  25. CreateReason reason,
  26. int digest_nonce_count,
  27. const NetLogWithSource& net_log,
  28. HostResolver* host_resolver,
  29. std::unique_ptr<HttpAuthHandler>* handler) override;
  30. };
  31. ~HttpAuthHandlerBasic() override = default;
  32. private:
  33. // HttpAuthHandler
  34. bool Init(HttpAuthChallengeTokenizer* challenge,
  35. const SSLInfo& ssl_info,
  36. const NetworkIsolationKey& network_isolation_key) override;
  37. int GenerateAuthTokenImpl(const AuthCredentials* credentials,
  38. const HttpRequestInfo* request,
  39. CompletionOnceCallback callback,
  40. std::string* auth_token) override;
  41. HttpAuth::AuthorizationResult HandleAnotherChallengeImpl(
  42. HttpAuthChallengeTokenizer* challenge) override;
  43. bool ParseChallenge(HttpAuthChallengeTokenizer* challenge);
  44. };
  45. } // namespace net
  46. #endif // NET_HTTP_HTTP_AUTH_HANDLER_BASIC_H_