2 * Copyright (c) 2012 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 wrt_ocsp_api.cpp
18 * @author Zofia Abramowska (z.abramowska@samsung.com)
20 * @brief This file contains implementation of WRT OCSP api
23 #include <dpl/log/log.h>
24 #include <dpl/dbus/dbus_client.h>
25 #include "ocsp_server_api.h"
26 #include "SecurityCommunicationClient.h"
28 #include "wrt_ocsp_api.h"
30 static WrtSecurity::Communication::Client *communicationClient = NULL;
32 wrt_ocsp_return_t wrt_ocsp_initialize(void){
33 #ifdef __SUPPORT_OCSP__
34 if (NULL != communicationClient) {
35 LogError("wrt_ocsp_api already initialized");
36 return WRT_OCSP_INTERNAL_ERROR;
40 communicationClient = new WrtSecurity::Communication::Client(WrtSecurity::OcspServerApi::INTERFACE_NAME());
41 } Catch (WrtSecurity::Communication::Client::Exception::SecurityCommunicationClientException) {
42 LogError("Can't connect to daemon");
43 return WRT_OCSP_INTERNAL_ERROR;
46 LogInfo("Initialized");
50 wrt_ocsp_return_t wrt_ocsp_shutdown(void){
51 #ifdef __SUPPORT_OCSP__
52 if (NULL == communicationClient) {
53 LogError("wrt_ocsp_api not initialized");
54 return WRT_OCSP_INTERNAL_ERROR;
56 delete communicationClient;
57 communicationClient = NULL;
63 wrt_ocsp_return_t wrt_ocsp_verify_widget(wrt_ocsp_widget_handle_t handle,
64 wrt_ocsp_widget_verification_status_t* status){
68 LogError("Invalid arguments");
69 return WRT_OCSP_INVALID_ARGUMENTS;
73 #ifdef __SUPPORT_OCSP__
75 communicationClient->call(WrtSecurity::OcspServerApi::CHECK_ACCESS_METHOD(),
78 } Catch (WrtSecurity::Communication::Client::Exception::SecurityCommunicationClientException) {
79 LogError("Problem with connection to daemon");
80 return WRT_OCSP_INTERNAL_ERROR;
84 (*status) = static_cast<wrt_ocsp_widget_verification_status_t>(intResponse);
85 LogInfo("Widget verified with response " << intResponse);