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/dbus/cryptohome_client.h" | 5 #include "chromeos/dbus/cryptohome_client.h" |
6 | 6 |
7 #include <stddef.h> | 7 #include <stddef.h> |
8 #include <stdint.h> | 8 #include <stdint.h> |
9 | 9 |
10 #include "base/bind.h" | 10 #include "base/bind.h" |
(...skipping 871 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
882 | 882 |
883 proxy_->CallMethod(&method_call, | 883 proxy_->CallMethod(&method_call, |
884 kTpmDBusTimeoutMs , | 884 kTpmDBusTimeoutMs , |
885 base::Bind(&CryptohomeClientImpl::OnBaseReplyMethod, | 885 base::Bind(&CryptohomeClientImpl::OnBaseReplyMethod, |
886 weak_ptr_factory_.GetWeakPtr(), | 886 weak_ptr_factory_.GetWeakPtr(), |
887 callback)); | 887 callback)); |
888 } | 888 } |
889 | 889 |
890 void GetBootAttribute(const cryptohome::GetBootAttributeRequest& request, | 890 void GetBootAttribute(const cryptohome::GetBootAttributeRequest& request, |
891 const ProtobufMethodCallback& callback) override { | 891 const ProtobufMethodCallback& callback) override { |
892 const char* method_name = cryptohome::kCryptohomeGetBootAttribute; | 892 CallCryptohomeMethod(cryptohome::kCryptohomeGetBootAttribute, request, |
893 dbus::MethodCall method_call(cryptohome::kCryptohomeInterface, method_name); | 893 callback); |
894 | |
895 dbus::MessageWriter writer(&method_call); | |
896 writer.AppendProtoAsArrayOfBytes(request); | |
897 | |
898 proxy_->CallMethod(&method_call, | |
899 kTpmDBusTimeoutMs , | |
900 base::Bind(&CryptohomeClientImpl::OnBaseReplyMethod, | |
901 weak_ptr_factory_.GetWeakPtr(), | |
902 callback)); | |
903 } | 894 } |
904 | 895 |
905 void SetBootAttribute(const cryptohome::SetBootAttributeRequest& request, | 896 void SetBootAttribute(const cryptohome::SetBootAttributeRequest& request, |
906 const ProtobufMethodCallback& callback) override { | 897 const ProtobufMethodCallback& callback) override { |
907 const char* method_name = cryptohome::kCryptohomeSetBootAttribute; | 898 CallCryptohomeMethod(cryptohome::kCryptohomeSetBootAttribute, request, |
908 dbus::MethodCall method_call(cryptohome::kCryptohomeInterface, method_name); | 899 callback); |
909 | |
910 dbus::MessageWriter writer(&method_call); | |
911 writer.AppendProtoAsArrayOfBytes(request); | |
912 | |
913 proxy_->CallMethod(&method_call, | |
914 kTpmDBusTimeoutMs , | |
915 base::Bind(&CryptohomeClientImpl::OnBaseReplyMethod, | |
916 weak_ptr_factory_.GetWeakPtr(), | |
917 callback)); | |
918 } | 900 } |
919 | 901 |
920 void FlushAndSignBootAttributes( | 902 void FlushAndSignBootAttributes( |
921 const cryptohome::FlushAndSignBootAttributesRequest& request, | 903 const cryptohome::FlushAndSignBootAttributesRequest& request, |
922 const ProtobufMethodCallback& callback) override { | 904 const ProtobufMethodCallback& callback) override { |
923 const char* method_name = cryptohome::kCryptohomeFlushAndSignBootAttributes; | 905 CallCryptohomeMethod(cryptohome::kCryptohomeFlushAndSignBootAttributes, |
924 dbus::MethodCall method_call(cryptohome::kCryptohomeInterface, method_name); | 906 request, callback); |
| 907 } |
925 | 908 |
926 dbus::MessageWriter writer(&method_call); | 909 void RemoveFirmwareManagementParametersFromTpm( |
927 writer.AppendProtoAsArrayOfBytes(request); | 910 const cryptohome::RemoveFirmwareManagementParametersRequest& request, |
| 911 const ProtobufMethodCallback& callback) override { |
| 912 CallCryptohomeMethod( |
| 913 cryptohome::kCryptohomeRemoveFirmwareManagementParameters, request, |
| 914 callback); |
| 915 } |
928 | 916 |
929 proxy_->CallMethod(&method_call, | 917 void SetFirmwareManagementParametersInTpm( |
930 kTpmDBusTimeoutMs , | 918 const cryptohome::SetFirmwareManagementParametersRequest& request, |
931 base::Bind(&CryptohomeClientImpl::OnBaseReplyMethod, | 919 const ProtobufMethodCallback& callback) override { |
932 weak_ptr_factory_.GetWeakPtr(), | 920 CallCryptohomeMethod(cryptohome::kCryptohomeSetFirmwareManagementParameters, |
933 callback)); | 921 request, callback); |
934 } | 922 } |
935 | 923 |
936 void MigrateToDircrypto(const cryptohome::Identification& cryptohome_id, | 924 void MigrateToDircrypto(const cryptohome::Identification& cryptohome_id, |
937 const cryptohome::AuthorizationRequest& auth, | 925 const cryptohome::AuthorizationRequest& auth, |
938 const VoidDBusMethodCallback& callback) override { | 926 const VoidDBusMethodCallback& callback) override { |
939 dbus::MethodCall method_call(cryptohome::kCryptohomeInterface, | 927 dbus::MethodCall method_call(cryptohome::kCryptohomeInterface, |
940 cryptohome::kCryptohomeMigrateToDircrypto); | 928 cryptohome::kCryptohomeMigrateToDircrypto); |
941 | 929 |
942 cryptohome::AccountIdentifier id_proto; | 930 cryptohome::AccountIdentifier id_proto; |
943 FillIdentificationProtobuf(cryptohome_id, &id_proto); | 931 FillIdentificationProtobuf(cryptohome_id, &id_proto); |
(...skipping 295 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1239 } | 1227 } |
1240 | 1228 |
1241 // Handles the result of signal connection setup. | 1229 // Handles the result of signal connection setup. |
1242 void OnSignalConnected(const std::string& interface, | 1230 void OnSignalConnected(const std::string& interface, |
1243 const std::string& signal, | 1231 const std::string& signal, |
1244 bool succeeded) { | 1232 bool succeeded) { |
1245 LOG_IF(ERROR, !succeeded) << "Connect to " << interface << " " << | 1233 LOG_IF(ERROR, !succeeded) << "Connect to " << interface << " " << |
1246 signal << " failed."; | 1234 signal << " failed."; |
1247 } | 1235 } |
1248 | 1236 |
| 1237 // Makes an asynchronous D-Bus call, using cryptohome interface. |method_name| |
| 1238 // is the name of the method to be called. |request| is the specific request |
| 1239 // for the method, including the data required to be sent. |callback| is |
| 1240 // invoked when the response is received. |
| 1241 void CallCryptohomeMethod(const std::string& method_name, |
| 1242 const google::protobuf::MessageLite& request, |
| 1243 const ProtobufMethodCallback& callback) { |
| 1244 dbus::MethodCall method_call(cryptohome::kCryptohomeInterface, method_name); |
| 1245 |
| 1246 dbus::MessageWriter writer(&method_call); |
| 1247 writer.AppendProtoAsArrayOfBytes(request); |
| 1248 |
| 1249 proxy_->CallMethod(&method_call, kTpmDBusTimeoutMs, |
| 1250 base::Bind(&CryptohomeClientImpl::OnBaseReplyMethod, |
| 1251 weak_ptr_factory_.GetWeakPtr(), callback)); |
| 1252 } |
| 1253 |
1249 dbus::ObjectProxy* proxy_; | 1254 dbus::ObjectProxy* proxy_; |
1250 std::unique_ptr<BlockingMethodCaller> blocking_method_caller_; | 1255 std::unique_ptr<BlockingMethodCaller> blocking_method_caller_; |
1251 AsyncCallStatusHandler async_call_status_handler_; | 1256 AsyncCallStatusHandler async_call_status_handler_; |
1252 AsyncCallStatusWithDataHandler async_call_status_data_handler_; | 1257 AsyncCallStatusWithDataHandler async_call_status_data_handler_; |
1253 LowDiskSpaceHandler low_disk_space_handler_; | 1258 LowDiskSpaceHandler low_disk_space_handler_; |
1254 DircryptoMigrationProgessHandler dircrypto_migration_progress_handler_; | 1259 DircryptoMigrationProgessHandler dircrypto_migration_progress_handler_; |
1255 | 1260 |
1256 // Note: This should remain the last member so it'll be destroyed and | 1261 // Note: This should remain the last member so it'll be destroyed and |
1257 // invalidate its weak pointers before any other members are destroyed. | 1262 // invalidate its weak pointers before any other members are destroyed. |
1258 base::WeakPtrFactory<CryptohomeClientImpl> weak_ptr_factory_; | 1263 base::WeakPtrFactory<CryptohomeClientImpl> weak_ptr_factory_; |
(...skipping 15 matching lines...) Expand all Loading... |
1274 return new CryptohomeClientImpl(); | 1279 return new CryptohomeClientImpl(); |
1275 } | 1280 } |
1276 | 1281 |
1277 // static | 1282 // static |
1278 std::string CryptohomeClient::GetStubSanitizedUsername( | 1283 std::string CryptohomeClient::GetStubSanitizedUsername( |
1279 const cryptohome::Identification& cryptohome_id) { | 1284 const cryptohome::Identification& cryptohome_id) { |
1280 return cryptohome_id.id() + kUserIdStubHashSuffix; | 1285 return cryptohome_id.id() + kUserIdStubHashSuffix; |
1281 } | 1286 } |
1282 | 1287 |
1283 } // namespace chromeos | 1288 } // namespace chromeos |
OLD | NEW |