blob: e8725c1077eca9bfe5e8d1e9d95b48797f2f7abf [file] [log] [blame]
Yingdi Yu7640cb32014-01-29 20:00:50 -08001/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil -*- */
2/**
3 * Copyright (C) 2013 Regents of the University of California.
4 * @author: Yingdi Yu <yingdi@cs.ucla.edu>
5 * See COPYING for copyright and distribution information.
6 */
7
Yingdi Yufc40d872014-02-18 12:56:04 -08008#ifndef NDN_SECURITY_CERTIFICATE_CACHE_TTL_HPP
9#define NDN_SECURITY_CERTIFICATE_CACHE_TTL_HPP
Yingdi Yu7640cb32014-01-29 20:00:50 -080010
Alexander Afanasyeve2dcdfd2014-02-07 15:53:28 -080011#include "../common.hpp"
Yingdi Yu7640cb32014-01-29 20:00:50 -080012#include "certificate-cache.hpp"
13#include "../util/scheduler.hpp"
Yingdi Yu7640cb32014-01-29 20:00:50 -080014
Alexander Afanasyeve2dcdfd2014-02-07 15:53:28 -080015namespace ndn {
Alexander Afanasyevaa0e7da2014-03-17 14:37:33 -070016
Yingdi Yu7640cb32014-01-29 20:00:50 -080017class CertificateCacheTtl : public CertificateCache
18{
19public:
Yingdi Yu4b8c6a22014-04-15 23:00:54 -070020 CertificateCacheTtl(shared_ptr<boost::asio::io_service> io,
21 const time::seconds& defaultTtl = time::seconds(3600));
Alexander Afanasyevaa0e7da2014-03-17 14:37:33 -070022
Yingdi Yu7640cb32014-01-29 20:00:50 -080023 virtual
24 ~CertificateCacheTtl();
Alexander Afanasyevaa0e7da2014-03-17 14:37:33 -070025
Yingdi Yu7640cb32014-01-29 20:00:50 -080026 virtual void
Yingdi Yu4b8c6a22014-04-15 23:00:54 -070027 insertCertificate(shared_ptr<const IdentityCertificate> certificate);
Alexander Afanasyevaa0e7da2014-03-17 14:37:33 -070028
Yingdi Yu4b8c6a22014-04-15 23:00:54 -070029 virtual shared_ptr<const IdentityCertificate>
Alexander Afanasyevfdbfc6d2014-04-14 15:12:11 -070030 getCertificate(const Name& certificateNameWithoutVersion);
Yingdi Yu7640cb32014-01-29 20:00:50 -080031
Alexander Afanasyevaa0e7da2014-03-17 14:37:33 -070032private:
Yingdi Yu7640cb32014-01-29 20:00:50 -080033 void
Yingdi Yu4b8c6a22014-04-15 23:00:54 -070034 insert(shared_ptr<const IdentityCertificate> certificate);
Alexander Afanasyevaa0e7da2014-03-17 14:37:33 -070035
Yingdi Yu7640cb32014-01-29 20:00:50 -080036 void
Alexander Afanasyevfdbfc6d2014-04-14 15:12:11 -070037 remove(const Name& certificateName);
Yingdi Yu7640cb32014-01-29 20:00:50 -080038
39protected:
Yingdi Yu4b8c6a22014-04-15 23:00:54 -070040 typedef std::map<Name, shared_ptr<const IdentityCertificate> > Cache;
Yingdi Yu7640cb32014-01-29 20:00:50 -080041 typedef std::map<Name, EventId> EventTracker;
42
Alexander Afanasyevaa0e7da2014-03-17 14:37:33 -070043 time::seconds m_defaultTtl;
Yingdi Yu7640cb32014-01-29 20:00:50 -080044 Cache m_cache;
45 EventTracker m_tracker;
46 Scheduler m_scheduler;
47};
48
Yingdi Yufc40d872014-02-18 12:56:04 -080049} // namespace ndn
Yingdi Yu7640cb32014-01-29 20:00:50 -080050
Yingdi Yufc40d872014-02-18 12:56:04 -080051#endif //NDN_SECURITY_CERTIFICATE_CACHE_TTL_HPP