| OLD | NEW |
| (Empty) |
| 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 | |
| 3 // found in the LICENSE file. | |
| 4 | |
| 5 #ifndef CHROMEOS_DBUS_CRYPTOHOME_CLIENT_STUB_H_ | |
| 6 #define CHROMEOS_DBUS_CRYPTOHOME_CLIENT_STUB_H_ | |
| 7 | |
| 8 #include <map> | |
| 9 | |
| 10 #include "base/basictypes.h" | |
| 11 #include "base/memory/weak_ptr.h" | |
| 12 #include "chromeos/dbus/cryptohome_client.h" | |
| 13 | |
| 14 namespace chromeos { | |
| 15 | |
| 16 class CHROMEOS_EXPORT CryptohomeClientStubImpl : public CryptohomeClient { | |
| 17 public: | |
| 18 CryptohomeClientStubImpl(); | |
| 19 virtual ~CryptohomeClientStubImpl(); | |
| 20 | |
| 21 virtual void Init(dbus::Bus* bus) OVERRIDE; | |
| 22 virtual void SetAsyncCallStatusHandlers( | |
| 23 const AsyncCallStatusHandler& handler, | |
| 24 const AsyncCallStatusWithDataHandler& data_handler) OVERRIDE; | |
| 25 virtual void ResetAsyncCallStatusHandlers() OVERRIDE; | |
| 26 virtual void IsMounted(const BoolDBusMethodCallback& callback) OVERRIDE; | |
| 27 virtual bool Unmount(bool* success) OVERRIDE; | |
| 28 virtual void AsyncCheckKey(const std::string& username, | |
| 29 const std::string& key, | |
| 30 const AsyncMethodCallback& callback) OVERRIDE; | |
| 31 virtual void AsyncMigrateKey(const std::string& username, | |
| 32 const std::string& from_key, | |
| 33 const std::string& to_key, | |
| 34 const AsyncMethodCallback& callback) OVERRIDE; | |
| 35 virtual void AsyncRemove(const std::string& username, | |
| 36 const AsyncMethodCallback& callback) OVERRIDE; | |
| 37 virtual bool GetSystemSalt(std::vector<uint8>* salt) OVERRIDE; | |
| 38 virtual void GetSanitizedUsername( | |
| 39 const std::string& username, | |
| 40 const StringDBusMethodCallback& callback) OVERRIDE; | |
| 41 virtual std::string BlockingGetSanitizedUsername( | |
| 42 const std::string& username) OVERRIDE; | |
| 43 virtual void AsyncMount(const std::string& username, | |
| 44 const std::string& key, | |
| 45 int flags, | |
| 46 const AsyncMethodCallback& callback) OVERRIDE; | |
| 47 virtual void AsyncAddKey(const std::string& username, | |
| 48 const std::string& key, | |
| 49 const std::string& new_key, | |
| 50 const AsyncMethodCallback& callback) OVERRIDE; | |
| 51 virtual void AsyncMountGuest(const AsyncMethodCallback& callback) OVERRIDE; | |
| 52 virtual void AsyncMountPublic(const std::string& public_mount_id, | |
| 53 int flags, | |
| 54 const AsyncMethodCallback& callback) OVERRIDE; | |
| 55 virtual void TpmIsReady(const BoolDBusMethodCallback& callback) OVERRIDE; | |
| 56 virtual void TpmIsEnabled(const BoolDBusMethodCallback& callback) OVERRIDE; | |
| 57 virtual bool CallTpmIsEnabledAndBlock(bool* enabled) OVERRIDE; | |
| 58 virtual void TpmGetPassword( | |
| 59 const StringDBusMethodCallback& callback) OVERRIDE; | |
| 60 virtual void TpmIsOwned(const BoolDBusMethodCallback& callback) OVERRIDE; | |
| 61 virtual bool CallTpmIsOwnedAndBlock(bool* owned) OVERRIDE; | |
| 62 virtual void TpmIsBeingOwned(const BoolDBusMethodCallback& callback) OVERRIDE; | |
| 63 virtual bool CallTpmIsBeingOwnedAndBlock(bool* owning) OVERRIDE; | |
| 64 virtual void TpmCanAttemptOwnership( | |
| 65 const VoidDBusMethodCallback& callback) OVERRIDE; | |
| 66 virtual void TpmClearStoredPassword( | |
| 67 const VoidDBusMethodCallback& callback) OVERRIDE; | |
| 68 virtual bool CallTpmClearStoredPasswordAndBlock() OVERRIDE; | |
| 69 virtual void Pkcs11IsTpmTokenReady( | |
| 70 const BoolDBusMethodCallback& callback) OVERRIDE; | |
| 71 virtual void Pkcs11GetTpmTokenInfo( | |
| 72 const Pkcs11GetTpmTokenInfoCallback& callback) OVERRIDE; | |
| 73 virtual bool InstallAttributesGet(const std::string& name, | |
| 74 std::vector<uint8>* value, | |
| 75 bool* successful) OVERRIDE; | |
| 76 virtual bool InstallAttributesSet(const std::string& name, | |
| 77 const std::vector<uint8>& value, | |
| 78 bool* successful) OVERRIDE; | |
| 79 virtual bool InstallAttributesFinalize(bool* successful) OVERRIDE; | |
| 80 virtual void InstallAttributesIsReady( | |
| 81 const BoolDBusMethodCallback& callback) OVERRIDE; | |
| 82 virtual bool InstallAttributesIsInvalid(bool* is_invalid) OVERRIDE; | |
| 83 virtual bool InstallAttributesIsFirstInstall(bool* is_first_install) OVERRIDE; | |
| 84 virtual void TpmAttestationIsPrepared( | |
| 85 const BoolDBusMethodCallback& callback) OVERRIDE; | |
| 86 virtual void TpmAttestationIsEnrolled( | |
| 87 const BoolDBusMethodCallback& callback) OVERRIDE; | |
| 88 virtual void AsyncTpmAttestationCreateEnrollRequest( | |
| 89 const AsyncMethodCallback& callback) OVERRIDE; | |
| 90 virtual void AsyncTpmAttestationEnroll( | |
| 91 const std::string& pca_response, | |
| 92 const AsyncMethodCallback& callback) OVERRIDE; | |
| 93 virtual void AsyncTpmAttestationCreateCertRequest( | |
| 94 attestation::AttestationCertificateProfile certificate_profile, | |
| 95 const std::string& user_email, | |
| 96 const std::string& request_origin, | |
| 97 const AsyncMethodCallback& callback) OVERRIDE; | |
| 98 virtual void AsyncTpmAttestationFinishCertRequest( | |
| 99 const std::string& pca_response, | |
| 100 attestation::AttestationKeyType key_type, | |
| 101 const std::string& key_name, | |
| 102 const AsyncMethodCallback& callback) OVERRIDE; | |
| 103 virtual void TpmAttestationDoesKeyExist( | |
| 104 attestation::AttestationKeyType key_type, | |
| 105 const std::string& key_name, | |
| 106 const BoolDBusMethodCallback& callback) OVERRIDE; | |
| 107 virtual void TpmAttestationGetCertificate( | |
| 108 attestation::AttestationKeyType key_type, | |
| 109 const std::string& key_name, | |
| 110 const DataMethodCallback& callback) OVERRIDE; | |
| 111 virtual void TpmAttestationGetPublicKey( | |
| 112 attestation::AttestationKeyType key_type, | |
| 113 const std::string& key_name, | |
| 114 const DataMethodCallback& callback) OVERRIDE; | |
| 115 virtual void TpmAttestationRegisterKey( | |
| 116 attestation::AttestationKeyType key_type, | |
| 117 const std::string& key_name, | |
| 118 const AsyncMethodCallback& callback) OVERRIDE; | |
| 119 virtual void TpmAttestationSignEnterpriseChallenge( | |
| 120 attestation::AttestationKeyType key_type, | |
| 121 const std::string& key_name, | |
| 122 const std::string& domain, | |
| 123 const std::string& device_id, | |
| 124 attestation::AttestationChallengeOptions options, | |
| 125 const std::string& challenge, | |
| 126 const AsyncMethodCallback& callback) OVERRIDE; | |
| 127 virtual void TpmAttestationSignSimpleChallenge( | |
| 128 attestation::AttestationKeyType key_type, | |
| 129 const std::string& key_name, | |
| 130 const std::string& challenge, | |
| 131 const AsyncMethodCallback& callback) OVERRIDE; | |
| 132 virtual void TpmAttestationGetKeyPayload( | |
| 133 attestation::AttestationKeyType key_type, | |
| 134 const std::string& key_name, | |
| 135 const DataMethodCallback& callback) OVERRIDE; | |
| 136 virtual void TpmAttestationSetKeyPayload( | |
| 137 attestation::AttestationKeyType key_type, | |
| 138 const std::string& key_name, | |
| 139 const std::string& payload, | |
| 140 const BoolDBusMethodCallback& callback) OVERRIDE; | |
| 141 | |
| 142 private: | |
| 143 // Posts tasks which return fake results to the UI thread. | |
| 144 void ReturnAsyncMethodResult(const AsyncMethodCallback& callback, | |
| 145 bool returns_data); | |
| 146 | |
| 147 // This method is used to implement ReturnAsyncMethodResult. | |
| 148 void ReturnAsyncMethodResultInternal(const AsyncMethodCallback& callback, | |
| 149 bool returns_data); | |
| 150 | |
| 151 int async_call_id_; | |
| 152 AsyncCallStatusHandler async_call_status_handler_; | |
| 153 AsyncCallStatusWithDataHandler async_call_status_data_handler_; | |
| 154 int tpm_is_ready_counter_; | |
| 155 | |
| 156 // A stub store for InstallAttributes, mapping an attribute name to the | |
| 157 // associated data blob. Used to implement InstallAttributesSet and -Get. | |
| 158 std::map<std::string, std::vector<uint8> > install_attrs_; | |
| 159 bool locked_; | |
| 160 base::WeakPtrFactory<CryptohomeClientStubImpl> weak_ptr_factory_; | |
| 161 | |
| 162 DISALLOW_COPY_AND_ASSIGN(CryptohomeClientStubImpl); | |
| 163 }; | |
| 164 | |
| 165 } // namespace chromeos | |
| 166 | |
| 167 #endif // CHROMEOS_DBUS_CRYPTOHOME_CLIENT_STUB_H_ | |
| OLD | NEW |