OLD | NEW |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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 "chromeos/cryptohome/homedir_methods.h" | 5 #include "chromeos/cryptohome/homedir_methods.h" |
6 | 6 |
7 #include "base/bind.h" | 7 #include "base/bind.h" |
8 #include "base/logging.h" | 8 #include "base/logging.h" |
9 #include "chromeos/dbus/cryptohome/key.pb.h" | 9 #include "chromeos/dbus/cryptohome/key.pb.h" |
10 #include "chromeos/dbus/cryptohome/rpc.pb.h" | 10 #include "chromeos/dbus/cryptohome/rpc.pb.h" |
(...skipping 160 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
171 | 171 |
172 // The implementation of HomedirMethods | 172 // The implementation of HomedirMethods |
173 class HomedirMethodsImpl : public HomedirMethods { | 173 class HomedirMethodsImpl : public HomedirMethods { |
174 public: | 174 public: |
175 HomedirMethodsImpl() : weak_ptr_factory_(this) {} | 175 HomedirMethodsImpl() : weak_ptr_factory_(this) {} |
176 | 176 |
177 virtual ~HomedirMethodsImpl() {} | 177 virtual ~HomedirMethodsImpl() {} |
178 | 178 |
179 virtual void GetKeyDataEx(const Identification& id, | 179 virtual void GetKeyDataEx(const Identification& id, |
180 const std::string& label, | 180 const std::string& label, |
181 const GetKeyDataCallback& callback) OVERRIDE { | 181 const GetKeyDataCallback& callback) override { |
182 cryptohome::AccountIdentifier id_proto; | 182 cryptohome::AccountIdentifier id_proto; |
183 cryptohome::AuthorizationRequest kEmptyAuthProto; | 183 cryptohome::AuthorizationRequest kEmptyAuthProto; |
184 cryptohome::GetKeyDataRequest request; | 184 cryptohome::GetKeyDataRequest request; |
185 | 185 |
186 FillIdentificationProtobuf(id, &id_proto); | 186 FillIdentificationProtobuf(id, &id_proto); |
187 request.mutable_key()->mutable_data()->set_label(label); | 187 request.mutable_key()->mutable_data()->set_label(label); |
188 | 188 |
189 DBusThreadManager::Get()->GetCryptohomeClient()->GetKeyDataEx( | 189 DBusThreadManager::Get()->GetCryptohomeClient()->GetKeyDataEx( |
190 id_proto, | 190 id_proto, |
191 kEmptyAuthProto, | 191 kEmptyAuthProto, |
192 request, | 192 request, |
193 base::Bind(&HomedirMethodsImpl::OnGetKeyDataExCallback, | 193 base::Bind(&HomedirMethodsImpl::OnGetKeyDataExCallback, |
194 weak_ptr_factory_.GetWeakPtr(), | 194 weak_ptr_factory_.GetWeakPtr(), |
195 callback)); | 195 callback)); |
196 } | 196 } |
197 | 197 |
198 virtual void CheckKeyEx(const Identification& id, | 198 virtual void CheckKeyEx(const Identification& id, |
199 const Authorization& auth, | 199 const Authorization& auth, |
200 const Callback& callback) OVERRIDE { | 200 const Callback& callback) override { |
201 cryptohome::AccountIdentifier id_proto; | 201 cryptohome::AccountIdentifier id_proto; |
202 cryptohome::AuthorizationRequest auth_proto; | 202 cryptohome::AuthorizationRequest auth_proto; |
203 cryptohome::CheckKeyRequest request; | 203 cryptohome::CheckKeyRequest request; |
204 | 204 |
205 FillIdentificationProtobuf(id, &id_proto); | 205 FillIdentificationProtobuf(id, &id_proto); |
206 FillAuthorizationProtobuf(auth, &auth_proto); | 206 FillAuthorizationProtobuf(auth, &auth_proto); |
207 | 207 |
208 DBusThreadManager::Get()->GetCryptohomeClient()->CheckKeyEx( | 208 DBusThreadManager::Get()->GetCryptohomeClient()->CheckKeyEx( |
209 id_proto, | 209 id_proto, |
210 auth_proto, | 210 auth_proto, |
211 request, | 211 request, |
212 base::Bind(&HomedirMethodsImpl::OnBaseReplyCallback, | 212 base::Bind(&HomedirMethodsImpl::OnBaseReplyCallback, |
213 weak_ptr_factory_.GetWeakPtr(), | 213 weak_ptr_factory_.GetWeakPtr(), |
214 callback)); | 214 callback)); |
215 } | 215 } |
216 | 216 |
217 virtual void MountEx(const Identification& id, | 217 virtual void MountEx(const Identification& id, |
218 const Authorization& auth, | 218 const Authorization& auth, |
219 const MountParameters& request, | 219 const MountParameters& request, |
220 const MountCallback& callback) OVERRIDE { | 220 const MountCallback& callback) override { |
221 cryptohome::AccountIdentifier id_proto; | 221 cryptohome::AccountIdentifier id_proto; |
222 cryptohome::AuthorizationRequest auth_proto; | 222 cryptohome::AuthorizationRequest auth_proto; |
223 cryptohome::MountRequest request_proto; | 223 cryptohome::MountRequest request_proto; |
224 | 224 |
225 FillIdentificationProtobuf(id, &id_proto); | 225 FillIdentificationProtobuf(id, &id_proto); |
226 FillAuthorizationProtobuf(auth, &auth_proto); | 226 FillAuthorizationProtobuf(auth, &auth_proto); |
227 | 227 |
228 if (request.ephemeral) | 228 if (request.ephemeral) |
229 request_proto.set_require_ephemeral(true); | 229 request_proto.set_require_ephemeral(true); |
230 | 230 |
231 if (!request.create_keys.empty()) { | 231 if (!request.create_keys.empty()) { |
232 CreateRequest* create = request_proto.mutable_create(); | 232 CreateRequest* create = request_proto.mutable_create(); |
233 for (size_t i = 0; i < request.create_keys.size(); ++i) | 233 for (size_t i = 0; i < request.create_keys.size(); ++i) |
234 FillKeyProtobuf(request.create_keys[i], create->add_keys()); | 234 FillKeyProtobuf(request.create_keys[i], create->add_keys()); |
235 } | 235 } |
236 | 236 |
237 DBusThreadManager::Get()->GetCryptohomeClient()->MountEx( | 237 DBusThreadManager::Get()->GetCryptohomeClient()->MountEx( |
238 id_proto, | 238 id_proto, |
239 auth_proto, | 239 auth_proto, |
240 request_proto, | 240 request_proto, |
241 base::Bind(&HomedirMethodsImpl::OnMountExCallback, | 241 base::Bind(&HomedirMethodsImpl::OnMountExCallback, |
242 weak_ptr_factory_.GetWeakPtr(), | 242 weak_ptr_factory_.GetWeakPtr(), |
243 callback)); | 243 callback)); |
244 } | 244 } |
245 | 245 |
246 virtual void AddKeyEx(const Identification& id, | 246 virtual void AddKeyEx(const Identification& id, |
247 const Authorization& auth, | 247 const Authorization& auth, |
248 const KeyDefinition& new_key, | 248 const KeyDefinition& new_key, |
249 bool clobber_if_exists, | 249 bool clobber_if_exists, |
250 const Callback& callback) OVERRIDE { | 250 const Callback& callback) override { |
251 cryptohome::AccountIdentifier id_proto; | 251 cryptohome::AccountIdentifier id_proto; |
252 cryptohome::AuthorizationRequest auth_proto; | 252 cryptohome::AuthorizationRequest auth_proto; |
253 cryptohome::AddKeyRequest request; | 253 cryptohome::AddKeyRequest request; |
254 | 254 |
255 FillIdentificationProtobuf(id, &id_proto); | 255 FillIdentificationProtobuf(id, &id_proto); |
256 FillAuthorizationProtobuf(auth, &auth_proto); | 256 FillAuthorizationProtobuf(auth, &auth_proto); |
257 FillKeyProtobuf(new_key, request.mutable_key()); | 257 FillKeyProtobuf(new_key, request.mutable_key()); |
258 request.set_clobber_if_exists(clobber_if_exists); | 258 request.set_clobber_if_exists(clobber_if_exists); |
259 | 259 |
260 DBusThreadManager::Get()->GetCryptohomeClient()->AddKeyEx( | 260 DBusThreadManager::Get()->GetCryptohomeClient()->AddKeyEx( |
261 id_proto, | 261 id_proto, |
262 auth_proto, | 262 auth_proto, |
263 request, | 263 request, |
264 base::Bind(&HomedirMethodsImpl::OnBaseReplyCallback, | 264 base::Bind(&HomedirMethodsImpl::OnBaseReplyCallback, |
265 weak_ptr_factory_.GetWeakPtr(), | 265 weak_ptr_factory_.GetWeakPtr(), |
266 callback)); | 266 callback)); |
267 } | 267 } |
268 | 268 |
269 virtual void RemoveKeyEx(const Identification& id, | 269 virtual void RemoveKeyEx(const Identification& id, |
270 const Authorization& auth, | 270 const Authorization& auth, |
271 const std::string& label, | 271 const std::string& label, |
272 const Callback& callback) OVERRIDE { | 272 const Callback& callback) override { |
273 cryptohome::AccountIdentifier id_proto; | 273 cryptohome::AccountIdentifier id_proto; |
274 cryptohome::AuthorizationRequest auth_proto; | 274 cryptohome::AuthorizationRequest auth_proto; |
275 cryptohome::RemoveKeyRequest request; | 275 cryptohome::RemoveKeyRequest request; |
276 | 276 |
277 FillIdentificationProtobuf(id, &id_proto); | 277 FillIdentificationProtobuf(id, &id_proto); |
278 FillAuthorizationProtobuf(auth, &auth_proto); | 278 FillAuthorizationProtobuf(auth, &auth_proto); |
279 request.mutable_key()->mutable_data()->set_label(label); | 279 request.mutable_key()->mutable_data()->set_label(label); |
280 | 280 |
281 DBusThreadManager::Get()->GetCryptohomeClient()->RemoveKeyEx( | 281 DBusThreadManager::Get()->GetCryptohomeClient()->RemoveKeyEx( |
282 id_proto, | 282 id_proto, |
283 auth_proto, | 283 auth_proto, |
284 request, | 284 request, |
285 base::Bind(&HomedirMethodsImpl::OnBaseReplyCallback, | 285 base::Bind(&HomedirMethodsImpl::OnBaseReplyCallback, |
286 weak_ptr_factory_.GetWeakPtr(), | 286 weak_ptr_factory_.GetWeakPtr(), |
287 callback)); | 287 callback)); |
288 } | 288 } |
289 | 289 |
290 virtual void UpdateKeyEx(const Identification& id, | 290 virtual void UpdateKeyEx(const Identification& id, |
291 const Authorization& auth, | 291 const Authorization& auth, |
292 const KeyDefinition& new_key, | 292 const KeyDefinition& new_key, |
293 const std::string& signature, | 293 const std::string& signature, |
294 const Callback& callback) OVERRIDE { | 294 const Callback& callback) override { |
295 cryptohome::AccountIdentifier id_proto; | 295 cryptohome::AccountIdentifier id_proto; |
296 cryptohome::AuthorizationRequest auth_proto; | 296 cryptohome::AuthorizationRequest auth_proto; |
297 cryptohome::UpdateKeyRequest pb_update_key; | 297 cryptohome::UpdateKeyRequest pb_update_key; |
298 | 298 |
299 FillIdentificationProtobuf(id, &id_proto); | 299 FillIdentificationProtobuf(id, &id_proto); |
300 FillAuthorizationProtobuf(auth, &auth_proto); | 300 FillAuthorizationProtobuf(auth, &auth_proto); |
301 FillKeyProtobuf(new_key, pb_update_key.mutable_changes()); | 301 FillKeyProtobuf(new_key, pb_update_key.mutable_changes()); |
302 pb_update_key.set_authorization_signature(signature); | 302 pb_update_key.set_authorization_signature(signature); |
303 | 303 |
304 DBusThreadManager::Get()->GetCryptohomeClient()->UpdateKeyEx( | 304 DBusThreadManager::Get()->GetCryptohomeClient()->UpdateKeyEx( |
(...skipping 176 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
481 } | 481 } |
482 delete g_homedir_methods; | 482 delete g_homedir_methods; |
483 g_homedir_methods = NULL; | 483 g_homedir_methods = NULL; |
484 VLOG(1) << "HomedirMethods Shutdown completed"; | 484 VLOG(1) << "HomedirMethods Shutdown completed"; |
485 } | 485 } |
486 | 486 |
487 // static | 487 // static |
488 HomedirMethods* HomedirMethods::GetInstance() { return g_homedir_methods; } | 488 HomedirMethods* HomedirMethods::GetInstance() { return g_homedir_methods; } |
489 | 489 |
490 } // namespace cryptohome | 490 } // namespace cryptohome |
OLD | NEW |