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