1 // Copyright (c) 2019 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 #ifndef COMMON_SIGNATURE_H_
6 #define COMMON_SIGNATURE_H_
8 #include <pkgmgrinfo_basic.h>
10 #include <boost/iostreams/stream.hpp>
11 #include <boost/iostreams/device/file_descriptor.hpp>
15 #include "common/installer_context.h"
17 namespace bf = boost::filesystem;
18 namespace bi = boost::iostreams;
20 namespace common_installer {
24 Signature(RequestType request_type, std::string pkgid,
25 bool is_readonly_package, bool skip_check_reference,
26 CertificateInfo* cert_info) :
27 request_type_(request_type), pkgid_(pkgid),
28 is_readonly_package_(is_readonly_package),
29 skip_check_reference_(skip_check_reference),
30 cert_info_(cert_info) {}
31 virtual ~Signature() = default;
33 virtual bool CheckSignatures(bool check_reference, PrivilegeLevel* level,
34 boost::filesystem::path sig_root_path,
35 std::string* error_message);
36 bool GetPrivilegeLevel(boost::filesystem::path sig_root_path,
37 PrivilegeLevel* level,
38 std::string* error_message);
39 bool CheckMetadataPrivilege(PrivilegeLevel level, manifest_x* manifest,
40 std::string* error_message);
41 bool CheckSignatureMismatch(std::string* error_message);
43 bool StoreSignature(bi::stream<bi::file_descriptor_sink> *ofs,
44 const ValidationCore::CertificatePtr& cert,
45 const ValidationCore::CertificatePtr& im_cert,
46 const ValidationCore::CertificatePtr& root_cert);
48 bool RemoveSignature(const bf::path& path);
49 bool SaveSignature(const bf::path& path);
50 const bf::path& GetFilePath() const;
51 const bf::path& GetBackupPath() const;
54 RequestType request_type_;
56 bool is_readonly_package_;
57 bool skip_check_reference_;
58 CertificateInfo* cert_info_;
60 bf::path backup_path_;
63 } // namespace common_installer
65 #endif // COMMON_SIGNATURE_H_