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

Side by Side Diff: chrome/browser/chromeos/login/signed_settings.cc

Issue 6151001: [Chrome OS] Canonicalize username before checking against whitelist (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 9 years, 11 months 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 | Annotate | Revision Log
« no previous file with comments | « no previous file | no next file » | 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) 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 "chrome/browser/chromeos/login/signed_settings.h" 5 #include "chrome/browser/chromeos/login/signed_settings.h"
6 6
7 #include <string> 7 #include <string>
8 #include <vector> 8 #include <vector>
9 9
10 #include "base/ref_counted.h" 10 #include "base/ref_counted.h"
11 #include "base/stringprintf.h" 11 #include "base/stringprintf.h"
12 #include "chrome/browser/browser_process.h" 12 #include "chrome/browser/browser_process.h"
13 #include "chrome/browser/browser_thread.h" 13 #include "chrome/browser/browser_thread.h"
14 #include "chrome/browser/chromeos/cros/cros_library.h" 14 #include "chrome/browser/chromeos/cros/cros_library.h"
15 #include "chrome/browser/chromeos/cros/login_library.h" 15 #include "chrome/browser/chromeos/cros/login_library.h"
16 #include "chrome/browser/chromeos/login/authenticator.h"
16 #include "chrome/browser/chromeos/login/ownership_service.h" 17 #include "chrome/browser/chromeos/login/ownership_service.h"
17 #include "chrome/browser/chromeos/login/signed_settings_temp_storage.h" 18 #include "chrome/browser/chromeos/login/signed_settings_temp_storage.h"
18 19
19 namespace chromeos { 20 namespace chromeos {
20 21
21 SignedSettings::SignedSettings() 22 SignedSettings::SignedSettings()
22 : service_(OwnershipService::GetSharedInstance()) { 23 : service_(OwnershipService::GetSharedInstance()) {
23 } 24 }
24 25
25 SignedSettings::~SignedSettings() {} 26 SignedSettings::~SignedSettings() {}
(...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after
101 std::string name_; 102 std::string name_;
102 std::string value_; 103 std::string value_;
103 SignedSettings::Delegate<std::string>* d_; 104 SignedSettings::Delegate<std::string>* d_;
104 }; 105 };
105 106
106 // static 107 // static
107 SignedSettings* SignedSettings::CreateCheckWhitelistOp( 108 SignedSettings* SignedSettings::CreateCheckWhitelistOp(
108 const std::string& email, 109 const std::string& email,
109 SignedSettings::Delegate<bool>* d) { 110 SignedSettings::Delegate<bool>* d) {
110 DCHECK(d != NULL); 111 DCHECK(d != NULL);
111 return new CheckWhitelistOp(email, d); 112 return new CheckWhitelistOp(Authenticator::Canonicalize(email), d);
112 } 113 }
113 114
114 // static 115 // static
115 SignedSettings* SignedSettings::CreateWhitelistOp( 116 SignedSettings* SignedSettings::CreateWhitelistOp(
116 const std::string& email, 117 const std::string& email,
117 bool add_to_whitelist, 118 bool add_to_whitelist,
118 SignedSettings::Delegate<bool>* d) { 119 SignedSettings::Delegate<bool>* d) {
119 DCHECK(d != NULL); 120 DCHECK(d != NULL);
120 return new WhitelistOp(email, add_to_whitelist, d); 121 return new WhitelistOp(Authenticator::Canonicalize(email),
122 add_to_whitelist,
123 d);
121 } 124 }
122 125
123 // static 126 // static
124 SignedSettings* SignedSettings::CreateStorePropertyOp( 127 SignedSettings* SignedSettings::CreateStorePropertyOp(
125 const std::string& name, 128 const std::string& name,
126 const std::string& value, 129 const std::string& value,
127 SignedSettings::Delegate<bool>* d) { 130 SignedSettings::Delegate<bool>* d) {
128 DCHECK(d != NULL); 131 DCHECK(d != NULL);
129 return new StorePropertyOp(name, value, d); 132 return new StorePropertyOp(name, value, d);
130 } 133 }
(...skipping 10 matching lines...) Expand all
141 SignedSettings::Delegate<bool>* d) 144 SignedSettings::Delegate<bool>* d)
142 : email_(email), 145 : email_(email),
143 d_(d) { 146 d_(d) {
144 } 147 }
145 148
146 CheckWhitelistOp::~CheckWhitelistOp() {} 149 CheckWhitelistOp::~CheckWhitelistOp() {}
147 150
148 void CheckWhitelistOp::Execute() { 151 void CheckWhitelistOp::Execute() {
149 CHECK(chromeos::CrosLibrary::Get()->EnsureLoaded()); 152 CHECK(chromeos::CrosLibrary::Get()->EnsureLoaded());
150 std::vector<uint8> sig; 153 std::vector<uint8> sig;
154 LOG(WARNING) << "HEY! " << email_;
xiyuan 2011/01/06 23:28:27 nit: remove this debug LOG?
151 if (!CrosLibrary::Get()->GetLoginLibrary()->CheckWhitelist(email_, &sig)) { 155 if (!CrosLibrary::Get()->GetLoginLibrary()->CheckWhitelist(email_, &sig)) {
152 d_->OnSettingsOpCompleted(NOT_FOUND, false); 156 d_->OnSettingsOpCompleted(NOT_FOUND, false);
153 return; 157 return;
154 } 158 }
155 // Posts a task to the FILE thread to verify |sig|. 159 // Posts a task to the FILE thread to verify |sig|.
156 service_->StartVerifyAttempt(email_, sig, this); 160 service_->StartVerifyAttempt(email_, sig, this);
157 } 161 }
158 162
159 void CheckWhitelistOp::OnKeyOpComplete( 163 void CheckWhitelistOp::OnKeyOpComplete(
160 const OwnerManager::KeyOpCode return_code, 164 const OwnerManager::KeyOpCode return_code,
161 const std::vector<uint8>& payload) { 165 const std::vector<uint8>& payload) {
162 // Ensure we're on the UI thread, due to the need to send DBus traffic. 166 // Ensure we're on the UI thread, due to the need to send DBus traffic.
163 if (!BrowserThread::CurrentlyOn(BrowserThread::UI)) { 167 if (!BrowserThread::CurrentlyOn(BrowserThread::UI)) {
164 BrowserThread::PostTask( 168 BrowserThread::PostTask(
165 BrowserThread::UI, FROM_HERE, 169 BrowserThread::UI, FROM_HERE,
166 NewRunnableMethod(this, 170 NewRunnableMethod(this,
167 &CheckWhitelistOp::OnKeyOpComplete, 171 &CheckWhitelistOp::OnKeyOpComplete,
168 return_code, payload)); 172 return_code, payload));
169 return; 173 return;
170 } 174 }
171 if (return_code == OwnerManager::SUCCESS) { 175 if (return_code == OwnerManager::SUCCESS) {
176 VLOG(2) << "Whitelist check was successful.";
172 d_->OnSettingsOpCompleted(SUCCESS, true); 177 d_->OnSettingsOpCompleted(SUCCESS, true);
173 } else { 178 } else {
179 VLOG(2) << "Whitelist check failed.";
174 d_->OnSettingsOpCompleted(SignedSettings::MapKeyOpCode(return_code), false); 180 d_->OnSettingsOpCompleted(SignedSettings::MapKeyOpCode(return_code), false);
175 } 181 }
176 } 182 }
177 183
178 WhitelistOp::WhitelistOp(const std::string& email, 184 WhitelistOp::WhitelistOp(const std::string& email,
179 bool add_to_whitelist, 185 bool add_to_whitelist,
180 SignedSettings::Delegate<bool>* d) 186 SignedSettings::Delegate<bool>* d)
181 : email_(email), 187 : email_(email),
182 add_to_whitelist_(add_to_whitelist), 188 add_to_whitelist_(add_to_whitelist),
183 d_(d) { 189 d_(d) {
(...skipping 156 matching lines...) Expand 10 before | Expand all | Expand 10 after
340 } 346 }
341 // Now, sure we're on the UI thread. 347 // Now, sure we're on the UI thread.
342 if (return_code == OwnerManager::SUCCESS) 348 if (return_code == OwnerManager::SUCCESS)
343 d_->OnSettingsOpCompleted(SUCCESS, value_); 349 d_->OnSettingsOpCompleted(SUCCESS, value_);
344 else 350 else
345 d_->OnSettingsOpCompleted(SignedSettings::MapKeyOpCode(return_code), 351 d_->OnSettingsOpCompleted(SignedSettings::MapKeyOpCode(return_code),
346 std::string()); 352 std::string());
347 } 353 }
348 354
349 } // namespace chromeos 355 } // namespace chromeos
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698