Tizen 2.1 base
[framework/web/wrt-commons.git] / modules / vcore / src / vcore / VerificationStatus.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 #ifndef _SRC_VALIDATION_CORE_VERIFICATION_STATUS_H_
17 #define _SRC_VALIDATION_CORE_VERIFICATION_STATUS_H_
18
19 namespace ValidationCore {
20 enum VerificationStatus
21 {
22     //! The certificate has not been revoked.
23     /*! Connection to OCSP responder was successful and the certificate
24      *  has not been revoked.
25      */
26     VERIFICATION_STATUS_GOOD = 1,
27
28     //! The certificate has been revoked.
29     /*! Connection to OCSP responder was successful and the certificate
30      *  has been revoked.
31      *  RFC2560: "The "revoked" state indicates that the certificate has
32      *  been revoked (either permanantly or temporarily
33      *  (on hold))."
34      */
35     VERIFICATION_STATUS_REVOKED = 1 << 1,
36
37     //! The certificate status is unknown.
38     /*! Connection to OCSP responder was successful and the certificate
39      *  has unknown status.
40      *
41      *  RFC2560: "The "unknown" state indicates that the responder
42      *  doesn't know about the certificate being requested."
43      */
44     VERIFICATION_STATUS_UNKNOWN = 1 << 2,
45
46     //! The certificate status was not figure out.
47     /*! The response from ocsp/crl server contains broken signature. */
48     VERIFICATION_STATUS_VERIFICATION_ERROR = 1 << 3,
49
50     //! The certificate status was not figure out.
51     /*! The certificate does not contain ocsp/crl extension. */
52     VERIFICATION_STATUS_NOT_SUPPORT = 1 << 4,
53
54     //! The certificate status was not figure out.
55     /*! The CertMgr could not connect to OCSP responder. */
56     VERIFICATION_STATUS_CONNECTION_FAILED = 1 << 5,
57
58     //! The certificate status is unknown due to internal error inside OCSP
59     VERIFICATION_STATUS_ERROR = 1 << 6
60 };
61
62 class VerificationStatusSet
63 {
64   public:
65     VerificationStatusSet() : m_verdictMap(0)
66     {
67     }
68
69     inline void add(VerificationStatus status)
70     {
71         m_verdictMap |= status;
72     }
73
74     inline bool contains(VerificationStatus status) const
75     {
76         return m_verdictMap & status;
77     }
78
79     inline bool isEmpty() const
80     {
81         return 0 == m_verdictMap;
82     }
83
84     inline void operator+=(const VerificationStatusSet &second)
85     {
86         m_verdictMap |= second.m_verdictMap;
87     }
88
89     inline void reset()
90     {
91         m_verdictMap = 0;
92     }
93
94     VerificationStatus convertToStatus() const;
95
96   private:
97     unsigned int m_verdictMap;
98 };
99
100 /* TODO this status should be defined in wrt-engine sources */
101 enum WidgetVerificationStatus
102 {
103     // All certificate has been veficated and all certificates are good.
104     // Widget is able to be installed.
105     WIDGET_VERIFICATION_STATUS_GOOD,
106     // Some certificate has been revoked. Widget is not able to be installed.
107     WIDGET_VERIFICATION_STATUS_REVOKED,
108 };
109 } // namespace ValidationCore
110
111 #endif // _SRC_VALIDATION_CORE_VERIFICATION_STATUS_H_