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 ace_service_dbus_interface.cpp
18 * @author Tomasz Swierczek (t.swierczek@samsung.com)
20 * @brief Implementation of ACE server API.
22 #include <dpl/foreach.h>
25 #include "ace_server_dbus_interface.h"
26 #include <dpl/dbus/dbus_server_deserialization.h>
27 #include <dpl/dbus/dbus_server_serialization.h>
29 #include <ace/Request.h>
30 #include <ace/PolicyResult.h>
31 #include <security_controller.h>
32 #include <attribute_facade.h>
37 void AceServerDBusInterface::onMethodCall(const gchar* methodName,
39 GDBusMethodInvocation* invocation)
41 using namespace WrtSecurity;
43 if (0 == g_strcmp0(methodName, AceServerApi::ECHO_METHOD().c_str()))
46 DPL::DBus::ServerDeserialization::deserialize(parameters, &str);
47 g_dbus_method_invocation_return_value(invocation,
48 DPL::DBus::ServerSerialization::serialize(str));
49 } else if (0 == g_strcmp0(methodName,
50 AceServerApi::CHECK_ACCESS_METHOD().c_str()))
53 std::string subject, resource, sessionId;
54 std::vector<std::string> paramNames, paramValues;
55 if (!DPL::DBus::ServerDeserialization::deserialize(parameters,
62 g_dbus_method_invocation_return_dbus_error(
64 "org.tizen.AceCheckAccessInterface.UnknownError",
65 "Error in deserializing input parameters");
68 if (paramNames.size() != paramValues.size()) {
69 g_dbus_method_invocation_return_dbus_error(
71 "org.tizen.AceCheckAccessInterface.UnknownError",
72 "Varying sizes of parameter names and parameter values");
75 LogDebug("We got subject: " << subject);
76 LogDebug("We got resource: " << resource);
78 FunctionParamImpl params;
79 for (size_t i = 0; i < paramNames.size(); ++i) {
80 params.addAttribute(paramNames[i], paramValues[i]);
83 Request request(widgetHandle,
84 WidgetExecutionPhase_Invoke,
86 request.addDeviceCapability(resource);
88 PolicyResult result(PolicyEffect::DENY);
89 CONTROLLER_POST_SYNC_EVENT(
91 SecurityControllerEvents::CheckRuntimeCallSyncEvent(
96 int response = PolicyResult::serialize(result);
97 g_dbus_method_invocation_return_value(invocation,
98 DPL::DBus::ServerSerialization::serialize(response));
99 } else if (0 == g_strcmp0(methodName,
100 AceServerApi::CHECK_ACCESS_INSTALL_METHOD().c_str()))
103 std::string resource;
104 if (!DPL::DBus::ServerDeserialization::deserialize(parameters,
107 g_dbus_method_invocation_return_dbus_error(
109 "org.tizen.AceCheckAccessInterface.UnknownError",
110 "Error in deserializing input parameters");
113 LogDebug("We got handle: " << widgetHandle);
114 LogDebug("We got resource: " << resource);
116 Request request(widgetHandle,
117 WidgetExecutionPhase_WidgetInstall);
118 request.addDeviceCapability(resource);
120 PolicyResult result(PolicyEffect::DENY);
121 CONTROLLER_POST_SYNC_EVENT(
123 SecurityControllerEvents::CheckFunctionCallSyncEvent(
127 int response = PolicyResult::serialize(result);
128 g_dbus_method_invocation_return_value(invocation,
129 DPL::DBus::ServerSerialization::serialize(response));
130 } else if (0 == g_strcmp0(methodName,
131 AceServerApi::UPDATE_POLICY_METHOD().c_str()))
133 LogDebug("Policy update DBus message received");
134 CONTROLLER_POST_SYNC_EVENT(
136 SecurityControllerEvents::UpdatePolicySyncEvent());
137 g_dbus_method_invocation_return_value(invocation, NULL);
139 // invalid method name
140 g_dbus_method_invocation_return_value(invocation, NULL);