OLD | NEW |
1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 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/attestation_policy_observer.h" | 5 #include "chrome/browser/chromeos/attestation/attestation_policy_observer.h" |
6 | 6 |
7 #include <string> | 7 #include <string> |
8 | 8 |
9 #include "base/bind.h" | 9 #include "base/bind.h" |
10 #include "chrome/browser/chromeos/attestation/attestation_ca_client.h" | 10 #include "chrome/browser/chromeos/attestation/attestation_ca_client.h" |
(...skipping 125 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
136 } | 136 } |
137 | 137 |
138 // Start a dbus call to check if an Enterprise Machine Key already exists. | 138 // Start a dbus call to check if an Enterprise Machine Key already exists. |
139 base::Closure on_does_exist = | 139 base::Closure on_does_exist = |
140 base::Bind(&AttestationPolicyObserver::GetExistingCertificate, | 140 base::Bind(&AttestationPolicyObserver::GetExistingCertificate, |
141 weak_factory_.GetWeakPtr()); | 141 weak_factory_.GetWeakPtr()); |
142 base::Closure on_does_not_exist = | 142 base::Closure on_does_not_exist = |
143 base::Bind(&AttestationPolicyObserver::GetNewCertificate, | 143 base::Bind(&AttestationPolicyObserver::GetNewCertificate, |
144 weak_factory_.GetWeakPtr()); | 144 weak_factory_.GetWeakPtr()); |
145 cryptohome_client_->TpmAttestationDoesKeyExist( | 145 cryptohome_client_->TpmAttestationDoesKeyExist( |
146 CryptohomeClient::DEVICE_KEY, | 146 DEVICE_KEY, |
147 kEnterpriseMachineKey, | 147 kEnterpriseMachineKey, |
148 base::Bind(DBusBoolRedirectCallback, on_does_exist, on_does_not_exist)); | 148 base::Bind(DBusBoolRedirectCallback, on_does_exist, on_does_not_exist)); |
149 } | 149 } |
150 | 150 |
151 void AttestationPolicyObserver::GetNewCertificate() { | 151 void AttestationPolicyObserver::GetNewCertificate() { |
152 // We can reuse the dbus callback handler logic. | 152 // We can reuse the dbus callback handler logic. |
153 attestation_flow_->GetCertificate( | 153 attestation_flow_->GetCertificate( |
154 kEnterpriseMachineKey, | 154 ENTERPRISE_MACHINE_CERTIFICATE, |
| 155 true, // Force a new key to be generated. |
155 base::Bind(DBusStringCallback, | 156 base::Bind(DBusStringCallback, |
156 base::Bind(&AttestationPolicyObserver::UploadCertificate, | 157 base::Bind(&AttestationPolicyObserver::UploadCertificate, |
157 weak_factory_.GetWeakPtr()), | 158 weak_factory_.GetWeakPtr()), |
158 DBUS_METHOD_CALL_SUCCESS)); | 159 DBUS_METHOD_CALL_SUCCESS)); |
159 } | 160 } |
160 | 161 |
161 void AttestationPolicyObserver::GetExistingCertificate() { | 162 void AttestationPolicyObserver::GetExistingCertificate() { |
162 cryptohome_client_->TpmAttestationGetCertificate( | 163 cryptohome_client_->TpmAttestationGetCertificate( |
163 CryptohomeClient::DEVICE_KEY, | 164 DEVICE_KEY, |
164 kEnterpriseMachineKey, | 165 kEnterpriseMachineKey, |
165 base::Bind(DBusStringCallback, | 166 base::Bind(DBusStringCallback, |
166 base::Bind(&AttestationPolicyObserver::CheckCertificateExpiry, | 167 base::Bind(&AttestationPolicyObserver::CheckCertificateExpiry, |
167 weak_factory_.GetWeakPtr()))); | 168 weak_factory_.GetWeakPtr()))); |
168 } | 169 } |
169 | 170 |
170 void AttestationPolicyObserver::CheckCertificateExpiry( | 171 void AttestationPolicyObserver::CheckCertificateExpiry( |
171 const std::string& certificate) { | 172 const std::string& certificate) { |
172 // TODO(dkrahn): Check if the certificate will expire soon, for now assume no. | 173 // TODO(dkrahn): Check if the certificate will expire soon, for now assume no. |
173 CheckIfUploaded(certificate); | 174 CheckIfUploaded(certificate); |
174 } | 175 } |
175 | 176 |
176 void AttestationPolicyObserver::UploadCertificate( | 177 void AttestationPolicyObserver::UploadCertificate( |
177 const std::string& certificate) { | 178 const std::string& certificate) { |
178 // TODO(dkrahn): Upload the certificate. | 179 // TODO(dkrahn): Upload the certificate. |
179 } | 180 } |
180 | 181 |
181 void AttestationPolicyObserver::CheckIfUploaded( | 182 void AttestationPolicyObserver::CheckIfUploaded( |
182 const std::string& certificate) { | 183 const std::string& certificate) { |
183 // TODO(dkrahn): Check if we've already uploaded the certificate. | 184 // TODO(dkrahn): Check if we've already uploaded the certificate. |
184 } | 185 } |
185 | 186 |
186 } // namespace attestation | 187 } // namespace attestation |
187 } // namespace chromeos | 188 } // namespace chromeos |
OLD | NEW |