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 "chrome/browser/chromeos/attestation/platform_verification_flow.h" | 5 #include "chrome/browser/chromeos/attestation/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/message_loop/message_loop.h" | 9 #include "base/message_loop/message_loop.h" |
10 #include "base/metrics/histogram.h" | 10 #include "base/metrics/histogram.h" |
(...skipping 123 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
134 callback(callback) {} | 134 callback(callback) {} |
135 | 135 |
136 PlatformVerificationFlow::ChallengeContext::~ChallengeContext() {} | 136 PlatformVerificationFlow::ChallengeContext::~ChallengeContext() {} |
137 | 137 |
138 PlatformVerificationFlow::PlatformVerificationFlow() | 138 PlatformVerificationFlow::PlatformVerificationFlow() |
139 : attestation_flow_(NULL), | 139 : attestation_flow_(NULL), |
140 async_caller_(cryptohome::AsyncMethodCaller::GetInstance()), | 140 async_caller_(cryptohome::AsyncMethodCaller::GetInstance()), |
141 cryptohome_client_(DBusThreadManager::Get()->GetCryptohomeClient()), | 141 cryptohome_client_(DBusThreadManager::Get()->GetCryptohomeClient()), |
142 delegate_(NULL), | 142 delegate_(NULL), |
143 timeout_delay_(base::TimeDelta::FromSeconds(kTimeoutInSeconds)) { | 143 timeout_delay_(base::TimeDelta::FromSeconds(kTimeoutInSeconds)) { |
144 DCHECK(content::BrowserThread::CurrentlyOn(content::BrowserThread::UI)); | 144 DCHECK_CURRENTLY_ON(content::BrowserThread::UI); |
145 scoped_ptr<ServerProxy> attestation_ca_client(new AttestationCAClient()); | 145 scoped_ptr<ServerProxy> attestation_ca_client(new AttestationCAClient()); |
146 default_attestation_flow_.reset(new AttestationFlow( | 146 default_attestation_flow_.reset(new AttestationFlow( |
147 async_caller_, | 147 async_caller_, |
148 cryptohome_client_, | 148 cryptohome_client_, |
149 attestation_ca_client.Pass())); | 149 attestation_ca_client.Pass())); |
150 attestation_flow_ = default_attestation_flow_.get(); | 150 attestation_flow_ = default_attestation_flow_.get(); |
151 default_delegate_.reset(new DefaultDelegate()); | 151 default_delegate_.reset(new DefaultDelegate()); |
152 delegate_ = default_delegate_.get(); | 152 delegate_ = default_delegate_.get(); |
153 } | 153 } |
154 | 154 |
155 PlatformVerificationFlow::PlatformVerificationFlow( | 155 PlatformVerificationFlow::PlatformVerificationFlow( |
156 AttestationFlow* attestation_flow, | 156 AttestationFlow* attestation_flow, |
157 cryptohome::AsyncMethodCaller* async_caller, | 157 cryptohome::AsyncMethodCaller* async_caller, |
158 CryptohomeClient* cryptohome_client, | 158 CryptohomeClient* cryptohome_client, |
159 Delegate* delegate) | 159 Delegate* delegate) |
160 : attestation_flow_(attestation_flow), | 160 : attestation_flow_(attestation_flow), |
161 async_caller_(async_caller), | 161 async_caller_(async_caller), |
162 cryptohome_client_(cryptohome_client), | 162 cryptohome_client_(cryptohome_client), |
163 delegate_(delegate), | 163 delegate_(delegate), |
164 timeout_delay_(base::TimeDelta::FromSeconds(kTimeoutInSeconds)) { | 164 timeout_delay_(base::TimeDelta::FromSeconds(kTimeoutInSeconds)) { |
165 DCHECK(content::BrowserThread::CurrentlyOn(content::BrowserThread::UI)); | 165 DCHECK_CURRENTLY_ON(content::BrowserThread::UI); |
166 if (!delegate_) { | 166 if (!delegate_) { |
167 default_delegate_.reset(new DefaultDelegate()); | 167 default_delegate_.reset(new DefaultDelegate()); |
168 delegate_ = default_delegate_.get(); | 168 delegate_ = default_delegate_.get(); |
169 } | 169 } |
170 } | 170 } |
171 | 171 |
172 PlatformVerificationFlow::~PlatformVerificationFlow() { | 172 PlatformVerificationFlow::~PlatformVerificationFlow() { |
173 } | 173 } |
174 | 174 |
175 void PlatformVerificationFlow::ChallengePlatformKey( | 175 void PlatformVerificationFlow::ChallengePlatformKey( |
176 content::WebContents* web_contents, | 176 content::WebContents* web_contents, |
177 const std::string& service_id, | 177 const std::string& service_id, |
178 const std::string& challenge, | 178 const std::string& challenge, |
179 const ChallengeCallback& callback) { | 179 const ChallengeCallback& callback) { |
180 DCHECK(content::BrowserThread::CurrentlyOn(content::BrowserThread::UI)); | 180 DCHECK_CURRENTLY_ON(content::BrowserThread::UI); |
181 | 181 |
182 if (!delegate_->GetURL(web_contents).is_valid()) { | 182 if (!delegate_->GetURL(web_contents).is_valid()) { |
183 LOG(WARNING) << "PlatformVerificationFlow: Invalid URL."; | 183 LOG(WARNING) << "PlatformVerificationFlow: Invalid URL."; |
184 ReportError(callback, INTERNAL_ERROR); | 184 ReportError(callback, INTERNAL_ERROR); |
185 return; | 185 return; |
186 } | 186 } |
187 | 187 |
188 // Note: The following two checks are also checked in GetPermissionStatus. | 188 // Note: The following two checks are also checked in GetPermissionStatus. |
189 // Checking them here explicitly to report the correct error type. | 189 // Checking them here explicitly to report the correct error type. |
190 | 190 |
(...skipping 168 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
359 certificate.length())); | 359 certificate.length())); |
360 if (!x509.get() || x509->valid_expiry().is_null()) { | 360 if (!x509.get() || x509->valid_expiry().is_null()) { |
361 LOG(WARNING) << "Failed to parse certificate, cannot check expiry."; | 361 LOG(WARNING) << "Failed to parse certificate, cannot check expiry."; |
362 return false; | 362 return false; |
363 } | 363 } |
364 return (base::Time::Now() > x509->valid_expiry()); | 364 return (base::Time::Now() > x509->valid_expiry()); |
365 } | 365 } |
366 | 366 |
367 } // namespace attestation | 367 } // namespace attestation |
368 } // namespace chromeos | 368 } // namespace chromeos |
OLD | NEW |