| 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 <string> | 7 #include <string> |
| 8 | 8 |
| 9 #include "base/logging.h" | 9 #include "base/logging.h" |
| 10 #include "base/md5.h" | 10 #include "base/md5.h" |
| 11 #include "base/rand_util.h" | 11 #include "base/rand_util.h" |
| 12 #include "base/string_util.h" | 12 #include "base/string_util.h" |
| 13 #include "base/stringprintf.h" |
| 13 #include "base/utf_string_conversions.h" | 14 #include "base/utf_string_conversions.h" |
| 14 #include "net/base/net_errors.h" | 15 #include "net/base/net_errors.h" |
| 15 #include "net/base/net_util.h" | 16 #include "net/base/net_util.h" |
| 16 #include "net/http/http_auth.h" | 17 #include "net/http/http_auth.h" |
| 17 #include "net/http/http_request_info.h" | 18 #include "net/http/http_request_info.h" |
| 18 #include "net/http/http_util.h" | 19 #include "net/http/http_util.h" |
| 19 | 20 |
| 20 // TODO(eroman): support qop=auth-int | 21 // TODO(eroman): support qop=auth-int |
| 21 | 22 |
| 22 namespace net { | 23 namespace net { |
| (...skipping 140 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 163 } | 164 } |
| 164 | 165 |
| 165 std::string HttpAuthHandlerDigest::AssembleCredentials( | 166 std::string HttpAuthHandlerDigest::AssembleCredentials( |
| 166 const std::string& method, | 167 const std::string& method, |
| 167 const std::string& path, | 168 const std::string& path, |
| 168 const string16& username, | 169 const string16& username, |
| 169 const string16& password, | 170 const string16& password, |
| 170 const std::string& cnonce, | 171 const std::string& cnonce, |
| 171 int nonce_count) const { | 172 int nonce_count) const { |
| 172 // the nonce-count is an 8 digit hex string. | 173 // the nonce-count is an 8 digit hex string. |
| 173 std::string nc = StringPrintf("%08x", nonce_count); | 174 std::string nc = base::StringPrintf("%08x", nonce_count); |
| 174 | 175 |
| 175 // TODO(eroman): is this the right encoding? | 176 // TODO(eroman): is this the right encoding? |
| 176 std::string authorization = (std::string("Digest username=") + | 177 std::string authorization = (std::string("Digest username=") + |
| 177 HttpUtil::Quote(UTF16ToUTF8(username))); | 178 HttpUtil::Quote(UTF16ToUTF8(username))); |
| 178 authorization += ", realm=" + HttpUtil::Quote(realm_); | 179 authorization += ", realm=" + HttpUtil::Quote(realm_); |
| 179 authorization += ", nonce=" + HttpUtil::Quote(nonce_); | 180 authorization += ", nonce=" + HttpUtil::Quote(nonce_); |
| 180 authorization += ", uri=" + HttpUtil::Quote(path); | 181 authorization += ", uri=" + HttpUtil::Quote(path); |
| 181 | 182 |
| 182 if (algorithm_ != ALGORITHM_UNSPECIFIED) { | 183 if (algorithm_ != ALGORITHM_UNSPECIFIED) { |
| 183 authorization += ", algorithm=" + AlgorithmToString(algorithm_); | 184 authorization += ", algorithm=" + AlgorithmToString(algorithm_); |
| (...skipping 158 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 342 // method and only constructing when valid. | 343 // method and only constructing when valid. |
| 343 scoped_ptr<HttpAuthHandler> tmp_handler( | 344 scoped_ptr<HttpAuthHandler> tmp_handler( |
| 344 new HttpAuthHandlerDigest(digest_nonce_count)); | 345 new HttpAuthHandlerDigest(digest_nonce_count)); |
| 345 if (!tmp_handler->InitFromChallenge(challenge, target, origin, net_log)) | 346 if (!tmp_handler->InitFromChallenge(challenge, target, origin, net_log)) |
| 346 return ERR_INVALID_RESPONSE; | 347 return ERR_INVALID_RESPONSE; |
| 347 handler->swap(tmp_handler); | 348 handler->swap(tmp_handler); |
| 348 return OK; | 349 return OK; |
| 349 } | 350 } |
| 350 | 351 |
| 351 } // namespace net | 352 } // namespace net |
| OLD | NEW |