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