2 * Copyright (c) 2011 Samsung Electronics Co., Ltd All Rights Reserved
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
8 * http://www.apache.org/licenses/LICENSE-2.0
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.
17 * @file vcore_service.cpp
18 * @author Lukasz Wrzosek (l.wrzosek@samsung.com)
20 * @brief This is implementation file of VCoreService service
23 #include <dpl/log/log.h>
24 #include <dpl/event/controller.h>
25 #include <dpl/generic_event.h>
29 #include <vcore/VCore.h>
30 #include <vcore/CachedOCSP.h>
31 #include <vcore/CachedCRL.h>
32 #include <dpl/wrt-dao-ro/global_config.h>
34 #include "security_daemon.h"
36 namespace VCoreService {
37 DECLARE_GENERIC_EVENT_0(UpdateCacheTimeReachedEvent)
38 using namespace ValidationCore;
40 class VCoreService : public SecurityDaemon::DaemonService,
41 DPL::Event::Controller<DPL::TypeListDecl<UpdateCacheTimeReachedEvent>::Type>
45 m_ignoreFurtherCacheUpdates(false),
46 m_timespan(static_cast<double>(CachedOCSP::OCSP_minTimeValid))
52 virtual void initialize()
54 using namespace WrtDB;
55 LogDebug("VCoreService initializing");
56 ValidationCore::AttachToThread();
57 ValidationCore::VCoreInit(
58 std::string(GlobalConfig::GetFingerprintListFile()),
59 std::string(GlobalConfig::GetFingerprintListSchema()),
60 std::string(GlobalConfig::GetVCoreDatabaseFilePath()));
65 LogDebug("Starting VCoreService");
66 OnEventReceived(UpdateCacheTimeReachedEvent());
71 LogDebug("Stopping VCoreService");
72 m_ignoreFurtherCacheUpdates = true;
75 virtual void deinitialize()
77 LogDebug("VCoreService deinitializing");
80 void OnEventReceived(const UpdateCacheTimeReachedEvent& /*event*/)
82 if (m_ignoreFurtherCacheUpdates) return;
84 this->PostTimedEvent(UpdateCacheTimeReachedEvent(), m_timespan);
86 LogDebug("calling ocsp module to cache update ...");
87 m_ocspCache.updateCache();
88 LogDebug("calling crl module to cache update ...");
89 m_crlCache.updateCache();
92 CachedOCSP m_ocspCache;
94 bool m_ignoreFurtherCacheUpdates;
96 const double m_timespan;
99 DAEMON_REGISTER_SERVICE_MODULE(VCoreService)
101 }//namespace VCoreService