| 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 "net/http/http_util.h" | 8 #include "net/http/http_util.h" |
| 9 | 9 |
| 10 template <class T> class scoped_refptr; | 10 template <class T> class scoped_refptr; |
| (...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 68 | 68 |
| 69 // Get the name of the header where the credentials go | 69 // Get the name of the header where the credentials go |
| 70 // (either Authorization or Proxy-Authorization). | 70 // (either Authorization or Proxy-Authorization). |
| 71 static std::string GetAuthorizationHeaderName(Target target); | 71 static std::string GetAuthorizationHeaderName(Target target); |
| 72 | 72 |
| 73 // Create a handler to generate credentials for the challenge, and pass | 73 // Create a handler to generate credentials for the challenge, and pass |
| 74 // it back in |*handler|. If the challenge is unsupported or invalid | 74 // it back in |*handler|. If the challenge is unsupported or invalid |
| 75 // |*handler| is set to NULL. | 75 // |*handler| is set to NULL. |
| 76 static void CreateAuthHandler(const std::string& challenge, | 76 static void CreateAuthHandler(const std::string& challenge, |
| 77 Target target, | 77 Target target, |
| 78 const GURL& origin, |
| 78 scoped_refptr<HttpAuthHandler>* handler); | 79 scoped_refptr<HttpAuthHandler>* handler); |
| 79 | 80 |
| 80 // Iterate through the challenge headers, and pick the best one that | 81 // Iterate through the challenge headers, and pick the best one that |
| 81 // we support. Obtains the implementation class for handling the challenge, | 82 // we support. Obtains the implementation class for handling the challenge, |
| 82 // and passes it back in |*handler|. If the existing handler in |*handler| | 83 // and passes it back in |*handler|. If the existing handler in |*handler| |
| 83 // should continue to be used (such as for the NTLM authentication scheme), | 84 // should continue to be used (such as for the NTLM authentication scheme), |
| 84 // |*handler| is unchanged. If no supported challenge was found, |*handler| | 85 // |*handler| is unchanged. If no supported challenge was found, |*handler| |
| 85 // is set to NULL. | 86 // is set to NULL. |
| 86 // | 87 // |
| 88 // |origin| is used by the NTLM authentication scheme to construct the |
| 89 // service principal name. It is ignored by other schemes. |
| 90 // |
| 87 // TODO(wtc): Continuing to use the existing handler in |*handler| (for | 91 // TODO(wtc): Continuing to use the existing handler in |*handler| (for |
| 88 // NTLM) is new behavior. Rename ChooseBestChallenge to fully encompass | 92 // NTLM) is new behavior. Rename ChooseBestChallenge to fully encompass |
| 89 // what it does now. | 93 // what it does now. |
| 90 static void ChooseBestChallenge(const HttpResponseHeaders* headers, | 94 static void ChooseBestChallenge(const HttpResponseHeaders* headers, |
| 91 Target target, | 95 Target target, |
| 96 const GURL& origin, |
| 92 scoped_refptr<HttpAuthHandler>* handler); | 97 scoped_refptr<HttpAuthHandler>* handler); |
| 93 | 98 |
| 94 // ChallengeTokenizer breaks up a challenge string into the the auth scheme | 99 // ChallengeTokenizer breaks up a challenge string into the the auth scheme |
| 95 // and parameter list, according to RFC 2617 Sec 1.2: | 100 // and parameter list, according to RFC 2617 Sec 1.2: |
| 96 // challenge = auth-scheme 1*SP 1#auth-param | 101 // challenge = auth-scheme 1*SP 1#auth-param |
| 97 // | 102 // |
| 98 // Check valid() after each iteration step in case it was malformed. | 103 // Check valid() after each iteration step in case it was malformed. |
| 99 // Also note that value() will give whatever is to the right of the equals | 104 // Also note that value() will give whatever is to the right of the equals |
| 100 // sign, quotemarks and all. Use unquoted_value() to get the logical value. | 105 // sign, quotemarks and all. Use unquoted_value() to get the logical value. |
| 101 class ChallengeTokenizer { | 106 class ChallengeTokenizer { |
| (...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 158 std::string::const_iterator value_begin_; | 163 std::string::const_iterator value_begin_; |
| 159 std::string::const_iterator value_end_; | 164 std::string::const_iterator value_end_; |
| 160 | 165 |
| 161 bool value_is_quoted_; | 166 bool value_is_quoted_; |
| 162 }; | 167 }; |
| 163 }; | 168 }; |
| 164 | 169 |
| 165 } // namespace net | 170 } // namespace net |
| 166 | 171 |
| 167 #endif // NET_HTTP_HTTP_AUTH_H_ | 172 #endif // NET_HTTP_HTTP_AUTH_H_ |
| OLD | NEW |