1 // Copyright (c) 2015 Samsung Electronics Co., Ltd All Rights Reserved
2 // Use of this source code is governed by a apache 2.0 license that can be
3 // found in the LICENSE file.
5 #include "common/step/security/step_register_security.h"
7 #include <boost/filesystem.hpp>
10 #include "common/security_registration.h"
12 namespace common_installer {
15 Step::Status StepRegisterSecurity::precheck() {
16 if (context_->pkg_path.get().empty()) {
17 LOG(ERROR) << "pkg_path attribute is empty";
18 return Step::Status::INVALID_VALUE;
20 if (!boost::filesystem::exists(context_->pkg_path.get())) {
21 LOG(ERROR) << "pkg_path ("
22 << context_->pkg_path.get()
23 << ") path does not exist";
24 return Step::Status::INVALID_VALUE;
27 if (context_->pkgid.get().empty()) {
28 LOG(ERROR) << "pkgid attribute is empty";
29 return Step::Status::INVALID_VALUE;
32 if (!context_->manifest_data.get()) {
33 LOG(ERROR) << "manifest_data attribute is empty";
34 return Step::Status::INVALID_VALUE;
37 return Step::Status::OK;
40 Step::Status StepRegisterSecurity::process() {
41 std::string error_message;
42 if (!RegisterSecurityContextForManifest(
43 context_->pkgid.get(), context_->pkg_path.get(), context_->uid.get(),
44 &context_->certificate_info.get(), context_->manifest_data.get(),
45 context_->cross_app_rules.get(), &error_message)) {
46 if (!error_message.empty()) {
47 LOG(ERROR) << "error_message: " << error_message;
48 on_error(Status::SECURITY_ERROR, error_message);
50 return Status::SECURITY_ERROR;
52 if (!RegisterSecurityContextForPath(
53 context_->pkgid.get(), context_->pkg_path.get(), context_->uid.get(),
55 if (!error_message.empty()) {
56 LOG(ERROR) << "error_message: " << error_message;
57 on_error(Status::SECURITY_ERROR, error_message);
59 return Status::SECURITY_ERROR;
61 LOG(DEBUG) << "Security context installed";
65 } // namespace security
66 } // namespace common_installer