tizen 2.4 release
[framework/web/wrt-installer.git] / src / jobs / widget_install / task_certify.h
1 /*
2  * Copyright (c) 2011 Samsung Electronics Co., Ltd All Rights Reserved
3  *
4  *    Licensed under the Apache License, Version 2.0 (the "License");
5  *    you may not use this file except in compliance with the License.
6  *    You may obtain a copy of the License at
7  *
8  *        http://www.apache.org/licenses/LICENSE-2.0
9  *
10  *    Unless required by applicable law or agreed to in writing, software
11  *    distributed under the License is distributed on an "AS IS" BASIS,
12  *    WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  *    See the License for the specific language governing permissions and
14  *    limitations under the License.
15  */
16 /**
17  * @file    task_certify.h
18  * @author  Pawel Sikorski (p.sikorski@samgsung.com)
19  * @version
20  * @brief
21  */
22 #ifndef INSTALLER_CORE_JOS_WIDGET_INSTALL_TASK_CERTIFY_H
23 #define INSTALLER_CORE_JOS_WIDGET_INSTALL_TASK_CERTIFY_H
24
25 //SYSTEM INCLUDES
26 #include <map>
27 #include <string>
28 #include <libxml/c14n.h>
29
30 //WRT INCLUDES
31 #include <dpl/task.h>
32 #include <vcore/CertStoreType.h>
33 #include <vcore/SignatureFinder.h>
34 #include <widget_install/job_widget_install.h>
35
36 class InstallerContext;
37
38 namespace ValidationCore {
39 class SignatureData;
40 }
41
42 namespace Jobs {
43 namespace WidgetInstall {
44 class TaskCertify :
45     public DPL::TaskDecl<TaskCertify>
46 {
47   public:
48     TaskCertify(JobWidgetInstall * const &jobContext);
49
50     enum Level {
51         UNKNOWN  = 0,
52         PUBLIC   = 1,
53         PARTNER  = 2,
54         PLATFORM = 3
55     };
56
57   private:
58     JobWidgetInstall *m_jobContext;
59
60     typedef std::map<std::string, Level> secureSettingMap;
61     typedef std::map<std::string, Level>::iterator secureSettingIter;
62
63     //steps
64     void stepSignature();
65     void stepVerifyUpdate();
66     void stepCertifyLevel();
67
68     void StartStep();
69     void EndStep();
70
71     //util
72     void processDistributorSignature(const ValidationCore::SignatureData &data);
73     void processAuthorSignature(const ValidationCore::SignatureData &data);
74     void getSignatureFiles(std::string path,
75             ValidationCore::SignatureFileInfoSet& file);
76
77     bool isTizenWebApp() const;
78
79     Level getCertifyLevel();
80     bool checkConfigurationLevel(Level level);
81     bool checkSettingLevel(Level level);
82     bool checkNPRuntime(Level level);
83     bool checkServiceLevel(Level level);
84     bool checkBackgroundCategoryLevel(Level level);
85     std::string enumToString(Level level);
86     Level certTypeToLevel(ValidationCore::CertStoreId::Type type);
87 };
88 } //namespace WidgetInstall
89 } //namespace Jobs
90
91 #endif // INSTALLER_CORE_JOS_WIDGET_INSTALL_TASK_CERTIFY_H