Yingdi Yu | 7640cb3 | 2014-01-29 20:00:50 -0800 | [diff] [blame] | 1 | /* -*- 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 | |
| 8 | #ifndef NDN_CERTIFICATE_CACHE_TTL_HPP |
| 9 | #define NDN_CERTIFICATE_CACHE_TTL_HPP |
| 10 | |
Alexander Afanasyev | e2dcdfd | 2014-02-07 15:53:28 -0800 | [diff] [blame^] | 11 | #include "../common.hpp" |
Yingdi Yu | 7640cb3 | 2014-01-29 20:00:50 -0800 | [diff] [blame] | 12 | #include "certificate-cache.hpp" |
| 13 | #include "../util/scheduler.hpp" |
| 14 | #include "../util/time.hpp" |
| 15 | |
Alexander Afanasyev | e2dcdfd | 2014-02-07 15:53:28 -0800 | [diff] [blame^] | 16 | namespace ndn { |
Yingdi Yu | 7640cb3 | 2014-01-29 20:00:50 -0800 | [diff] [blame] | 17 | |
| 18 | class CertificateCacheTtl : public CertificateCache |
| 19 | { |
| 20 | public: |
| 21 | CertificateCacheTtl(shared_ptr<boost::asio::io_service> io, int defaultTtl = 3600); |
| 22 | |
| 23 | virtual |
| 24 | ~CertificateCacheTtl(); |
| 25 | |
| 26 | virtual void |
| 27 | insertCertificate(ptr_lib::shared_ptr<const IdentityCertificate> certificate); |
| 28 | |
| 29 | virtual ptr_lib::shared_ptr<const IdentityCertificate> |
| 30 | getCertificate(const Name & certificateNameWithoutVersion); |
| 31 | |
| 32 | private: |
| 33 | void |
| 34 | insert(ptr_lib::shared_ptr<const IdentityCertificate> certificate); |
| 35 | |
| 36 | void |
| 37 | remove(const Name &certificateName); |
| 38 | |
| 39 | protected: |
| 40 | typedef std::map<Name, ptr_lib::shared_ptr<const IdentityCertificate> > Cache; |
| 41 | typedef std::map<Name, EventId> EventTracker; |
| 42 | |
| 43 | int m_defaultTtl; |
| 44 | Cache m_cache; |
| 45 | EventTracker m_tracker; |
| 46 | Scheduler m_scheduler; |
| 47 | }; |
| 48 | |
| 49 | }//ndn |
| 50 | |
| 51 | #endif |