Remove boost dependency
[platform/core/appfw/app-installers.git] / src / common / step / security / step_revoke_security.cc
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.
4
5 #include "common/step/security/step_revoke_security.h"
6
7 #include <string>
8
9 #include "common/security_registration.h"
10
11 namespace common_installer {
12 namespace security {
13
14 Step::Status StepRevokeSecurity::precheck() {
15   if (context_->pkgid.get().empty()) {
16     LOG(ERROR) << "pkgid attribute is empty";
17     return Step::Status::PACKAGE_NOT_FOUND;
18   }
19   if (!context_->manifest_data.get()) {
20     LOG(ERROR) << "manifest_data attribute is empty";
21     return Step::Status::MANIFEST_NOT_FOUND;
22   }
23
24   return Step::Status::OK;
25 }
26
27 Step::Status StepRevokeSecurity::clean() {
28   std::string error_message;
29   if (!UnregisterSecurityContextForManifest(
30       context_->pkgid.get(), context_->pkg_type.get(), context_->uid.get(),
31       context_->manifest_data.get(),
32       &error_message)) {
33     LOG(ERROR) << "Failure on unregistering security context for app "
34                << context_->pkgid.get();
35     if (!error_message.empty()) {
36       LOG(ERROR) << "error_message: " << error_message;
37       on_error_->on_error(Status::SECURITY_ERROR, error_message);
38     }
39   } else {
40     LOG(DEBUG) << "Security context uninstalled";
41   }
42   return Status::OK;
43 }
44
45 }  // namespace security
46 }  // namespace common_installer