| // Copyright 2019 The Chromium OS Authors. All rights reserved. |
| // Use of this source code is governed by a BSD-style license that can be |
| // found in the LICENSE file. |
| |
| #ifndef CRYPTOHOME_DBUS_SERVICE_H_ |
| #define CRYPTOHOME_DBUS_SERVICE_H_ |
| |
| #include <memory> |
| |
| #include <brillo/daemons/dbus_daemon.h> |
| |
| #include "cryptohome/service_userdataauth.h" |
| #include "cryptohome/userdataauth.h" |
| |
| namespace cryptohome { |
| |
| class UserDataAuthDaemon : public brillo::DBusServiceDaemon { |
| public: |
| UserDataAuthDaemon() |
| : DBusServiceDaemon(kUserDataAuthServiceName), |
| service_(new cryptohome::UserDataAuth()) {} |
| |
| // Retrieve the UserDataAuth object, it holds the service's state and provides |
| // a good chunk of functionality. |
| UserDataAuth* GetUserDataAuth() { return service_.get(); } |
| |
| protected: |
| void RegisterDBusObjectsAsync( |
| brillo::dbus_utils::AsyncEventSequencer* sequencer) override { |
| service_->set_dbus(bus_); |
| |
| DCHECK(!dbus_object_); |
| dbus_object_ = std::make_unique<brillo::dbus_utils::DBusObject>( |
| nullptr, bus_, dbus::ObjectPath(kUserDataAuthServicePath)); |
| |
| userdataauth_adaptor_.reset( |
| new UserDataAuthAdaptor(bus_, dbus_object_.get(), service_.get())); |
| userdataauth_adaptor_->RegisterAsync(); |
| |
| arc_quota_adaptor_.reset( |
| new ArcQuotaAdaptor(bus_, dbus_object_.get(), service_.get())); |
| arc_quota_adaptor_->RegisterAsync(); |
| |
| pkcs11_adaptor_.reset( |
| new Pkcs11Adaptor(bus_, dbus_object_.get(), service_.get())); |
| pkcs11_adaptor_->RegisterAsync(); |
| |
| install_attributes_adaptor_.reset( |
| new InstallAttributesAdaptor(bus_, dbus_object_.get(), service_.get())); |
| install_attributes_adaptor_->RegisterAsync(); |
| |
| misc_adaptor_.reset( |
| new CryptohomeMiscAdaptor(bus_, dbus_object_.get(), service_.get())); |
| misc_adaptor_->RegisterAsync(); |
| |
| dbus_object_->RegisterAsync( |
| sequencer->GetHandler("RegisterAsync() for UserDataAuth failed", true)); |
| } |
| |
| private: |
| std::unique_ptr<UserDataAuthAdaptor> userdataauth_adaptor_; |
| std::unique_ptr<ArcQuotaAdaptor> arc_quota_adaptor_; |
| std::unique_ptr<Pkcs11Adaptor> pkcs11_adaptor_; |
| std::unique_ptr<InstallAttributesAdaptor> install_attributes_adaptor_; |
| std::unique_ptr<CryptohomeMiscAdaptor> misc_adaptor_; |
| |
| std::unique_ptr<UserDataAuth> service_; |
| |
| std::unique_ptr<brillo::dbus_utils::DBusObject> dbus_object_; |
| |
| DISALLOW_COPY_AND_ASSIGN(UserDataAuthDaemon); |
| }; |
| |
| } // namespace cryptohome |
| |
| #endif // CRYPTOHOME_DBUS_SERVICE_H_ |