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