| OLD | NEW |
| 1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #ifndef NET_HTTP_HTTP_AUTH_HANDLER_NEGOTIATE_H_ | 5 #ifndef NET_HTTP_HTTP_AUTH_HANDLER_NEGOTIATE_H_ |
| 6 #define NET_HTTP_HTTP_AUTH_HANDLER_NEGOTIATE_H_ | 6 #define NET_HTTP_HTTP_AUTH_HANDLER_NEGOTIATE_H_ |
| 7 | 7 |
| 8 #include "build/build_config.h" | 8 #include "build/build_config.h" |
| 9 | 9 |
| 10 #include <string> | 10 #include <string> |
| 11 | 11 |
| 12 #include "net/base/address_list.h" | 12 #include "net/base/address_list.h" |
| 13 #include "net/http/http_auth_handler.h" | 13 #include "net/http/http_auth_handler.h" |
| 14 #include "net/http/http_auth_handler_factory.h" | 14 #include "net/http/http_auth_handler_factory.h" |
| 15 | 15 |
| 16 #if defined(OS_WIN) | 16 #if defined(OS_WIN) |
| 17 #include "net/http/http_auth_sspi_win.h" | 17 #include "net/http/http_auth_sspi_win.h" |
| 18 #endif | 18 #endif |
| 19 | 19 |
| 20 #if defined(OS_POSIX) |
| 21 #include "net/http/http_auth_gssapi_posix.h" |
| 22 #endif |
| 23 |
| 24 namespace gssapi { |
| 25 struct gss_buffer_desc_struct; |
| 26 } // namespace gssapi |
| 27 |
| 20 namespace net { | 28 namespace net { |
| 21 | 29 |
| 22 class SingleRequestHostResolver; | 30 class SingleRequestHostResolver; |
| 23 class URLSecurityManager; | 31 class URLSecurityManager; |
| 24 | 32 |
| 25 // Handler for WWW-Authenticate: Negotiate protocol. | 33 // Handler for WWW-Authenticate: Negotiate protocol. |
| 26 // | 34 // |
| 27 // See http://tools.ietf.org/html/rfc4178 and http://tools.ietf.org/html/rfc4559 | 35 // See http://tools.ietf.org/html/rfc4178 and http://tools.ietf.org/html/rfc4559 |
| 28 // for more information about the protocol. | 36 // for more information about the protocol. |
| 29 | 37 |
| (...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 61 // Set the SSPILibrary to use. Typically the only callers which need to | 69 // Set the SSPILibrary to use. Typically the only callers which need to |
| 62 // use this are unit tests which pass in a mocked-out version of the | 70 // use this are unit tests which pass in a mocked-out version of the |
| 63 // SSPI library. | 71 // SSPI library. |
| 64 // The caller is responsible for managing the lifetime of |*sspi_library|, | 72 // The caller is responsible for managing the lifetime of |*sspi_library|, |
| 65 // and the lifetime must exceed that of this Factory object and all | 73 // and the lifetime must exceed that of this Factory object and all |
| 66 // HttpAuthHandler's that this Factory object creates. | 74 // HttpAuthHandler's that this Factory object creates. |
| 67 void set_sspi_library(SSPILibrary* sspi_library) { | 75 void set_sspi_library(SSPILibrary* sspi_library) { |
| 68 sspi_library_ = sspi_library; | 76 sspi_library_ = sspi_library; |
| 69 } | 77 } |
| 70 #endif // defined(OS_WIN) | 78 #endif // defined(OS_WIN) |
| 79 #if defined(OS_POSIX) |
| 80 // Set the GSSAPILibrary to use. Typically the only callers which need to |
| 81 // use this are unit tests which pass in a mocked-out version of the |
| 82 // GSSAPI library. |
| 83 // The caller is responsible for managing the lifetime of |*gssapi_library|, |
| 84 // and the lifetime must exceed that of this Factory object and all |
| 85 // HttpAuthHandler's that this Factory object creates. |
| 86 void set_gssapi_library(GSSAPILibrary* gssapi_library) { |
| 87 gssapi_library_ = gssapi_library; |
| 88 } |
| 89 #endif // defined(OS_WIN) |
| 71 private: | 90 private: |
| 72 bool disable_cname_lookup_; | 91 bool disable_cname_lookup_; |
| 73 bool use_port_; | 92 bool use_port_; |
| 74 #if defined(OS_WIN) | 93 #if defined(OS_WIN) |
| 75 ULONG max_token_length_; | 94 ULONG max_token_length_; |
| 76 bool first_creation_; | 95 bool first_creation_; |
| 77 bool is_unsupported_; | 96 bool is_unsupported_; |
| 78 SSPILibrary* sspi_library_; | 97 SSPILibrary* sspi_library_; |
| 79 #endif // defined(OS_WIN) | 98 #endif // defined(OS_WIN) |
| 99 #if defined(OS_POSIX) |
| 100 GSSAPILibrary* gssapi_library_; |
| 101 #endif // defined(OS_POSIX) |
| 80 }; | 102 }; |
| 81 | 103 |
| 82 #if defined(OS_WIN) | 104 #if defined(OS_WIN) |
| 83 HttpAuthHandlerNegotiate(SSPILibrary* sspi_library, ULONG max_token_length, | 105 HttpAuthHandlerNegotiate(SSPILibrary* sspi_library, |
| 106 ULONG max_token_length, |
| 84 URLSecurityManager* url_security_manager, | 107 URLSecurityManager* url_security_manager, |
| 85 bool disable_cname_lookup, bool use_port); | 108 bool disable_cname_lookup, |
| 109 bool use_port); |
| 86 #else | 110 #else |
| 87 explicit HttpAuthHandlerNegotiate(URLSecurityManager* url_security_manager); | 111 HttpAuthHandlerNegotiate(GSSAPILibrary* library, |
| 112 URLSecurityManager* url_security_manager, |
| 113 bool disable_cname_lookup, |
| 114 bool use_port); |
| 88 #endif | 115 #endif |
| 89 | 116 |
| 90 virtual bool NeedsIdentity(); | 117 virtual bool NeedsIdentity(); |
| 91 | 118 |
| 92 virtual bool IsFinalRound(); | 119 virtual bool IsFinalRound(); |
| 93 | 120 |
| 94 virtual bool AllowsDefaultCredentials(); | 121 virtual bool AllowsDefaultCredentials(); |
| 95 | 122 |
| 96 virtual bool NeedsCanonicalName(); | 123 virtual bool NeedsCanonicalName(); |
| 97 | 124 |
| 98 virtual int GenerateAuthToken(const std::wstring& username, | 125 virtual int GenerateAuthToken(const std::wstring& username, |
| 99 const std::wstring& password, | 126 const std::wstring& password, |
| 100 const HttpRequestInfo* request, | 127 const HttpRequestInfo* request, |
| 101 const ProxyInfo* proxy, | 128 const ProxyInfo* proxy, |
| 102 std::string* auth_token); | 129 std::string* auth_token); |
| 103 | 130 |
| 104 virtual int GenerateDefaultAuthToken(const HttpRequestInfo* request, | 131 virtual int GenerateDefaultAuthToken(const HttpRequestInfo* request, |
| 105 const ProxyInfo* proxy, | 132 const ProxyInfo* proxy, |
| 106 std::string* auth_token); | 133 std::string* auth_token); |
| 107 | 134 |
| 108 virtual int ResolveCanonicalName(HostResolver* host_resolver, | 135 virtual int ResolveCanonicalName(HostResolver* host_resolver, |
| 109 CompletionCallback* callback, | 136 CompletionCallback* callback, |
| 110 const BoundNetLog& net_log); | 137 const BoundNetLog& net_log); |
| 111 | 138 |
| 112 #if defined(OS_WIN) | |
| 113 // These are public for unit tests | 139 // These are public for unit tests |
| 114 std::wstring CreateSPN(const AddressList& address_list, const GURL& orign); | 140 std::wstring CreateSPN(const AddressList& address_list, const GURL& orign); |
| 115 const std::wstring& spn() const { return spn_; } | 141 const std::wstring& spn() const { return spn_; } |
| 116 #endif // defined(OS_WIN) | |
| 117 | 142 |
| 118 protected: | 143 protected: |
| 119 virtual bool Init(HttpAuth::ChallengeTokenizer* challenge); | 144 virtual bool Init(HttpAuth::ChallengeTokenizer* challenge); |
| 120 | 145 |
| 121 private: | 146 private: |
| 122 ~HttpAuthHandlerNegotiate(); | 147 ~HttpAuthHandlerNegotiate(); |
| 123 | 148 |
| 149 void OnResolveCanonicalName(int result); |
| 150 |
| 124 #if defined(OS_WIN) | 151 #if defined(OS_WIN) |
| 125 void OnResolveCanonicalName(int result); | |
| 126 HttpAuthSSPI auth_sspi_; | 152 HttpAuthSSPI auth_sspi_; |
| 127 AddressList address_list_; | 153 #endif |
| 154 |
| 155 #if defined(OS_POSIX) |
| 156 HttpAuthGSSAPI auth_gssapi_; |
| 157 gssapi::gss_buffer_desc_struct* current_token_; |
| 158 #endif // defined(OS_POSIX) |
| 159 |
| 128 scoped_ptr<SingleRequestHostResolver> single_resolve_; | 160 scoped_ptr<SingleRequestHostResolver> single_resolve_; |
| 129 CompletionCallback* user_callback_; | 161 CompletionCallback* user_callback_; |
| 130 CompletionCallbackImpl<HttpAuthHandlerNegotiate> resolve_cname_callback_; | 162 CompletionCallbackImpl<HttpAuthHandlerNegotiate> resolve_cname_callback_; |
| 163 |
| 131 bool disable_cname_lookup_; | 164 bool disable_cname_lookup_; |
| 132 bool use_port_; | 165 bool use_port_; |
| 133 std::wstring spn_; | 166 std::wstring spn_; |
| 134 #endif | 167 AddressList address_list_; |
| 135 | 168 |
| 136 URLSecurityManager* url_security_manager_; | 169 URLSecurityManager* url_security_manager_; |
| 137 }; | 170 }; |
| 138 | 171 |
| 139 } // namespace net | 172 } // namespace net |
| 140 | 173 |
| 141 #endif // NET_HTTP_HTTP_AUTH_HANDLER_NEGOTIATE_H_ | 174 #endif // NET_HTTP_HTTP_AUTH_HANDLER_NEGOTIATE_H_ |
| OLD | NEW |