2969cebf70ec57226293af71d2d56a7fae6b213f
[platform/core/appfw/app-installers.git] / src / common / step / security / step_signature.h
1 // Copyright (c) 2019 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 #ifndef COMMON_STEP_SECURITY_STEP_SIGNATURE_H_
6 #define COMMON_STEP_SECURITY_STEP_SIGNATURE_H_
7
8 #include <boost/filesystem/path.hpp>
9
10 #include <manifest_parser/utils/logging.h>
11
12 #include <memory>
13
14 #include "common/installer_context.h"
15 #include "common/step/step.h"
16 #include "common/signature.h"
17
18 namespace common_installer {
19 namespace security {
20
21 /**
22  * \brief Step responsible for checking signature of given package and
23  *        saving certificates into individual files to restore certificate database.
24  *        Used by WGT and TPK backend
25  */
26 class StepSignature : public Step {
27  public:
28   using Step::Step;
29
30   StepSignature(InstallerContext* context, bool save_signature)
31       : Step(context), save_signature_(save_signature) {}
32
33   Status process() override;
34   Status undo() override;
35   Status clean() override;
36   Status precheck() override;
37
38  protected:
39   virtual boost::filesystem::path GetSignatureRoot() const;
40   virtual Status CheckPrivilegeLevel(PrivilegeLevel level);
41
42  private:
43   bool save_signature_;
44   boost::filesystem::path backup_path_;
45   std::unique_ptr<Signature> signature_;
46
47   STEP_NAME(Signature)
48 };
49
50 }  // namespace security
51 }  // namespace common_installer
52
53 #endif  // COMMON_STEP_SECURITY_STEP_SIGNATURE_H_