e899ad800e8e1ed5065c84f60fb0307638bc719f
[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
33 class WacSecurity : public WrtDB::IWacSecurity
34 {
35   public:
36     WacSecurity() :
37         mRecognized(false),
38         mDistributorSigned(false),
39         mWacSigned(false)
40     {
41     }
42
43     // from IWacSecurity
44     virtual const WrtDB::WidgetCertificateDataList& getCertificateList() const
45     {
46         return mCertificateList;
47     }
48
49     virtual bool isRecognized() const { return mRecognized; }
50
51     virtual bool isDistributorSigned() const { return mDistributorSigned; }
52
53     virtual bool isWacSigned() const { return mWacSigned; }
54
55     virtual void getCertificateChainList(
56             WrtDB::CertificateChainList& list) const;
57
58     virtual void getCertificateChainList(
59             WrtDB::CertificateChainList& list,
60             WrtDB::CertificateSource source) const;
61
62     void setRecognized(bool recognized) { mRecognized = recognized; }
63     void setDistributorSigned(bool distributorSigned)
64     {
65         mDistributorSigned = distributorSigned;
66     }
67     void setWacSigned(bool wacSigned) { mWacSigned = wacSigned; }
68
69     ValidationCore::CertificatePtr getAuthorCertificatePtr() const { return mAuthorCertificate;}
70     ValidationCore::CertificateCollectionList& getCertificateChainListRef()
71     {
72         return mCertificateChainList;
73     }
74
75     ValidationCore::CertificateCollectionList& getAuthorsCertificateChainListRef()
76     {
77         return mAuthorsCertificateChainList;
78     }
79
80     WrtDB::WidgetCertificateDataList& getCertificateListRef()
81     {
82         return mCertificateList;
83     }
84
85   private:
86     // This data are used to evaluate policy
87     WrtDB::WidgetCertificateDataList mCertificateList;
88
89     // author signature verified
90     bool mRecognized;
91     // known distribuor
92     bool mDistributorSigned;
93     // distributor is wac
94     bool mWacSigned;
95     // Author end entity certificate.
96     // Information from this certificate are shown to user
97     // during installation process.
98     ValidationCore::CertificatePtr mAuthorCertificate;
99     // This certificates are used by OCSP/CRL
100     ValidationCore::CertificateCollectionList mCertificateChainList;
101     // This authors certificates are used by tizen
102     ValidationCore::CertificateCollectionList mAuthorsCertificateChainList;
103 };
104
105 } // namespace WidgetInstall
106 } // namespace Jobs
107
108 #endif /* WACSECURITY_H_ */