Remove boost dependency
[platform/core/appfw/app-installers.git] / src / common / step / security / step_get_privilege_level.cc
1 // Copyright (c) 2018 Samsung Electronics Co., Ltd All Rights Reserved
2 // Use of this source code is governed by an apache 2.0 license that can be
3 // found in the LICENSE file.
4
5 #include "common/step/security/step_get_privilege_level.h"
6
7 #include "common/certificate_validation.h"
8
9 namespace common_installer {
10 namespace security {
11
12 Step::Status StepGetPrivilegeLevel::process() {
13   PrivilegeLevel level = PrivilegeLevel::UNTRUSTED;
14
15   if (!GetSignatureFromFile(context_->pkgid.get(),
16       context_->is_readonly_package.get(), &level,
17       &context_->certificate_info.get()))
18     LOG(INFO) << "Failed to get privilege level from file";
19
20   if (context_->is_readonly_package.get())
21     level = PrivilegeLevel::PLATFORM;
22
23   if (level == PrivilegeLevel::UNTRUSTED) {
24     std::string error_message =
25         "Failed to get privilege level from file";
26     on_error_->on_error(Status::CERT_ERROR, error_message);
27     return Status::CERT_ERROR;
28   }
29
30   context_->privilege_level.set(level);
31   return Status::OK;
32 }
33
34 }  // namespace security
35 }  // namespace common_installer