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 view_logic_keys_support.cpp
18 * @author Pawel Sikorski (p.sikorski@samsung.com)
19 * @brief Implementation file of SecuritySupport API used by ViewLogic
22 #include "view_logic_security_support.h"
24 #include <dpl/string.h>
25 #include <dpl/log/log.h>
26 #include <dpl/wrt-dao-ro/global_dao_read_only.h>
27 #include <dpl/wrt-dao-ro/widget_dao_read_only.h>
28 #include <ace_api_client.h>
29 #include <dpl/utils/warp_iri.h>
30 #include <widget_data_types.h>
32 namespace ViewModule {
33 namespace SecuritySupport {
37 const char *GEOLOCATION_DEV_CAP = "geolocation.position";
38 const char *GEOLOCATION_PARAM_NAME = "param:enableHighAccuracy";
39 const char *GEOLOCATION_PARAM_VALUE = "true";
42 const DPL::String& tizenId,
44 const char *paramName,
45 const char *paramValue)
47 WrtDB::WidgetDAOReadOnly dao(tizenId);
48 ace_request_t aceRequest;
49 aceRequest.widget_handle = dao.getHandle();
50 aceRequest.session_id = const_cast<const ace_string_t>("");
51 aceRequest.feature_list.count = 0;
52 aceRequest.dev_cap_list.count = 1;
53 aceRequest.dev_cap_list.items = new ace_dev_cap_t[1];
54 aceRequest.dev_cap_list.items[0].name =
55 const_cast<ace_string_t>(devCap);
57 aceRequest.dev_cap_list.items[0].param_list.count = paramName ? 1 : 0;
58 aceRequest.dev_cap_list.items[0].param_list.items = NULL;
61 aceRequest.dev_cap_list.items[0].param_list.items = new ace_param_t[1];
62 aceRequest.dev_cap_list.items[0].param_list.items[0].name =
63 const_cast<ace_string_t>(paramName);
64 aceRequest.dev_cap_list.items[0].param_list.items[0].value =
65 const_cast<ace_string_t>(paramValue);
68 LogDebug("Making ace check with new C-API");
69 ace_bool_t result = ACE_FALSE;
70 ace_return_t ret = ace_check_access(&aceRequest, &result);
72 LogDebug("Result is: " << static_cast<int>(result));
74 delete [] aceRequest.dev_cap_list.items[0].param_list.items;
75 delete [] aceRequest.dev_cap_list.items;
77 return ACE_OK == ret && ACE_TRUE == result;
80 } //TODO copied from view_logic.cpp
82 bool checkWhitelist(const char *url)
84 LogInfo("Check WhiteList");
85 // White List should be checked in only case of Tizen widget
86 if (WarpIRI::isIRISchemaIgnored(url)) {
87 // scheme is not supported by WARP
91 WidgetAccessList whiteURIList(WrtDB::GlobalDAOReadOnly::GetWhiteURIList());
92 return whiteURIList.isRequiredIRI(DPL::FromUTF8String(std::string(url)));
95 bool geolocationACECheck(const DPL::String& tizenId, bool highAccuracy) {
96 const char *paramName = NULL;
97 const char *paramValue = NULL;
99 paramName = GEOLOCATION_PARAM_NAME;
100 paramValue = GEOLOCATION_PARAM_VALUE;
102 return simpleAceCheck(
109 } // namespace SecuritySupport
110 } //namespace ViewModule