${DPL_PATH}/core/src/string.cpp
${DPL_PATH}/db/src/naive_synchronization_object.cpp
${DPL_PATH}/db/src/sql_connection.cpp
+ ${COMMON_PATH}/config.cpp
${COMMON_PATH}/connection.cpp
${COMMON_PATH}/cynara.cpp
${COMMON_PATH}/file-lock.cpp
--- /dev/null
+/*
+ * Copyright (c) 2015 Samsung Electronics Co., Ltd All Rights Reserved
+ *
+ * Contact: Rafal Krypa <r.krypa@samsung.com>
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License
+ */
+/*
+ * @file config.cpp
+ * @author Zofia Abramowska <z.abramowska@samsung.com>
+ * @version 1.0
+ * @brief Setting values of Configuration options
+ */
+
+#include <config.h>
+
+namespace SecurityManager {
+
+namespace Config {
+
+const std::string PRIVILEGE_VERSION =
+#ifdef PRIVILEGE_VERSION
+ PRIVILEGE_VERSION
+#else
+ "3.0"
+#endif
+;
+};
+
+} /* namespace SecurityManager */
--- /dev/null
+/*
+ * Copyright (c) 2015 Samsung Electronics Co., Ltd All Rights Reserved
+ *
+ * Contact: Rafal Krypa <r.krypa@samsung.com>
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License
+ */
+/*
+ * @file config.h
+ * @author Zofia Abramowska <z.abramowska@samsung.com>
+ * @version 1.0
+ * @brief Definition of Configuration options
+ */
+
+#ifndef SECURITY_MANAGER_CONFIG_
+#define SECURITY_MANAGER_CONFIG_
+
+#include <string>
+
+namespace SecurityManager {
+
+namespace Config {
+
+extern const std::string PRIVILEGE_VERSION;
+
+};
+
+} /* namespace SecurityManager */
+
+#endif /* SECURITY_MANAGER_CONFIG_ */
*/
int policyGetDesc(std::vector<std::string> &descriptions);
+/**
+ * Process getting privileges mappings from one version to another.
+ *
+ * @param[in] version_from version to be mapped from
+ * @param[in] version_to version to be mapped to
+ * @param[in] privileges vector of privileges to be mapped
+ * @param[out] mappings mappings of given privileges
+ */
+int getPrivilegesMappings(const std::string &version_from,
+ const std::string &version_to,
+ const std::vector<std::string> &privileges,
+ std::vector<std::string> &mappings);
+
} /* namespace ServiceImpl */
} /* namespace SecurityManager */
#include <dpl/log/log.h>
#include <tzplatform_config.h>
+#include <config.h>
#include "protocols.h"
#include "privilege_db.h"
#include "cynara.h"
return ret;
}
+int getPrivilegesMappings(const std::string &version_from,
+ const std::string &version_to,
+ const std::vector<std::string> &privileges,
+ std::vector<std::string> &mappings)
+{
+ int errorRet;
+ try {
+ std::string finalVersionTo;
+ if (version_to.empty()) {
+ finalVersionTo = Config::PRIVILEGE_VERSION;
+ } else {
+ finalVersionTo = version_to;
+ }
+
+ PrivilegeDb::getInstance().BeginTransaction();
+ if (privileges.size() == 0) {
+ PrivilegeDb::getInstance().GetDefaultMapping(version_from, finalVersionTo, mappings);
+ } else if ( privileges.size() == 1) {
+ PrivilegeDb::getInstance().GetPrivilegeMappings(version_from, finalVersionTo,
+ privileges.front(), mappings);
+ } else {
+ PrivilegeDb::getInstance().GetPrivilegesMappings(version_from, finalVersionTo,
+ privileges, mappings);
+ }
+ PrivilegeDb::getInstance().CommitTransaction();
+ return SECURITY_MANAGER_API_SUCCESS;
+ } catch (const PrivilegeDb::Exception::IOError &e) {
+ LogError("Cannot access application database: " << e.DumpToString());
+ errorRet = SECURITY_MANAGER_API_ERROR_SERVER_ERROR;
+ } catch (const PrivilegeDb::Exception::InternalError &e) {
+ LogError("Error while getting privilege mapping from database: " << e.DumpToString());
+ errorRet = SECURITY_MANAGER_API_ERROR_SERVER_ERROR;
+ } catch (const std::bad_alloc &e) {
+ LogError("Memory allocation failed: " << e.what());
+ errorRet = SECURITY_MANAGER_API_ERROR_OUT_OF_MEMORY;
+ } catch (const std::exception &e) {
+ LogError("Some exception thrown : " << e.what());
+ errorRet = SECURITY_MANAGER_API_ERROR_UNKNOWN;
+ } catch (...) {
+ LogError("Unknown exception thrown");
+ errorRet = SECURITY_MANAGER_API_ERROR_UNKNOWN;
+ }
+ PrivilegeDb::getInstance().RollbackTransaction();
+ return errorRet;
+}
+
} /* namespace ServiceImpl */
} /* namespace SecurityManager */
Deserialization::Deserialize(recv, version_to);
Deserialization::Deserialize(recv, privileges);
- int ret = SECURITY_MANAGER_API_SUCCESS;
std::vector<std::string> mappings;
+ int ret = ServiceImpl::getPrivilegesMappings(version_from, version_to, privileges, mappings);
+
Serialization::Serialize(send, ret);
Serialization::Serialize(send, mappings);
}