Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(228)

Side by Side Diff: net/http/http_auth_handler_basic.cc

Issue 86913002: Make base::Base64Encode() return void (Closed) Base URL: http://git.chromium.org/chromium/src.git@master
Patch Set: One more chromeos-specific fix. Created 7 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « net/http/http_auth_gssapi_posix.cc ('k') | net/http/http_auth_handler_ntlm.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 #include "net/http/http_auth_handler_basic.h" 5 #include "net/http/http_auth_handler_basic.h"
6 6
7 #include <string> 7 #include <string>
8 8
9 #include "base/base64.h" 9 #include "base/base64.h"
10 #include "base/i18n/icu_string_conversions.h" 10 #include "base/i18n/icu_string_conversions.h"
(...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after
84 HttpAuth::AUTHORIZATION_RESULT_DIFFERENT_REALM: 84 HttpAuth::AUTHORIZATION_RESULT_DIFFERENT_REALM:
85 HttpAuth::AUTHORIZATION_RESULT_REJECT; 85 HttpAuth::AUTHORIZATION_RESULT_REJECT;
86 } 86 }
87 87
88 int HttpAuthHandlerBasic::GenerateAuthTokenImpl( 88 int HttpAuthHandlerBasic::GenerateAuthTokenImpl(
89 const AuthCredentials* credentials, const HttpRequestInfo*, 89 const AuthCredentials* credentials, const HttpRequestInfo*,
90 const CompletionCallback&, std::string* auth_token) { 90 const CompletionCallback&, std::string* auth_token) {
91 DCHECK(credentials); 91 DCHECK(credentials);
92 // TODO(eroman): is this the right encoding of username/password? 92 // TODO(eroman): is this the right encoding of username/password?
93 std::string base64_username_password; 93 std::string base64_username_password;
94 if (!base::Base64Encode( 94 base::Base64Encode(UTF16ToUTF8(credentials->username()) + ":" +
95 UTF16ToUTF8(credentials->username()) + ":" + 95 UTF16ToUTF8(credentials->password()),
96 UTF16ToUTF8(credentials->password()), 96 &base64_username_password);
97 &base64_username_password)) {
98 LOG(ERROR) << "Unexpected problem Base64 encoding.";
99 return ERR_UNEXPECTED;
100 }
101 *auth_token = "Basic " + base64_username_password; 97 *auth_token = "Basic " + base64_username_password;
102 return OK; 98 return OK;
103 } 99 }
104 100
105 HttpAuthHandlerBasic::Factory::Factory() { 101 HttpAuthHandlerBasic::Factory::Factory() {
106 } 102 }
107 103
108 HttpAuthHandlerBasic::Factory::~Factory() { 104 HttpAuthHandlerBasic::Factory::~Factory() {
109 } 105 }
110 106
111 int HttpAuthHandlerBasic::Factory::CreateAuthHandler( 107 int HttpAuthHandlerBasic::Factory::CreateAuthHandler(
112 HttpAuth::ChallengeTokenizer* challenge, 108 HttpAuth::ChallengeTokenizer* challenge,
113 HttpAuth::Target target, 109 HttpAuth::Target target,
114 const GURL& origin, 110 const GURL& origin,
115 CreateReason reason, 111 CreateReason reason,
116 int digest_nonce_count, 112 int digest_nonce_count,
117 const BoundNetLog& net_log, 113 const BoundNetLog& net_log,
118 scoped_ptr<HttpAuthHandler>* handler) { 114 scoped_ptr<HttpAuthHandler>* handler) {
119 // TODO(cbentzel): Move towards model of parsing in the factory 115 // TODO(cbentzel): Move towards model of parsing in the factory
120 // method and only constructing when valid. 116 // method and only constructing when valid.
121 scoped_ptr<HttpAuthHandler> tmp_handler(new HttpAuthHandlerBasic()); 117 scoped_ptr<HttpAuthHandler> tmp_handler(new HttpAuthHandlerBasic());
122 if (!tmp_handler->InitFromChallenge(challenge, target, origin, net_log)) 118 if (!tmp_handler->InitFromChallenge(challenge, target, origin, net_log))
123 return ERR_INVALID_RESPONSE; 119 return ERR_INVALID_RESPONSE;
124 handler->swap(tmp_handler); 120 handler->swap(tmp_handler);
125 return OK; 121 return OK;
126 } 122 }
127 123
128 } // namespace net 124 } // namespace net
OLDNEW
« no previous file with comments | « net/http/http_auth_gssapi_posix.cc ('k') | net/http/http_auth_handler_ntlm.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698