| OLD | NEW |
| 1 // Copyright (c) 2006-2008 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2006-2008 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_H_ | 5 #ifndef NET_HTTP_HTTP_AUTH_H_ |
| 6 #define NET_HTTP_HTTP_AUTH_H_ | 6 #define NET_HTTP_HTTP_AUTH_H_ |
| 7 | 7 |
| 8 #include "base/ref_counted.h" | 8 #include "base/ref_counted.h" |
| 9 #include "net/http/http_util.h" | 9 #include "net/http/http_util.h" |
| 10 | 10 |
| (...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 46 IDENT_SRC_EXTERNAL, | 46 IDENT_SRC_EXTERNAL, |
| 47 }; | 47 }; |
| 48 | 48 |
| 49 // Helper structure used by HttpNetworkTransaction to track | 49 // Helper structure used by HttpNetworkTransaction to track |
| 50 // the current identity being used for authorization. | 50 // the current identity being used for authorization. |
| 51 struct Identity { | 51 struct Identity { |
| 52 Identity() : source(IDENT_SRC_NONE), invalid(true) { } | 52 Identity() : source(IDENT_SRC_NONE), invalid(true) { } |
| 53 | 53 |
| 54 IdentitySource source; | 54 IdentitySource source; |
| 55 bool invalid; | 55 bool invalid; |
| 56 // TODO(wtc): |username| and |password| should be string16. |
| 56 std::wstring username; | 57 std::wstring username; |
| 57 std::wstring password; | 58 std::wstring password; |
| 58 }; | 59 }; |
| 59 | 60 |
| 60 // Get the name of the header containing the auth challenge | 61 // Get the name of the header containing the auth challenge |
| 61 // (either WWW-Authenticate or Proxy-Authenticate). | 62 // (either WWW-Authenticate or Proxy-Authenticate). |
| 62 static std::string GetChallengeHeaderName(Target target); | 63 static std::string GetChallengeHeaderName(Target target); |
| 63 | 64 |
| 64 // Get the name of the header where the credentials go | 65 // Get the name of the header where the credentials go |
| 65 // (either Authorization or Proxy-Authorization). | 66 // (either Authorization or Proxy-Authorization). |
| 66 static std::string GetAuthorizationHeaderName(Target target); | 67 static std::string GetAuthorizationHeaderName(Target target); |
| 67 | 68 |
| 68 // Create a handler to generate credentials for the challenge, and pass | 69 // Create a handler to generate credentials for the challenge, and pass |
| 69 // it back in |*handler|. If the challenge is unsupported or invalid | 70 // it back in |*handler|. If the challenge is unsupported or invalid |
| 70 // |*handler| is set to NULL. | 71 // |*handler| is set to NULL. |
| 71 static void CreateAuthHandler(const std::string& challenge, | 72 static void CreateAuthHandler(const std::string& challenge, |
| 72 Target target, | 73 Target target, |
| 73 scoped_refptr<HttpAuthHandler>* handler); | 74 scoped_refptr<HttpAuthHandler>* handler); |
| 74 | 75 |
| 75 // Iterate through the challenge headers, and pick the best one that | 76 // Iterate through the challenge headers, and pick the best one that |
| 76 // we support. Obtains the implementation class for handling the challenge, | 77 // we support. Obtains the implementation class for handling the challenge, |
| 77 // and passes it back in |*handler|. If no supported challenge was found | 78 // and passes it back in |*handler|. If the existing handler in |*handler| |
| 78 // |*handler| is set to NULL. | 79 // should continue to be used (such as for the NTLM authentication scheme), |
| 80 // |*handler| is unchanged. If no supported challenge was found, |*handler| |
| 81 // is set to NULL. |
| 82 // |
| 83 // TODO(wtc): Continuing to use the existing handler in |*handler| (for |
| 84 // NTLM) is new behavior. Rename ChooseBestChallenge to fully encompass |
| 85 // what it does now. |
| 79 static void ChooseBestChallenge(const HttpResponseHeaders* headers, | 86 static void ChooseBestChallenge(const HttpResponseHeaders* headers, |
| 80 Target target, | 87 Target target, |
| 81 scoped_refptr<HttpAuthHandler>* handler); | 88 scoped_refptr<HttpAuthHandler>* handler); |
| 82 | 89 |
| 83 // ChallengeTokenizer breaks up a challenge string into the the auth scheme | 90 // ChallengeTokenizer breaks up a challenge string into the the auth scheme |
| 84 // and parameter list, according to RFC 2617 Sec 1.2: | 91 // and parameter list, according to RFC 2617 Sec 1.2: |
| 85 // challenge = auth-scheme 1*SP 1#auth-param | 92 // challenge = auth-scheme 1*SP 1#auth-param |
| 86 // | 93 // |
| 87 // Check valid() after each iteration step in case it was malformed. | 94 // Check valid() after each iteration step in case it was malformed. |
| 88 // Also note that value() will give whatever is to the right of the equals | 95 // Also note that value() will give whatever is to the right of the equals |
| (...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 147 std::string::const_iterator value_begin_; | 154 std::string::const_iterator value_begin_; |
| 148 std::string::const_iterator value_end_; | 155 std::string::const_iterator value_end_; |
| 149 | 156 |
| 150 bool value_is_quoted_; | 157 bool value_is_quoted_; |
| 151 }; | 158 }; |
| 152 }; | 159 }; |
| 153 | 160 |
| 154 } // namespace net | 161 } // namespace net |
| 155 | 162 |
| 156 #endif // NET_HTTP_HTTP_AUTH_H_ | 163 #endif // NET_HTTP_HTTP_AUTH_H_ |
| OLD | NEW |