Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 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 | 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 <string> | 8 #include <string> |
| 9 | 9 |
| 10 #include "build/build_config.h" | 10 #include "build/build_config.h" |
| 11 #include "net/base/address_list.h" | 11 #include "net/base/address_list.h" |
| 12 #include "net/base/net_export.h" | 12 #include "net/base/net_export.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_ANDROID) |
| 17 #include "net/android/http_auth_negotiate_android.h" | |
| 18 #elif defined(OS_WIN) | |
| 17 #include "net/http/http_auth_sspi_win.h" | 19 #include "net/http/http_auth_sspi_win.h" |
| 18 #elif defined(OS_POSIX) | 20 #elif defined(OS_POSIX) |
| 19 #include "net/http/http_auth_gssapi_posix.h" | 21 #include "net/http/http_auth_gssapi_posix.h" |
| 20 #endif | 22 #endif |
| 21 | 23 |
| 22 namespace net { | 24 namespace net { |
| 23 | 25 |
| 24 class HostResolver; | 26 class HostResolver; |
| 25 class SingleRequestHostResolver; | 27 class SingleRequestHostResolver; |
| 26 class URLSecurityManager; | 28 class URLSecurityManager; |
| 27 | 29 |
| 28 // Handler for WWW-Authenticate: Negotiate protocol. | 30 // Handler for WWW-Authenticate: Negotiate protocol. |
| 29 // | 31 // |
| 30 // See http://tools.ietf.org/html/rfc4178 and http://tools.ietf.org/html/rfc4559 | 32 // See http://tools.ietf.org/html/rfc4178 and http://tools.ietf.org/html/rfc4559 |
| 31 // for more information about the protocol. | 33 // for more information about the protocol. |
| 32 | 34 |
| 33 class NET_EXPORT_PRIVATE HttpAuthHandlerNegotiate : public HttpAuthHandler { | 35 class NET_EXPORT_PRIVATE HttpAuthHandlerNegotiate : public HttpAuthHandler { |
| 34 public: | 36 public: |
| 35 #if defined(OS_WIN) | 37 #if defined(OS_ANDROID) |
| 38 typedef net::android::HttpAuthNegotiateAndroid AuthSystem; | |
|
cbentzel
2015/06/30 12:53:55
I think this is likely too ugly, but you could con
aberent
2015/07/02 21:13:36
Done. I don't really like it (since it isn't a lib
cbentzel
2015/07/08 18:27:11
I don't have one either, other than renaming the v
aberent
2015/07/09 13:38:45
Done.
| |
| 39 #elif defined(OS_WIN) | |
| 36 typedef SSPILibrary AuthLibrary; | 40 typedef SSPILibrary AuthLibrary; |
| 37 typedef HttpAuthSSPI AuthSystem; | 41 typedef HttpAuthSSPI AuthSystem; |
| 38 #elif defined(OS_POSIX) | 42 #elif defined(OS_POSIX) |
| 39 typedef GSSAPILibrary AuthLibrary; | 43 typedef GSSAPILibrary AuthLibrary; |
| 40 typedef HttpAuthGSSAPI AuthSystem; | 44 typedef HttpAuthGSSAPI AuthSystem; |
| 41 #endif | 45 #endif |
| 42 | 46 |
| 43 class NET_EXPORT_PRIVATE Factory : public HttpAuthHandlerFactory { | 47 class NET_EXPORT_PRIVATE Factory : public HttpAuthHandlerFactory { |
| 44 public: | 48 public: |
| 45 Factory(); | 49 Factory(); |
| (...skipping 10 matching lines...) Expand all Loading... | |
| 56 | 60 |
| 57 // |use_port()| and |set_use_port()| get/set whether the auth handlers | 61 // |use_port()| and |set_use_port()| get/set whether the auth handlers |
| 58 // generated by this factory should include the port number of the server | 62 // generated by this factory should include the port number of the server |
| 59 // they are authenticating to when constructing a Kerberos SPN. The default | 63 // they are authenticating to when constructing a Kerberos SPN. The default |
| 60 // value is false. | 64 // value is false. |
| 61 bool use_port() const { return use_port_; } | 65 bool use_port() const { return use_port_; } |
| 62 void set_use_port(bool use_port) { use_port_ = use_port; } | 66 void set_use_port(bool use_port) { use_port_ = use_port; } |
| 63 | 67 |
| 64 void set_host_resolver(HostResolver* host_resolver); | 68 void set_host_resolver(HostResolver* host_resolver); |
| 65 | 69 |
| 70 #if defined(OS_ANDROID) | |
| 71 // Sets the account type to use for authentication | |
| 72 void set_account_type(const std::string& account_type) { | |
| 73 account_type_ = account_type; | |
| 74 } | |
| 75 #endif | |
| 76 #if defined(OS_WIN) || (defined(OS_POSIX) && !defined(OS_ANDROID)) | |
|
cbentzel
2015/06/30 12:53:55
This is repeated three times in this header - wond
aberent
2015/07/02 21:13:36
Removed because of the change on line 38.
| |
| 66 // Sets the system library to use, thereby assuming ownership of | 77 // Sets the system library to use, thereby assuming ownership of |
| 67 // |auth_library|. | 78 // |auth_library|. |
| 68 void set_library(AuthLibrary* auth_library) { | 79 void set_library(AuthLibrary* auth_library) { |
| 69 auth_library_.reset(auth_library); | 80 auth_library_.reset(auth_library); |
| 70 } | 81 } |
| 82 #endif | |
| 71 | 83 |
| 72 int CreateAuthHandler(HttpAuthChallengeTokenizer* challenge, | 84 int CreateAuthHandler(HttpAuthChallengeTokenizer* challenge, |
| 73 HttpAuth::Target target, | 85 HttpAuth::Target target, |
| 74 const GURL& origin, | 86 const GURL& origin, |
| 75 CreateReason reason, | 87 CreateReason reason, |
| 76 int digest_nonce_count, | 88 int digest_nonce_count, |
| 77 const BoundNetLog& net_log, | 89 const BoundNetLog& net_log, |
| 78 scoped_ptr<HttpAuthHandler>* handler) override; | 90 scoped_ptr<HttpAuthHandler>* handler) override; |
| 79 | 91 |
| 80 private: | 92 private: |
| 81 bool disable_cname_lookup_; | 93 bool disable_cname_lookup_; |
| 82 bool use_port_; | 94 bool use_port_; |
| 83 HostResolver* resolver_; | 95 HostResolver* resolver_; |
| 84 #if defined(OS_WIN) | 96 #if defined(OS_WIN) |
| 85 ULONG max_token_length_; | 97 ULONG max_token_length_; |
| 86 bool first_creation_; | 98 bool first_creation_; |
| 87 #endif | 99 #endif |
| 88 bool is_unsupported_; | 100 bool is_unsupported_; |
| 101 #if defined(OS_ANDROID) | |
| 102 std::string account_type_; | |
| 103 #endif | |
| 104 #if defined(OS_WIN) || (defined(OS_POSIX) && !defined(OS_ANDROID)) | |
| 89 scoped_ptr<AuthLibrary> auth_library_; | 105 scoped_ptr<AuthLibrary> auth_library_; |
| 106 #endif | |
| 90 }; | 107 }; |
| 91 | 108 |
| 92 HttpAuthHandlerNegotiate(AuthLibrary* sspi_library, | 109 HttpAuthHandlerNegotiate( |
| 110 #if defined(OS_ANDROID) | |
| 111 std::string account_type, | |
| 112 #endif | |
| 113 #if defined(OS_WIN) || (defined(OS_POSIX) && !defined(OS_ANDROID)) | |
| 114 AuthLibrary* sspi_library, | |
| 115 #endif | |
| 93 #if defined(OS_WIN) | 116 #if defined(OS_WIN) |
| 94 ULONG max_token_length, | 117 ULONG max_token_length, |
| 95 #endif | 118 #endif |
| 96 URLSecurityManager* url_security_manager, | 119 URLSecurityManager* url_security_manager, |
| 97 HostResolver* host_resolver, | 120 HostResolver* host_resolver, |
| 98 bool disable_cname_lookup, | 121 bool disable_cname_lookup, |
| 99 bool use_port); | 122 bool use_port); |
| 100 | 123 |
| 101 ~HttpAuthHandlerNegotiate() override; | 124 ~HttpAuthHandlerNegotiate() override; |
| 102 | 125 |
| 103 // These are public for unit tests | 126 // These are public for unit tests |
| 104 std::string CreateSPN(const AddressList& address_list, const GURL& orign); | 127 std::string CreateSPN(const AddressList& address_list, const GURL& orign); |
| 105 const std::string& spn() const { return spn_; } | 128 const std::string& spn() const { return spn_; } |
| 106 | 129 |
| 107 // HttpAuthHandler: | 130 // HttpAuthHandler: |
| 108 HttpAuth::AuthorizationResult HandleAnotherChallenge( | 131 HttpAuth::AuthorizationResult HandleAnotherChallenge( |
| 109 HttpAuthChallengeTokenizer* challenge) override; | 132 HttpAuthChallengeTokenizer* challenge) override; |
| (...skipping 21 matching lines...) Expand all Loading... | |
| 131 void OnIOComplete(int result); | 154 void OnIOComplete(int result); |
| 132 void DoCallback(int result); | 155 void DoCallback(int result); |
| 133 int DoLoop(int result); | 156 int DoLoop(int result); |
| 134 | 157 |
| 135 int DoResolveCanonicalName(); | 158 int DoResolveCanonicalName(); |
| 136 int DoResolveCanonicalNameComplete(int rv); | 159 int DoResolveCanonicalNameComplete(int rv); |
| 137 int DoGenerateAuthToken(); | 160 int DoGenerateAuthToken(); |
| 138 int DoGenerateAuthTokenComplete(int rv); | 161 int DoGenerateAuthTokenComplete(int rv); |
| 139 bool CanDelegate() const; | 162 bool CanDelegate() const; |
| 140 | 163 |
| 164 bool ParseFirstChallenge(HttpAuthChallengeTokenizer* tok); | |
|
cbentzel
2015/06/30 12:53:55
ParseFirstChallenge is not defined. Should this be
aberent
2015/07/02 21:13:36
Done.
| |
| 165 | |
| 141 AuthSystem auth_system_; | 166 AuthSystem auth_system_; |
| 142 bool disable_cname_lookup_; | 167 bool disable_cname_lookup_; |
| 143 bool use_port_; | 168 bool use_port_; |
| 144 HostResolver* const resolver_; | 169 HostResolver* const resolver_; |
| 145 | 170 |
| 146 // Members which are needed for DNS lookup + SPN. | 171 // Members which are needed for DNS lookup + SPN. |
| 147 AddressList address_list_; | 172 AddressList address_list_; |
| 148 scoped_ptr<SingleRequestHostResolver> single_resolve_; | 173 scoped_ptr<SingleRequestHostResolver> single_resolve_; |
| 149 | 174 |
| 150 // Things which should be consistent after first call to GenerateAuthToken. | 175 // Things which should be consistent after first call to GenerateAuthToken. |
| 151 bool already_called_; | 176 bool already_called_; |
| 152 bool has_credentials_; | 177 bool has_credentials_; |
| 153 AuthCredentials credentials_; | 178 AuthCredentials credentials_; |
| 154 std::string spn_; | 179 std::string spn_; |
| 155 | 180 |
| 156 // Things which vary each round. | 181 // Things which vary each round. |
| 157 CompletionCallback callback_; | 182 CompletionCallback callback_; |
| 158 std::string* auth_token_; | 183 std::string* auth_token_; |
| 159 | 184 |
| 160 State next_state_; | 185 State next_state_; |
| 161 | 186 |
| 162 const URLSecurityManager* url_security_manager_; | 187 const URLSecurityManager* url_security_manager_; |
| 163 }; | 188 }; |
| 164 | 189 |
| 165 } // namespace net | 190 } // namespace net |
| 166 | 191 |
| 167 #endif // NET_HTTP_HTTP_AUTH_HANDLER_NEGOTIATE_H_ | 192 #endif // NET_HTTP_HTTP_AUTH_HANDLER_NEGOTIATE_H_ |
| OLD | NEW |