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"
26 using namespace WrtSecurity;
28 OcspServerDBusInterface::OcspServerDBusInterface():
29 DPL::DBus::InterfaceDispatcher(OcspServerApi::INTERFACE_NAME())
31 setXmlSignature("<node>"
32 " <interface name='" + OcspServerApi::INTERFACE_NAME() + "'>"
33 " <method name='" + OcspServerApi::ECHO_METHOD() + "'>"
34 " <arg type='s' name='input' direction='in'/>"
35 " <arg type='s' name='output' direction='out'/>"
37 " <method name='" + OcspServerApi::CHECK_ACCESS_METHOD() + "'>"
38 " <arg type='i' name='input' direction='in'/>"
39 " <arg type='i' name='output' direction='out'/>"
46 void OcspServerDBusInterface::onMethodCall(
47 const gchar* argMethodName,
48 GVariant* argParameters,
49 GDBusMethodInvocation* argInvocation)
51 if (OcspServerApi::ECHO_METHOD() == argMethodName){
52 // TODO: Deserialization should use
53 // DBus::SErverDeserialization::deserialize()
54 const gchar* arg = NULL;
55 g_variant_get(argParameters, "(&s)", &arg);
56 // TODO: Serialization should use
57 // DBus::SErverDeserialization::serialize()
58 gchar* response = g_strdup_printf(arg);
59 g_dbus_method_invocation_return_value(argInvocation,
60 g_variant_new ("(s)", response));
62 } else if (OcspServerApi::CHECK_ACCESS_METHOD() == argMethodName) {
64 g_variant_get(argParameters, "(i)", &value);
66 // TODO: this is making OCSP service a stub! this HAS to be moved
67 // with proper implementation to cert-svc daemon
68 gint32 response = 0; // Certificates are valid for now
70 GVariant* varResponse = g_variant_new ("(i)", response);
71 //This function will unref invocation and it will be freed
72 LogDebug("OCSP dbus interface tries to send result");
73 g_dbus_method_invocation_return_value(argInvocation, varResponse);