| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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/async_method_caller.h" | 5 #include "chromeos/cryptohome/async_method_caller.h" |
| 6 | 6 |
| 7 #include "base/bind.h" | 7 #include "base/bind.h" |
| 8 #include "base/containers/hash_tables.h" | 8 #include "base/containers/hash_tables.h" |
| 9 #include "base/location.h" | 9 #include "base/location.h" |
| 10 #include "base/message_loop/message_loop_proxy.h" | 10 #include "base/message_loop/message_loop_proxy.h" |
| (...skipping 19 matching lines...) Expand all Loading... |
| 30 weak_ptr_factory_.GetWeakPtr())); | 30 weak_ptr_factory_.GetWeakPtr())); |
| 31 } | 31 } |
| 32 | 32 |
| 33 virtual ~AsyncMethodCallerImpl() { | 33 virtual ~AsyncMethodCallerImpl() { |
| 34 DBusThreadManager::Get()->GetCryptohomeClient()-> | 34 DBusThreadManager::Get()->GetCryptohomeClient()-> |
| 35 ResetAsyncCallStatusHandlers(); | 35 ResetAsyncCallStatusHandlers(); |
| 36 } | 36 } |
| 37 | 37 |
| 38 virtual void AsyncCheckKey(const std::string& user_email, | 38 virtual void AsyncCheckKey(const std::string& user_email, |
| 39 const std::string& passhash, | 39 const std::string& passhash, |
| 40 Callback callback) OVERRIDE { | 40 Callback callback) override { |
| 41 DBusThreadManager::Get()->GetCryptohomeClient()-> | 41 DBusThreadManager::Get()->GetCryptohomeClient()-> |
| 42 AsyncCheckKey(user_email, passhash, base::Bind( | 42 AsyncCheckKey(user_email, passhash, base::Bind( |
| 43 &AsyncMethodCallerImpl::RegisterAsyncCallback, | 43 &AsyncMethodCallerImpl::RegisterAsyncCallback, |
| 44 weak_ptr_factory_.GetWeakPtr(), | 44 weak_ptr_factory_.GetWeakPtr(), |
| 45 callback, | 45 callback, |
| 46 "Couldn't initiate async check of user's key.")); | 46 "Couldn't initiate async check of user's key.")); |
| 47 } | 47 } |
| 48 | 48 |
| 49 virtual void AsyncMigrateKey(const std::string& user_email, | 49 virtual void AsyncMigrateKey(const std::string& user_email, |
| 50 const std::string& old_hash, | 50 const std::string& old_hash, |
| 51 const std::string& new_hash, | 51 const std::string& new_hash, |
| 52 Callback callback) OVERRIDE { | 52 Callback callback) override { |
| 53 DBusThreadManager::Get()->GetCryptohomeClient()-> | 53 DBusThreadManager::Get()->GetCryptohomeClient()-> |
| 54 AsyncMigrateKey(user_email, old_hash, new_hash, base::Bind( | 54 AsyncMigrateKey(user_email, old_hash, new_hash, base::Bind( |
| 55 &AsyncMethodCallerImpl::RegisterAsyncCallback, | 55 &AsyncMethodCallerImpl::RegisterAsyncCallback, |
| 56 weak_ptr_factory_.GetWeakPtr(), | 56 weak_ptr_factory_.GetWeakPtr(), |
| 57 callback, | 57 callback, |
| 58 "Couldn't initiate aync migration of user's key")); | 58 "Couldn't initiate aync migration of user's key")); |
| 59 } | 59 } |
| 60 | 60 |
| 61 virtual void AsyncMount(const std::string& user_email, | 61 virtual void AsyncMount(const std::string& user_email, |
| 62 const std::string& passhash, | 62 const std::string& passhash, |
| 63 int flags, | 63 int flags, |
| 64 Callback callback) OVERRIDE { | 64 Callback callback) override { |
| 65 DBusThreadManager::Get()->GetCryptohomeClient()-> | 65 DBusThreadManager::Get()->GetCryptohomeClient()-> |
| 66 AsyncMount(user_email, passhash, flags, base::Bind( | 66 AsyncMount(user_email, passhash, flags, base::Bind( |
| 67 &AsyncMethodCallerImpl::RegisterAsyncCallback, | 67 &AsyncMethodCallerImpl::RegisterAsyncCallback, |
| 68 weak_ptr_factory_.GetWeakPtr(), | 68 weak_ptr_factory_.GetWeakPtr(), |
| 69 callback, | 69 callback, |
| 70 "Couldn't initiate async mount of cryptohome.")); | 70 "Couldn't initiate async mount of cryptohome.")); |
| 71 } | 71 } |
| 72 | 72 |
| 73 virtual void AsyncAddKey(const std::string& user_email, | 73 virtual void AsyncAddKey(const std::string& user_email, |
| 74 const std::string& passhash, | 74 const std::string& passhash, |
| 75 const std::string& new_passhash, | 75 const std::string& new_passhash, |
| 76 Callback callback) OVERRIDE { | 76 Callback callback) override { |
| 77 DBusThreadManager::Get()->GetCryptohomeClient()-> | 77 DBusThreadManager::Get()->GetCryptohomeClient()-> |
| 78 AsyncAddKey(user_email, passhash, new_passhash, base::Bind( | 78 AsyncAddKey(user_email, passhash, new_passhash, base::Bind( |
| 79 &AsyncMethodCallerImpl::RegisterAsyncCallback, | 79 &AsyncMethodCallerImpl::RegisterAsyncCallback, |
| 80 weak_ptr_factory_.GetWeakPtr(), | 80 weak_ptr_factory_.GetWeakPtr(), |
| 81 callback, | 81 callback, |
| 82 "Couldn't initiate async key addition.")); | 82 "Couldn't initiate async key addition.")); |
| 83 } | 83 } |
| 84 | 84 |
| 85 virtual void AsyncMountGuest(Callback callback) OVERRIDE { | 85 virtual void AsyncMountGuest(Callback callback) override { |
| 86 DBusThreadManager::Get()->GetCryptohomeClient()-> | 86 DBusThreadManager::Get()->GetCryptohomeClient()-> |
| 87 AsyncMountGuest(base::Bind( | 87 AsyncMountGuest(base::Bind( |
| 88 &AsyncMethodCallerImpl::RegisterAsyncCallback, | 88 &AsyncMethodCallerImpl::RegisterAsyncCallback, |
| 89 weak_ptr_factory_.GetWeakPtr(), | 89 weak_ptr_factory_.GetWeakPtr(), |
| 90 callback, | 90 callback, |
| 91 "Couldn't initiate async mount of cryptohome.")); | 91 "Couldn't initiate async mount of cryptohome.")); |
| 92 } | 92 } |
| 93 | 93 |
| 94 virtual void AsyncMountPublic(const std::string& public_mount_id, | 94 virtual void AsyncMountPublic(const std::string& public_mount_id, |
| 95 int flags, | 95 int flags, |
| 96 Callback callback) OVERRIDE { | 96 Callback callback) override { |
| 97 DBusThreadManager::Get()->GetCryptohomeClient()-> | 97 DBusThreadManager::Get()->GetCryptohomeClient()-> |
| 98 AsyncMountPublic(public_mount_id, flags, base::Bind( | 98 AsyncMountPublic(public_mount_id, flags, base::Bind( |
| 99 &AsyncMethodCallerImpl::RegisterAsyncCallback, | 99 &AsyncMethodCallerImpl::RegisterAsyncCallback, |
| 100 weak_ptr_factory_.GetWeakPtr(), | 100 weak_ptr_factory_.GetWeakPtr(), |
| 101 callback, | 101 callback, |
| 102 "Couldn't initiate async mount public of cryptohome.")); | 102 "Couldn't initiate async mount public of cryptohome.")); |
| 103 } | 103 } |
| 104 | 104 |
| 105 virtual void AsyncRemove(const std::string& user_email, | 105 virtual void AsyncRemove(const std::string& user_email, |
| 106 Callback callback) OVERRIDE { | 106 Callback callback) override { |
| 107 DBusThreadManager::Get()->GetCryptohomeClient()-> | 107 DBusThreadManager::Get()->GetCryptohomeClient()-> |
| 108 AsyncRemove(user_email, base::Bind( | 108 AsyncRemove(user_email, base::Bind( |
| 109 &AsyncMethodCallerImpl::RegisterAsyncCallback, | 109 &AsyncMethodCallerImpl::RegisterAsyncCallback, |
| 110 weak_ptr_factory_.GetWeakPtr(), | 110 weak_ptr_factory_.GetWeakPtr(), |
| 111 callback, | 111 callback, |
| 112 "Couldn't initiate async removal of cryptohome.")); | 112 "Couldn't initiate async removal of cryptohome.")); |
| 113 } | 113 } |
| 114 | 114 |
| 115 virtual void AsyncTpmAttestationCreateEnrollRequest( | 115 virtual void AsyncTpmAttestationCreateEnrollRequest( |
| 116 chromeos::attestation::PrivacyCAType pca_type, | 116 chromeos::attestation::PrivacyCAType pca_type, |
| 117 const DataCallback& callback) OVERRIDE { | 117 const DataCallback& callback) override { |
| 118 DBusThreadManager::Get()->GetCryptohomeClient()-> | 118 DBusThreadManager::Get()->GetCryptohomeClient()-> |
| 119 AsyncTpmAttestationCreateEnrollRequest(pca_type, base::Bind( | 119 AsyncTpmAttestationCreateEnrollRequest(pca_type, base::Bind( |
| 120 &AsyncMethodCallerImpl::RegisterAsyncDataCallback, | 120 &AsyncMethodCallerImpl::RegisterAsyncDataCallback, |
| 121 weak_ptr_factory_.GetWeakPtr(), | 121 weak_ptr_factory_.GetWeakPtr(), |
| 122 callback, | 122 callback, |
| 123 "Couldn't initiate async attestation enroll request.")); | 123 "Couldn't initiate async attestation enroll request.")); |
| 124 } | 124 } |
| 125 | 125 |
| 126 virtual void AsyncTpmAttestationEnroll( | 126 virtual void AsyncTpmAttestationEnroll( |
| 127 chromeos::attestation::PrivacyCAType pca_type, | 127 chromeos::attestation::PrivacyCAType pca_type, |
| 128 const std::string& pca_response, | 128 const std::string& pca_response, |
| 129 const Callback& callback) OVERRIDE { | 129 const Callback& callback) override { |
| 130 DBusThreadManager::Get()->GetCryptohomeClient()-> | 130 DBusThreadManager::Get()->GetCryptohomeClient()-> |
| 131 AsyncTpmAttestationEnroll(pca_type, pca_response, base::Bind( | 131 AsyncTpmAttestationEnroll(pca_type, pca_response, base::Bind( |
| 132 &AsyncMethodCallerImpl::RegisterAsyncCallback, | 132 &AsyncMethodCallerImpl::RegisterAsyncCallback, |
| 133 weak_ptr_factory_.GetWeakPtr(), | 133 weak_ptr_factory_.GetWeakPtr(), |
| 134 callback, | 134 callback, |
| 135 "Couldn't initiate async attestation enroll.")); | 135 "Couldn't initiate async attestation enroll.")); |
| 136 } | 136 } |
| 137 | 137 |
| 138 virtual void AsyncTpmAttestationCreateCertRequest( | 138 virtual void AsyncTpmAttestationCreateCertRequest( |
| 139 chromeos::attestation::PrivacyCAType pca_type, | 139 chromeos::attestation::PrivacyCAType pca_type, |
| 140 chromeos::attestation::AttestationCertificateProfile certificate_profile, | 140 chromeos::attestation::AttestationCertificateProfile certificate_profile, |
| 141 const std::string& user_id, | 141 const std::string& user_id, |
| 142 const std::string& request_origin, | 142 const std::string& request_origin, |
| 143 const DataCallback& callback) OVERRIDE { | 143 const DataCallback& callback) override { |
| 144 DBusThreadManager::Get()->GetCryptohomeClient()-> | 144 DBusThreadManager::Get()->GetCryptohomeClient()-> |
| 145 AsyncTpmAttestationCreateCertRequest( | 145 AsyncTpmAttestationCreateCertRequest( |
| 146 pca_type, | 146 pca_type, |
| 147 certificate_profile, | 147 certificate_profile, |
| 148 user_id, | 148 user_id, |
| 149 request_origin, | 149 request_origin, |
| 150 base::Bind(&AsyncMethodCallerImpl::RegisterAsyncDataCallback, | 150 base::Bind(&AsyncMethodCallerImpl::RegisterAsyncDataCallback, |
| 151 weak_ptr_factory_.GetWeakPtr(), | 151 weak_ptr_factory_.GetWeakPtr(), |
| 152 callback, | 152 callback, |
| 153 "Couldn't initiate async attestation cert request.")); | 153 "Couldn't initiate async attestation cert request.")); |
| 154 } | 154 } |
| 155 | 155 |
| 156 virtual void AsyncTpmAttestationFinishCertRequest( | 156 virtual void AsyncTpmAttestationFinishCertRequest( |
| 157 const std::string& pca_response, | 157 const std::string& pca_response, |
| 158 chromeos::attestation::AttestationKeyType key_type, | 158 chromeos::attestation::AttestationKeyType key_type, |
| 159 const std::string& user_id, | 159 const std::string& user_id, |
| 160 const std::string& key_name, | 160 const std::string& key_name, |
| 161 const DataCallback& callback) OVERRIDE { | 161 const DataCallback& callback) override { |
| 162 DBusThreadManager::Get()->GetCryptohomeClient()-> | 162 DBusThreadManager::Get()->GetCryptohomeClient()-> |
| 163 AsyncTpmAttestationFinishCertRequest( | 163 AsyncTpmAttestationFinishCertRequest( |
| 164 pca_response, | 164 pca_response, |
| 165 key_type, | 165 key_type, |
| 166 user_id, | 166 user_id, |
| 167 key_name, | 167 key_name, |
| 168 base::Bind( | 168 base::Bind( |
| 169 &AsyncMethodCallerImpl::RegisterAsyncDataCallback, | 169 &AsyncMethodCallerImpl::RegisterAsyncDataCallback, |
| 170 weak_ptr_factory_.GetWeakPtr(), | 170 weak_ptr_factory_.GetWeakPtr(), |
| 171 callback, | 171 callback, |
| 172 "Couldn't initiate async attestation finish cert request.")); | 172 "Couldn't initiate async attestation finish cert request.")); |
| 173 } | 173 } |
| 174 | 174 |
| 175 virtual void TpmAttestationRegisterKey( | 175 virtual void TpmAttestationRegisterKey( |
| 176 chromeos::attestation::AttestationKeyType key_type, | 176 chromeos::attestation::AttestationKeyType key_type, |
| 177 const std::string& user_id, | 177 const std::string& user_id, |
| 178 const std::string& key_name, | 178 const std::string& key_name, |
| 179 const Callback& callback) OVERRIDE { | 179 const Callback& callback) override { |
| 180 DBusThreadManager::Get()->GetCryptohomeClient()-> | 180 DBusThreadManager::Get()->GetCryptohomeClient()-> |
| 181 TpmAttestationRegisterKey( | 181 TpmAttestationRegisterKey( |
| 182 key_type, | 182 key_type, |
| 183 user_id, | 183 user_id, |
| 184 key_name, | 184 key_name, |
| 185 base::Bind( | 185 base::Bind( |
| 186 &AsyncMethodCallerImpl::RegisterAsyncCallback, | 186 &AsyncMethodCallerImpl::RegisterAsyncCallback, |
| 187 weak_ptr_factory_.GetWeakPtr(), | 187 weak_ptr_factory_.GetWeakPtr(), |
| 188 callback, | 188 callback, |
| 189 "Couldn't initiate async attestation register key.")); | 189 "Couldn't initiate async attestation register key.")); |
| 190 } | 190 } |
| 191 | 191 |
| 192 virtual void TpmAttestationSignEnterpriseChallenge( | 192 virtual void TpmAttestationSignEnterpriseChallenge( |
| 193 chromeos::attestation::AttestationKeyType key_type, | 193 chromeos::attestation::AttestationKeyType key_type, |
| 194 const std::string& user_id, | 194 const std::string& user_id, |
| 195 const std::string& key_name, | 195 const std::string& key_name, |
| 196 const std::string& domain, | 196 const std::string& domain, |
| 197 const std::string& device_id, | 197 const std::string& device_id, |
| 198 chromeos::attestation::AttestationChallengeOptions options, | 198 chromeos::attestation::AttestationChallengeOptions options, |
| 199 const std::string& challenge, | 199 const std::string& challenge, |
| 200 const DataCallback& callback) OVERRIDE { | 200 const DataCallback& callback) override { |
| 201 DBusThreadManager::Get()->GetCryptohomeClient()-> | 201 DBusThreadManager::Get()->GetCryptohomeClient()-> |
| 202 TpmAttestationSignEnterpriseChallenge( | 202 TpmAttestationSignEnterpriseChallenge( |
| 203 key_type, | 203 key_type, |
| 204 user_id, | 204 user_id, |
| 205 key_name, | 205 key_name, |
| 206 domain, | 206 domain, |
| 207 device_id, | 207 device_id, |
| 208 options, | 208 options, |
| 209 challenge, | 209 challenge, |
| 210 base::Bind( | 210 base::Bind( |
| 211 &AsyncMethodCallerImpl::RegisterAsyncDataCallback, | 211 &AsyncMethodCallerImpl::RegisterAsyncDataCallback, |
| 212 weak_ptr_factory_.GetWeakPtr(), | 212 weak_ptr_factory_.GetWeakPtr(), |
| 213 callback, | 213 callback, |
| 214 "Couldn't initiate async attestation enterprise challenge.")); | 214 "Couldn't initiate async attestation enterprise challenge.")); |
| 215 } | 215 } |
| 216 | 216 |
| 217 virtual void TpmAttestationSignSimpleChallenge( | 217 virtual void TpmAttestationSignSimpleChallenge( |
| 218 chromeos::attestation::AttestationKeyType key_type, | 218 chromeos::attestation::AttestationKeyType key_type, |
| 219 const std::string& user_id, | 219 const std::string& user_id, |
| 220 const std::string& key_name, | 220 const std::string& key_name, |
| 221 const std::string& challenge, | 221 const std::string& challenge, |
| 222 const DataCallback& callback) OVERRIDE { | 222 const DataCallback& callback) override { |
| 223 DBusThreadManager::Get()->GetCryptohomeClient()-> | 223 DBusThreadManager::Get()->GetCryptohomeClient()-> |
| 224 TpmAttestationSignSimpleChallenge( | 224 TpmAttestationSignSimpleChallenge( |
| 225 key_type, | 225 key_type, |
| 226 user_id, | 226 user_id, |
| 227 key_name, | 227 key_name, |
| 228 challenge, | 228 challenge, |
| 229 base::Bind( | 229 base::Bind( |
| 230 &AsyncMethodCallerImpl::RegisterAsyncDataCallback, | 230 &AsyncMethodCallerImpl::RegisterAsyncDataCallback, |
| 231 weak_ptr_factory_.GetWeakPtr(), | 231 weak_ptr_factory_.GetWeakPtr(), |
| 232 callback, | 232 callback, |
| 233 "Couldn't initiate async attestation simple challenge.")); | 233 "Couldn't initiate async attestation simple challenge.")); |
| 234 } | 234 } |
| 235 | 235 |
| 236 virtual void AsyncGetSanitizedUsername( | 236 virtual void AsyncGetSanitizedUsername( |
| 237 const std::string& user, | 237 const std::string& user, |
| 238 const DataCallback& callback) OVERRIDE { | 238 const DataCallback& callback) override { |
| 239 DBusThreadManager::Get()->GetCryptohomeClient()-> | 239 DBusThreadManager::Get()->GetCryptohomeClient()-> |
| 240 GetSanitizedUsername(user, | 240 GetSanitizedUsername(user, |
| 241 base::Bind( | 241 base::Bind( |
| 242 &AsyncMethodCallerImpl::GetSanitizedUsernameCallback, | 242 &AsyncMethodCallerImpl::GetSanitizedUsernameCallback, |
| 243 weak_ptr_factory_.GetWeakPtr(), | 243 weak_ptr_factory_.GetWeakPtr(), |
| 244 callback)); | 244 callback)); |
| 245 } | 245 } |
| 246 | 246 |
| 247 virtual void GetSanitizedUsernameCallback( | 247 virtual void GetSanitizedUsernameCallback( |
| 248 const DataCallback& callback, | 248 const DataCallback& callback, |
| (...skipping 129 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 378 g_async_method_caller = NULL; | 378 g_async_method_caller = NULL; |
| 379 VLOG(1) << "AsyncMethodCaller Shutdown completed"; | 379 VLOG(1) << "AsyncMethodCaller Shutdown completed"; |
| 380 } | 380 } |
| 381 | 381 |
| 382 // static | 382 // static |
| 383 AsyncMethodCaller* AsyncMethodCaller::GetInstance() { | 383 AsyncMethodCaller* AsyncMethodCaller::GetInstance() { |
| 384 return g_async_method_caller; | 384 return g_async_method_caller; |
| 385 } | 385 } |
| 386 | 386 |
| 387 } // namespace cryptohome | 387 } // namespace cryptohome |
| OLD | NEW |