Tizen 2.1 base
[framework/web/wrt-commons.git] / modules / vcore / src / vcore / CachedCRL.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       CachedCRL.h
19  * @author     Tomasz Swierczek (t.swierczek@samsung.com)
20  * @version    0.1
21  * @brief      Header file for smart cached CRL class
22  */
23
24 #ifndef _SRC_VALIDATION_CORE_CACHED_CRL_
25 #define _SRC_VALIDATION_CORE_CACHED_CRL_
26
27 #include "CRL.h"
28 #include "IAbstractResponseCache.h"
29
30 namespace ValidationCore {
31
32 class CachedCRL : public IAbstractResponseCache {
33   public:
34     // cache can't be refreshed more frequently than CRL_minTimeValid
35     static const time_t CRL_minTimeValid;
36
37     // to be even more secure, cache will be refreshed for certificate at least
38     // after CRL_maxTimeValid from last response
39     static const time_t CRL_maxTimeValid;
40
41     // upon cache refresh, responses that will be invalid in CRL_refreshBefore
42     // seconds will be refreshed
43     static const time_t CRL_refreshBefore;
44
45     VerificationStatus check(const CertificateCollection &certs);
46     VerificationStatus checkEndEntity(CertificateCollection &certs);
47     void updateCache();
48
49     CachedCRL()
50     {
51     }
52     virtual ~CachedCRL()
53     {
54     }
55
56   private:
57
58     // updates CRL cache for distributor URI
59     // useExpiredShift ==true should be used in cron/global cache update
60     // since it updates all CRLs that will be out of date in next
61     // CRL_refreshBefore seconds
62     bool updateCRLForUri(const std::string & uri,
63                          bool useExpiredShift);
64     time_t getNextUpdateTime(time_t now, time_t response_validity);
65 };
66
67 } // namespace ValidationCore
68
69 #endif /* _SRC_VALIDATION_CORE_CACHED_CRL_ */