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" |
(...skipping 25 matching lines...) Expand all Loading... |
36 typedef SSPILibrary AuthLibrary; | 36 typedef SSPILibrary AuthLibrary; |
37 typedef HttpAuthSSPI AuthSystem; | 37 typedef HttpAuthSSPI AuthSystem; |
38 #elif defined(OS_POSIX) | 38 #elif defined(OS_POSIX) |
39 typedef GSSAPILibrary AuthLibrary; | 39 typedef GSSAPILibrary AuthLibrary; |
40 typedef HttpAuthGSSAPI AuthSystem; | 40 typedef HttpAuthGSSAPI AuthSystem; |
41 #endif | 41 #endif |
42 | 42 |
43 class NET_EXPORT_PRIVATE Factory : public HttpAuthHandlerFactory { | 43 class NET_EXPORT_PRIVATE Factory : public HttpAuthHandlerFactory { |
44 public: | 44 public: |
45 Factory(); | 45 Factory(); |
46 virtual ~Factory(); | 46 ~Factory() override; |
47 | 47 |
48 // |disable_cname_lookup()| and |set_disable_cname_lookup()| get/set whether | 48 // |disable_cname_lookup()| and |set_disable_cname_lookup()| get/set whether |
49 // the auth handlers generated by this factory should skip looking up the | 49 // the auth handlers generated by this factory should skip looking up the |
50 // canonical DNS name of the the host that they are authenticating to when | 50 // canonical DNS name of the the host that they are authenticating to when |
51 // generating the SPN. The default value is false. | 51 // generating the SPN. The default value is false. |
52 bool disable_cname_lookup() const { return disable_cname_lookup_; } | 52 bool disable_cname_lookup() const { return disable_cname_lookup_; } |
53 void set_disable_cname_lookup(bool disable_cname_lookup) { | 53 void set_disable_cname_lookup(bool disable_cname_lookup) { |
54 disable_cname_lookup_ = disable_cname_lookup; | 54 disable_cname_lookup_ = disable_cname_lookup; |
55 } | 55 } |
56 | 56 |
57 // |use_port()| and |set_use_port()| get/set whether the auth handlers | 57 // |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 | 58 // generated by this factory should include the port number of the server |
59 // they are authenticating to when constructing a Kerberos SPN. The default | 59 // they are authenticating to when constructing a Kerberos SPN. The default |
60 // value is false. | 60 // value is false. |
61 bool use_port() const { return use_port_; } | 61 bool use_port() const { return use_port_; } |
62 void set_use_port(bool use_port) { use_port_ = use_port; } | 62 void set_use_port(bool use_port) { use_port_ = use_port; } |
63 | 63 |
64 void set_host_resolver(HostResolver* host_resolver); | 64 void set_host_resolver(HostResolver* host_resolver); |
65 | 65 |
66 // Sets the system library to use, thereby assuming ownership of | 66 // Sets the system library to use, thereby assuming ownership of |
67 // |auth_library|. | 67 // |auth_library|. |
68 void set_library(AuthLibrary* auth_library) { | 68 void set_library(AuthLibrary* auth_library) { |
69 auth_library_.reset(auth_library); | 69 auth_library_.reset(auth_library); |
70 } | 70 } |
71 | 71 |
72 virtual int CreateAuthHandler( | 72 int CreateAuthHandler(HttpAuthChallengeTokenizer* challenge, |
73 HttpAuthChallengeTokenizer* challenge, | 73 HttpAuth::Target target, |
74 HttpAuth::Target target, | 74 const GURL& origin, |
75 const GURL& origin, | 75 CreateReason reason, |
76 CreateReason reason, | 76 int digest_nonce_count, |
77 int digest_nonce_count, | 77 const BoundNetLog& net_log, |
78 const BoundNetLog& net_log, | 78 scoped_ptr<HttpAuthHandler>* handler) override; |
79 scoped_ptr<HttpAuthHandler>* handler) override; | |
80 | 79 |
81 private: | 80 private: |
82 bool disable_cname_lookup_; | 81 bool disable_cname_lookup_; |
83 bool use_port_; | 82 bool use_port_; |
84 HostResolver* resolver_; | 83 HostResolver* resolver_; |
85 #if defined(OS_WIN) | 84 #if defined(OS_WIN) |
86 ULONG max_token_length_; | 85 ULONG max_token_length_; |
87 bool first_creation_; | 86 bool first_creation_; |
88 #endif | 87 #endif |
89 bool is_unsupported_; | 88 bool is_unsupported_; |
90 scoped_ptr<AuthLibrary> auth_library_; | 89 scoped_ptr<AuthLibrary> auth_library_; |
91 }; | 90 }; |
92 | 91 |
93 HttpAuthHandlerNegotiate(AuthLibrary* sspi_library, | 92 HttpAuthHandlerNegotiate(AuthLibrary* sspi_library, |
94 #if defined(OS_WIN) | 93 #if defined(OS_WIN) |
95 ULONG max_token_length, | 94 ULONG max_token_length, |
96 #endif | 95 #endif |
97 URLSecurityManager* url_security_manager, | 96 URLSecurityManager* url_security_manager, |
98 HostResolver* host_resolver, | 97 HostResolver* host_resolver, |
99 bool disable_cname_lookup, | 98 bool disable_cname_lookup, |
100 bool use_port); | 99 bool use_port); |
101 | 100 |
102 virtual ~HttpAuthHandlerNegotiate(); | 101 ~HttpAuthHandlerNegotiate() override; |
103 | 102 |
104 // These are public for unit tests | 103 // These are public for unit tests |
105 std::string CreateSPN(const AddressList& address_list, const GURL& orign); | 104 std::string CreateSPN(const AddressList& address_list, const GURL& orign); |
106 const std::string& spn() const { return spn_; } | 105 const std::string& spn() const { return spn_; } |
107 | 106 |
108 // HttpAuthHandler: | 107 // HttpAuthHandler: |
109 virtual HttpAuth::AuthorizationResult HandleAnotherChallenge( | 108 HttpAuth::AuthorizationResult HandleAnotherChallenge( |
110 HttpAuthChallengeTokenizer* challenge) override; | 109 HttpAuthChallengeTokenizer* challenge) override; |
111 virtual bool NeedsIdentity() override; | 110 bool NeedsIdentity() override; |
112 virtual bool AllowsDefaultCredentials() override; | 111 bool AllowsDefaultCredentials() override; |
113 virtual bool AllowsExplicitCredentials() override; | 112 bool AllowsExplicitCredentials() override; |
114 | 113 |
115 protected: | 114 protected: |
116 virtual bool Init(HttpAuthChallengeTokenizer* challenge) override; | 115 bool Init(HttpAuthChallengeTokenizer* challenge) override; |
117 | 116 |
118 virtual int GenerateAuthTokenImpl(const AuthCredentials* credentials, | 117 int GenerateAuthTokenImpl(const AuthCredentials* credentials, |
119 const HttpRequestInfo* request, | 118 const HttpRequestInfo* request, |
120 const CompletionCallback& callback, | 119 const CompletionCallback& callback, |
121 std::string* auth_token) override; | 120 std::string* auth_token) override; |
122 | 121 |
123 private: | 122 private: |
124 enum State { | 123 enum State { |
125 STATE_RESOLVE_CANONICAL_NAME, | 124 STATE_RESOLVE_CANONICAL_NAME, |
126 STATE_RESOLVE_CANONICAL_NAME_COMPLETE, | 125 STATE_RESOLVE_CANONICAL_NAME_COMPLETE, |
127 STATE_GENERATE_AUTH_TOKEN, | 126 STATE_GENERATE_AUTH_TOKEN, |
128 STATE_GENERATE_AUTH_TOKEN_COMPLETE, | 127 STATE_GENERATE_AUTH_TOKEN_COMPLETE, |
129 STATE_NONE, | 128 STATE_NONE, |
130 }; | 129 }; |
131 | 130 |
(...skipping 27 matching lines...) Expand all Loading... |
159 std::string* auth_token_; | 158 std::string* auth_token_; |
160 | 159 |
161 State next_state_; | 160 State next_state_; |
162 | 161 |
163 const URLSecurityManager* url_security_manager_; | 162 const URLSecurityManager* url_security_manager_; |
164 }; | 163 }; |
165 | 164 |
166 } // namespace net | 165 } // namespace net |
167 | 166 |
168 #endif // NET_HTTP_HTTP_AUTH_HANDLER_NEGOTIATE_H_ | 167 #endif // NET_HTTP_HTTP_AUTH_HANDLER_NEGOTIATE_H_ |
OLD | NEW |