OLD | NEW |
---|---|
1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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 "platform_verification_flow.h" | 5 #include "platform_verification_flow.h" |
6 | 6 |
7 #include "base/command_line.h" | 7 #include "base/command_line.h" |
8 #include "base/logging.h" | 8 #include "base/logging.h" |
9 #include "base/prefs/pref_service.h" | 9 #include "base/prefs/pref_service.h" |
10 #include "chrome/browser/chromeos/attestation/attestation_ca_client.h" | 10 #include "chrome/browser/chromeos/attestation/attestation_ca_client.h" |
(...skipping 220 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
231 ReportError(callback, USER_REJECTED); | 231 ReportError(callback, USER_REJECTED); |
232 return; | 232 return; |
233 } else if (consent_response == CONSENT_RESPONSE_ALLOW) { | 233 } else if (consent_response == CONSENT_RESPONSE_ALLOW) { |
234 content::RecordAction( | 234 content::RecordAction( |
235 content::UserMetricsAction("PlatformVerificationAccepted")); | 235 content::UserMetricsAction("PlatformVerificationAccepted")); |
236 } | 236 } |
237 } | 237 } |
238 | 238 |
239 // At this point all user interaction is complete and we can proceed with the | 239 // At this point all user interaction is complete and we can proceed with the |
240 // certificate request. | 240 // certificate request. |
241 chromeos::User* user = user_manager_->GetUserByProfile( | |
bartfab (slow)
2013/10/13 16:31:35
#include "chrome/browser/chromeos/login/user.h"
Darren Krahn
2013/10/15 16:49:06
Done.
| |
242 Profile::FromBrowserContext(web_contents->GetBrowserContext())); | |
bartfab (slow)
2013/10/13 16:31:35
#include "content/public/browser/browser_context.h
Darren Krahn
2013/10/15 16:49:06
Done.
| |
243 if (!user) { | |
244 ReportError(callback, INTERNAL_ERROR); | |
245 LOG(ERROR) << "Profile does not map to a valid user."; | |
246 return; | |
247 } | |
241 AttestationFlow::CertificateCallback certificate_callback = base::Bind( | 248 AttestationFlow::CertificateCallback certificate_callback = base::Bind( |
242 &PlatformVerificationFlow::OnCertificateReady, | 249 &PlatformVerificationFlow::OnCertificateReady, |
243 weak_factory_.GetWeakPtr(), | 250 weak_factory_.GetWeakPtr(), |
251 user->email(), | |
244 service_id, | 252 service_id, |
245 challenge, | 253 challenge, |
246 callback); | 254 callback); |
247 attestation_flow_->GetCertificate( | 255 attestation_flow_->GetCertificate( |
248 PROFILE_CONTENT_PROTECTION_CERTIFICATE, | 256 PROFILE_CONTENT_PROTECTION_CERTIFICATE, |
249 user_manager_->GetActiveUser()->email(), | 257 user->email(), |
250 service_id, | 258 service_id, |
251 false, // Don't force a new key. | 259 false, // Don't force a new key. |
252 certificate_callback); | 260 certificate_callback); |
253 } | 261 } |
254 | 262 |
255 void PlatformVerificationFlow::OnCertificateReady( | 263 void PlatformVerificationFlow::OnCertificateReady( |
264 const std::string& user_email, | |
256 const std::string& service_id, | 265 const std::string& service_id, |
257 const std::string& challenge, | 266 const std::string& challenge, |
258 const ChallengeCallback& callback, | 267 const ChallengeCallback& callback, |
259 bool operation_success, | 268 bool operation_success, |
260 const std::string& certificate) { | 269 const std::string& certificate) { |
261 if (!operation_success) { | 270 if (!operation_success) { |
262 LOG(WARNING) << "PlatformVerificationFlow: Failed to certify platform."; | 271 LOG(WARNING) << "PlatformVerificationFlow: Failed to certify platform."; |
263 ReportError(callback, PLATFORM_NOT_VERIFIED); | 272 ReportError(callback, PLATFORM_NOT_VERIFIED); |
264 return; | 273 return; |
265 } | 274 } |
266 cryptohome::AsyncMethodCaller::DataCallback cryptohome_callback = base::Bind( | 275 cryptohome::AsyncMethodCaller::DataCallback cryptohome_callback = base::Bind( |
267 &PlatformVerificationFlow::OnChallengeReady, | 276 &PlatformVerificationFlow::OnChallengeReady, |
268 weak_factory_.GetWeakPtr(), | 277 weak_factory_.GetWeakPtr(), |
269 certificate, | 278 certificate, |
270 challenge, | 279 challenge, |
271 callback); | 280 callback); |
272 std::string key_name = kContentProtectionKeyPrefix; | 281 std::string key_name = kContentProtectionKeyPrefix; |
273 key_name += service_id; | 282 key_name += service_id; |
274 async_caller_->TpmAttestationSignSimpleChallenge(KEY_USER, | 283 async_caller_->TpmAttestationSignSimpleChallenge(KEY_USER, |
284 user_email, | |
275 key_name, | 285 key_name, |
276 challenge, | 286 challenge, |
277 cryptohome_callback); | 287 cryptohome_callback); |
278 } | 288 } |
279 | 289 |
280 void PlatformVerificationFlow::OnChallengeReady( | 290 void PlatformVerificationFlow::OnChallengeReady( |
281 const std::string& certificate, | 291 const std::string& certificate, |
282 const std::string& challenge, | 292 const std::string& challenge, |
283 const ChallengeCallback& callback, | 293 const ChallengeCallback& callback, |
284 bool operation_success, | 294 bool operation_success, |
(...skipping 136 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
421 bool allow_domain) { | 431 bool allow_domain) { |
422 PrefService* pref_service = GetPrefs(web_contents); | 432 PrefService* pref_service = GetPrefs(web_contents); |
423 CHECK(pref_service); | 433 CHECK(pref_service); |
424 DictionaryPrefUpdate updater(pref_service, prefs::kRAConsentDomains); | 434 DictionaryPrefUpdate updater(pref_service, prefs::kRAConsentDomains); |
425 const GURL& url = GetURL(web_contents); | 435 const GURL& url = GetURL(web_contents); |
426 updater->SetBoolean(url.host(), allow_domain); | 436 updater->SetBoolean(url.host(), allow_domain); |
427 } | 437 } |
428 | 438 |
429 } // namespace attestation | 439 } // namespace attestation |
430 } // namespace chromeos | 440 } // namespace chromeos |
OLD | NEW |