2 * Copyright (c) 2011 Samsung Electronics Co., Ltd All Rights Reserved
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
8 * http://www.apache.org/licenses/LICENSE-2.0
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
17 * @file security_dbus_service.cpp
18 * @author Tomasz Swierczek (t.swierczek@samsung.com)
19 * @author Zbigniew Kostrzewa (z.kostrzewa@samsung.com)
21 * @brief This file contains implementation of security DBus service.
23 #include <dpl/log/log.h>
26 #include <dpl/exception.h>
27 #include <dpl/dbus/interface.h>
28 #include <dpl/dbus/connection.h>
29 #include "security_dbus_service.h"
30 #include "security_daemon_dbus_config.h"
31 #include <ace_server_dbus_interface.h>
32 #include <ocsp_server_dbus_interface.h>
33 #include <popup_response_dbus_interface.h>
36 void SecurityDBusService::start()
38 LogDebug("SecurityDBusService starting");
39 m_connection = DPL::DBus::Connection::systemBus();
40 std::for_each(m_objects.begin(),
42 [&m_connection] (const DPL::DBus::ObjectPtr& object)
44 m_connection->registerObject(object);
46 m_connection->registerService(
47 WrtSecurity::SecurityDaemonConfig::SERVICE_NAME());
50 void SecurityDBusService::stop()
52 LogDebug("SecurityDBusService stopping");
56 void SecurityDBusService::initialize()
58 LogDebug("SecurityDBusService initializing");
61 addInterface(WrtSecurity::SecurityDaemonConfig::OBJECT_PATH(),
62 std::make_shared<RPC::AceServerDBusInterface>());
63 addInterface(WrtSecurity::SecurityDaemonConfig::OBJECT_PATH(),
64 std::make_shared<RPC::OcspServerDBusInterface>());
65 addInterface(WrtSecurity::SecurityDaemonConfig::OBJECT_PATH(),
66 std::make_shared<RPC::PopupResponseDBusInterface>());
69 void SecurityDBusService::addInterface(const std::string& objectPath,
70 const InterfaceDispatcherPtr& dispatcher)
73 DPL::DBus::Interface::fromXMLString(dispatcher->getXmlSignature());
76 ThrowMsg(DPL::Exception, "No interface description.");
79 auto iface = ifaces.at(0);
80 iface->setDispatcher(dispatcher.get());
82 m_dispatchers.push_back(dispatcher);
83 m_objects.push_back(DPL::DBus::Object::create(objectPath, iface));
86 void SecurityDBusService::deinitialize()
88 LogDebug("SecurityDBusService deinitializing");
90 m_dispatchers.clear();
93 #ifdef DBUS_CONNECTION
94 DAEMON_REGISTER_SERVICE_MODULE(SecurityDBusService)
95 #endif //DBUS_CONNECTION