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.
5 #include "common/step/security/step_get_privilege_level.h"
7 #include "common/certificate_validation.h"
9 namespace common_installer {
12 Step::Status StepGetPrivilegeLevel::process() {
13 PrivilegeLevel level = PrivilegeLevel::UNTRUSTED;
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";
20 if (context_->is_readonly_package.get())
21 level = PrivilegeLevel::PLATFORM;
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;
30 context_->privilege_level.set(level);
34 } // namespace security
35 } // namespace common_installer