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 ocsp_service_dbus_interface.cpp
18 * @author Piotr Marcinkiewicz (p.marcinkiew@samsung.com)
20 * @brief Implementation of OCSP server API.
22 #include "ocsp_server_dbus_interface.h"
23 #include <vcore/VerificationStatus.h>
24 #include <dpl/foreach.h>
25 #include <vcore/CertificateVerifier.h>
26 #include <vcore/VerificationStatus.h>
27 #include <dpl/wrt-dao-ro/global_config.h>
28 #include <dpl/ace-dao-ro/common_dao_types.h>
29 #include <dpl/wrt-dao-ro/widget_dao_read_only.h>
30 #include "ocsp_controller.h"
36 using namespace WrtSecurity;
38 OcspServerDBusInterface::OcspServerDBusInterface():
39 DPL::DBus::InterfaceDispatcher(OcspServerApi::INTERFACE_NAME())
41 setXmlSignature("<node>"
42 " <interface name='" + OcspServerApi::INTERFACE_NAME() + "'>"
43 " <method name='" + OcspServerApi::ECHO_METHOD() + "'>"
44 " <arg type='s' name='input' direction='in'/>"
45 " <arg type='s' name='output' direction='out'/>"
47 " <method name='" + OcspServerApi::CHECK_ACCESS_METHOD() + "'>"
48 " <arg type='i' name='input' direction='in'/>"
49 " <arg type='i' name='output' direction='out'/>"
55 void OcspServerDBusInterface::onResponse(
56 OCSPControllerEvents::ErrorCode argError,
57 ValidationCore::WidgetVerificationStatus argState)
59 Assert(!m_invocationFifo.empty());
60 GDBusMethodInvocation* invocation = m_invocationFifo.front();
61 m_invocationFifo.pop_front();
63 if (OCSPControllerEvents::ErrorOK == argError) {
65 gint32 response = static_cast<gint32>(argState);
67 //Ownership is transferred to return value function
68 GVariant* varResponse = g_variant_new ("(i)", response);
69 //This function will unref invocation and it will be freed
70 LogDebug("OCSP dbus interface tries to send result");
71 g_dbus_method_invocation_return_value(invocation,
73 } else if (OCSPControllerEvents::ErrorNoWidget == argError) {
74 g_dbus_method_invocation_return_dbus_error(
76 "org.tizen.OcspCheck.WidgetNotFound",
77 "WidgetDAOReadOnly returned error WidgetNotFound");
78 } else if (OCSPControllerEvents::ErrorUnknown == argError) {
79 g_dbus_method_invocation_return_dbus_error(
81 "org.tizen.OcspCheck.UnknownError",
82 "WidgetDAOReadOnly returned unknown error");
84 Assert(false && "Not supported error code");
88 void OcspServerDBusInterface::onMethodCall(
89 const gchar* argMethodName,
90 GVariant* argParameters,
91 GDBusMethodInvocation* argInvocation)
93 if (OcspServerApi::ECHO_METHOD() == argMethodName){
94 // TODO: Deserialization should use
95 // DBus::SErverDeserialization::deserialize()
96 const gchar* arg = NULL;
97 g_variant_get(argParameters, "(&s)", &arg);
98 // TODO: Serialization should use
99 // DBus::SErverDeserialization::serialize()
100 gchar* response = g_strdup_printf(arg);
101 g_dbus_method_invocation_return_value(argInvocation,
102 g_variant_new ("(s)", response));
104 } else if (OcspServerApi::CHECK_ACCESS_METHOD() == argMethodName) {
106 //TODO: Check if argument is valid and report error for invalid
107 g_variant_get(argParameters, "(i)", &value);
108 WrtDB::DbWidgetHandle handle = static_cast<WrtDB::DbWidgetHandle>(
111 m_invocationFifo.push_back(argInvocation);
112 CONTROLLER_POST_EVENT(
114 OCSPControllerEvents::OCSPCheckEvent(
116 makeICDelegate(&OcspServerDBusInterface::onResponse)