8306f75848fbadd3acf1269281365b9fe0e28809
[platform/framework/web/wrt-installer.git] / src / jobs / widget_install / wac_security.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    wac_security.h
18  * @author  Krzysztof Jackiewicz(k.jackiewicz@samsung.com)
19  * @version 1.0
20  * @brief
21  */
22
23 #ifndef WACSECURITY_H_
24 #define WACSECURITY_H_
25
26 #include <dpl/wrt-dao-ro/widget_dao_read_only.h>
27 #include <vcore/Certificate.h>
28 #include <vcore/CertificateCollection.h>
29
30 namespace Jobs {
31 namespace WidgetInstall {
32 class WacSecurity : public WrtDB::IWacSecurity
33 {
34   public:
35     WacSecurity() :
36         mRecognized(false),
37         mDistributorSigned(false)
38     {}
39
40     // from IWacSecurity
41     virtual const WrtDB::WidgetCertificateDataList& getCertificateList() const
42     {
43         return mCertificateList;
44     }
45
46     virtual bool isRecognized() const
47     {
48         return mRecognized;
49     }
50
51     virtual bool isDistributorSigned() const
52     {
53         return mDistributorSigned;
54     }
55
56     // TODO : remove after wrt-commons released
57     virtual bool isWacSigned() const
58     {
59         return false;
60     }
61
62     virtual void getCertificateChainList(
63         WrtDB::CertificateChainList& list,
64         WrtDB::CertificateSource source) const;
65
66     void setRecognized(bool recognized)
67     {
68         mRecognized = recognized;
69     }
70     void setDistributorSigned(bool distributorSigned)
71     {
72         mDistributorSigned = distributorSigned;
73     }
74     void setAuthorCertificatePtr(ValidationCore::CertificatePtr certPtr)
75     {
76         mAuthorCertificate = certPtr;
77     }
78
79     ValidationCore::CertificatePtr getAuthorCertificatePtr() const
80     {
81         return mAuthorCertificate;
82     }
83     ValidationCore::CertificateCollectionList& getCertificateChainListRef()
84     {
85         return mCertificateChainList;
86     }
87
88     ValidationCore::CertificateCollectionList&
89     getAuthorsCertificateChainListRef()
90     {
91         return mAuthorsCertificateChainList;
92     }
93
94     WrtDB::WidgetCertificateDataList& getCertificateListRef()
95     {
96         return mCertificateList;
97     }
98
99   private:
100     // This data are used to evaluate policy
101     WrtDB::WidgetCertificateDataList mCertificateList;
102
103     // author signature verified
104     bool mRecognized;
105     // known distribuor
106     bool mDistributorSigned;
107     // Author end entity certificate.
108     // Information from this certificate are shown to user
109     // during installation process.
110     ValidationCore::CertificatePtr mAuthorCertificate;
111     // This certificates are used by OCSP/CRL
112     ValidationCore::CertificateCollectionList mCertificateChainList;
113     // This authors certificates are used by tizen
114     ValidationCore::CertificateCollectionList mAuthorsCertificateChainList;
115 };
116 } // namespace WidgetInstall
117 } // namespace Jobs
118
119 #endif /* WACSECURITY_H_ */