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 if (NULL != communicationClient) {
34 LogError("wrt_ocsp_api already initialized");
35 return WRT_OCSP_INTERNAL_ERROR;
39 communicationClient = new WrtSecurity::Communication::Client(WrtSecurity::OcspServerApi::INTERFACE_NAME());
40 } Catch (WrtSecurity::Communication::Client::Exception::SecurityCommunicationClientException) {
41 LogError("Can't connect to daemon");
42 return WRT_OCSP_INTERNAL_ERROR;
44 LogInfo("Initialized");
48 wrt_ocsp_return_t wrt_ocsp_shutdown(void){
49 if (NULL == communicationClient) {
50 LogError("wrt_ocsp_api not initialized");
51 return WRT_OCSP_INTERNAL_ERROR;
53 delete communicationClient;
54 communicationClient = NULL;
59 wrt_ocsp_return_t wrt_ocsp_verify_widget(wrt_ocsp_widget_handle_t handle,
60 wrt_ocsp_widget_verification_status_t* status){
64 LogError("Invalid arguments");
65 return WRT_OCSP_INVALID_ARGUMENTS;
70 communicationClient->call(WrtSecurity::OcspServerApi::CHECK_ACCESS_METHOD(),
73 } Catch (WrtSecurity::Communication::Client::Exception::SecurityCommunicationClientException) {
74 LogError("Problem with connection to daemon");
75 return WRT_OCSP_INTERNAL_ERROR;
77 (*status) = static_cast<wrt_ocsp_widget_verification_status_t>(intResponse);
78 LogInfo("Widget verified with response " << intResponse);