namespace fs = boost::filesystem;
+bool SatifiesPrivilegeLevel(PrivilegeLevel required_level,
+ PrivilegeLevel allowed_level) {
+ return static_cast<int>(required_level) <= static_cast<int>(allowed_level);
+}
+
const char* PrivilegeLevelToString(PrivilegeLevel level) {
switch (level) {
case PrivilegeLevel::UNTRUSTED:
PLATFORM = 3
};
+bool SatifiesPrivilegeLevel(PrivilegeLevel required_level,
+ PrivilegeLevel allowed_level);
const char* PrivilegeLevelToString(PrivilegeLevel level);
// TODO(p.sikorski@samsung.com) this class should be divided into:
LOG(INFO) << "Privilege level: " << PrivilegeLevelToString(level);
context_->privilege_level.set(level);
- // TODO(t.iwanek): check settings for privilege level...
-
// TODO(t.iwanek): refactoring, move to wgt backend
bool is_webapp = context_->pkg_type.get() == "wgt";
if (!ValidatePrivilegeLevel(level, is_webapp,
# Target - sources
SET(SRCS
+ step/step_check_settings_level.cc
step/step_create_symbolic_link.cc
step/step_parse.cc
wgt_app_query_interface.cc
--- /dev/null
+// Copyright (c) 2015 Samsung Electronics Co., Ltd All Rights Reserved
+// Use of this source code is governed by a apache 2.0 license that can be
+// found in the LICENSE file.
+
+#include "wgt/step/step_check_settings_level.h"
+
+#include <manifest_handlers/setting_handler.h>
+
+#include <map>
+
+#include "common/utils/logging.h"
+
+#include "wgt/wgt_backend_data.h"
+
+namespace {
+
+bool ValidateSettingsForLevel(common_installer::PrivilegeLevel level,
+ const wgt::parse::SettingInfo& settings) {
+ if (settings.background_vibration()) {
+ common_installer::PrivilegeLevel required_level =
+ common_installer::PrivilegeLevel::PARTNER;
+ if (!common_installer::SatifiesPrivilegeLevel(required_level, level)) {
+ LOG(ERROR) << "background_vibration requires visibility level: "
+ << common_installer::PrivilegeLevelToString(required_level);
+ return false;
+ }
+ LOG(INFO) << "Setting: 'background-vibration' allowed";
+ }
+ return true;
+}
+
+} // namespace
+
+namespace wgt {
+namespace check_settings {
+
+common_installer::Step::Status StepCheckSettingsLevel::process() {
+ if (!ValidateSettingsForLevel(context_->privilege_level.get(),
+ static_cast<WgtBackendData*>(
+ context_->backend_data.get())->settings.get())) {
+ return Status::ERROR;
+ }
+ LOG(INFO) << "Settings privilege level checked";
+ return Status::OK;
+}
+
+} // namespace check_settings
+} // namespace wgt
--- /dev/null
+// Copyright (c) 2015 Samsung Electronics Co., Ltd All Rights Reserved
+// Use of this source code is governed by a apache 2.0 license that can be
+// found in the LICENSE file.
+
+#ifndef WGT_STEP_STEP_CHECK_SETTINGS_LEVEL_H_
+#define WGT_STEP_STEP_CHECK_SETTINGS_LEVEL_H_
+
+#include "common/app_installer.h"
+#include "common/context_installer.h"
+#include "common/step/step.h"
+#include "common/utils/logging.h"
+
+namespace wgt {
+namespace check_settings {
+
+class StepCheckSettingsLevel : public common_installer::Step {
+ public:
+ using Step::Step;
+
+ Status process() override;
+ Status clean() override { return Status::OK; }
+ Status undo() override { return Status::OK; }
+ Status precheck() override { return Status::OK; }
+
+ SCOPE_LOG_TAG(CheckSettingsLevel)
+};
+
+} // namespace check_settings
+} // namespace wgt
+
+#endif // WGT_STEP_STEP_CHECK_SETTINGS_LEVEL_H_
#include "common/step/step_update_security.h"
#include "wgt/step/step_create_symbolic_link.h"
+#include "wgt/step/step_check_settings_level.h"
#include "wgt/step/step_parse.h"
#include "wgt/wgt_app_query_interface.h"
installer.AddStep<ci::unzip::StepUnzip>();
installer.AddStep<wgt::parse::StepParse>();
installer.AddStep<ci::signature::StepCheckSignature>();
+ installer.AddStep<wgt::check_settings::StepCheckSettingsLevel>();
installer.AddStep<ci::copy::StepCopy>();
installer.AddStep<ci::create_storage::StepCreateStorageDirectories>();
installer.AddStep<wgt::symbolic_link::StepCreateSymbolicLink>();
installer.AddStep<ci::unzip::StepUnzip>();
installer.AddStep<wgt::parse::StepParse>();
installer.AddStep<ci::signature::StepCheckSignature>();
+ installer.AddStep<wgt::check_settings::StepCheckSettingsLevel>();
installer.AddStep<ci::old_manifest::StepOldManifest>();
installer.AddStep<ci::backup_manifest::StepBackupManifest>();
installer.AddStep<ci::backup_icons::StepBackupIcons>();