2 * Copyright (c) 2015 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 src/SecurityManager/DataProvider.cpp
18 * @author Aleksander Zdyb <a.zdyb@samsung.com>
27 #include <SecurityManager/ErrorException.h>
29 #include "DataProvider.h"
31 namespace SecurityManager {
33 DataProvider::DataProvider(BaseSecurityManagerWrapper &smApi) : m_smApi(smApi) {}
35 Lad::DataProvider::GroupsList DataProvider::getResourceGroups(void) {
36 Lad::DataProvider::GroupsList retGroups;
38 char **groups = nullptr;
41 auto getRet = m_smApi.security_manager_groups_get(&groups, &groupsLen);
43 if (getRet != m_smApi.SECURITY_MANAGER_SUCCESS_CONST()) {
44 throw ErrorException("Could not get groups from Security Manager");
47 auto groupsDeleter = std::bind(&BaseSecurityManagerWrapper::security_manager_groups_free,
48 &m_smApi, std::placeholders::_1, groupsLen);
49 std::unique_ptr<char *, std::function<void(char **)>> groupsPtr(groups, groupsDeleter);
51 for (size_t i = 0; i < groupsLen; ++i) {
52 retGroups.push_back(groups[i]);
58 } /* namespace SecurityManager */