Tizen 2.1 base
[framework/web/wrt-commons.git] / modules / vcore / src / vcore / CachedOCSP.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  *
18  * @file       CachedOCSP.h
19  * @author     Tomasz Swierczek (t.swierczek@samsung.com)
20  * @version    0.1
21  * @brief      Header file for smart cached OCSP class
22  */
23
24 #ifndef _SRC_VALIDATION_CORE_CACHED_OCSP_
25 #define _SRC_VALIDATION_CORE_CACHED_OCSP_
26
27 #include "OCSP.h"
28 #include "IAbstractResponseCache.h"
29
30 namespace ValidationCore {
31
32 class CachedOCSP : public IAbstractResponseCache {
33   public:
34     // cache can't be refreshed more frequently than OCSP_minTimeValid
35     static const time_t OCSP_minTimeValid;
36
37     // to be even more secure, cache will be refreshed for certificate at least
38     // after OCSP_minTimeValid from last response
39     static const time_t OCSP_maxTimeValid;
40
41     // upon cache refresh, responses that will be invalid in OCSP_refreshBefore
42     // seconds will be refreshed
43     static const time_t OCSP_refreshBefore;
44
45     VerificationStatus check(const CertificateCollection &certs);
46     VerificationStatus checkEndEntity(CertificateCollection &certs);
47     void updateCache();
48
49     CachedOCSP()
50     {
51     }
52     virtual ~CachedOCSP()
53     {
54     }
55
56   private:
57
58     void getCertsForEndEntity(const CertificateCollection &certs,
59                               CertificateList* clst);
60     time_t getNextUpdateTime(time_t now, time_t response_validity);
61 };
62
63 } // namespace ValidationCore
64
65 #endif /* _SRC_VALIDATION_CORE_CACHED_OCSP_ */