| 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 #include "net/http/http_auth_handler_digest.h" | 5 #include "net/http/http_auth_handler_digest.h" |
| 6 | 6 |
| 7 #include "base/logging.h" | 7 #include "base/logging.h" |
| 8 #include "base/md5.h" | 8 #include "base/md5.h" |
| 9 #include "base/rand_util.h" | 9 #include "base/rand_util.h" |
| 10 #include "base/string_util.h" | 10 #include "base/string_util.h" |
| (...skipping 154 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 165 const std::string& method, | 165 const std::string& method, |
| 166 const std::string& path, | 166 const std::string& path, |
| 167 const std::string& username, | 167 const std::string& username, |
| 168 const std::string& password, | 168 const std::string& password, |
| 169 const std::string& cnonce, | 169 const std::string& cnonce, |
| 170 int nonce_count) const { | 170 int nonce_count) const { |
| 171 // the nonce-count is an 8 digit hex string. | 171 // the nonce-count is an 8 digit hex string. |
| 172 std::string nc = StringPrintf("%08x", nonce_count); | 172 std::string nc = StringPrintf("%08x", nonce_count); |
| 173 | 173 |
| 174 std::string authorization = std::string("Digest username=") + | 174 std::string authorization = std::string("Digest username=") + |
| 175 HttpUtil::Quote(username); | 175 HttpUtil::Quote(username); |
| 176 authorization += ", realm=" + HttpUtil::Quote(realm_); | 176 authorization += ", realm=" + HttpUtil::Quote(realm_); |
| 177 authorization += ", nonce=" + HttpUtil::Quote(nonce_); | 177 authorization += ", nonce=" + HttpUtil::Quote(nonce_); |
| 178 authorization += ", uri=" + HttpUtil::Quote(path); | 178 authorization += ", uri=" + HttpUtil::Quote(path); |
| 179 | 179 |
| 180 if (algorithm_ != ALGORITHM_UNSPECIFIED) { | 180 if (algorithm_ != ALGORITHM_UNSPECIFIED) { |
| 181 authorization += ", algorithm=" + AlgorithmToString(algorithm_); | 181 authorization += ", algorithm=" + AlgorithmToString(algorithm_); |
| 182 } | 182 } |
| 183 std::string response = AssembleResponseDigest(method, path, username, | 183 std::string response = AssembleResponseDigest(method, path, username, |
| 184 password, cnonce, nc); | 184 password, cnonce, nc); |
| 185 // No need to call HttpUtil::Quote() as the response digest cannot contain | 185 // No need to call HttpUtil::Quote() as the response digest cannot contain |
| (...skipping 123 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 309 // TODO(cbentzel): Move towards model of parsing in the factory | 309 // TODO(cbentzel): Move towards model of parsing in the factory |
| 310 // method and only constructing when valid. | 310 // method and only constructing when valid. |
| 311 scoped_refptr<HttpAuthHandler> tmp_handler(new HttpAuthHandlerDigest()); | 311 scoped_refptr<HttpAuthHandler> tmp_handler(new HttpAuthHandlerDigest()); |
| 312 if (!tmp_handler->InitFromChallenge(challenge, target, origin)) | 312 if (!tmp_handler->InitFromChallenge(challenge, target, origin)) |
| 313 return ERR_INVALID_RESPONSE; | 313 return ERR_INVALID_RESPONSE; |
| 314 handler->swap(tmp_handler); | 314 handler->swap(tmp_handler); |
| 315 return OK; | 315 return OK; |
| 316 } | 316 } |
| 317 | 317 |
| 318 } // namespace net | 318 } // namespace net |
| OLD | NEW |