blob: 1e31e9cb590e2d968c03551a2a5ec438c9f840d5 [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"
14#include "../util/time.hpp"
15
Alexander Afanasyeve2dcdfd2014-02-07 15:53:28 -080016namespace ndn {
Alexander Afanasyevaa0e7da2014-03-17 14:37:33 -070017
Yingdi Yu7640cb32014-01-29 20:00:50 -080018class CertificateCacheTtl : public CertificateCache
19{
20public:
Alexander Afanasyevaa0e7da2014-03-17 14:37:33 -070021 CertificateCacheTtl(shared_ptr<boost::asio::io_service> io, const time::seconds& defaultTtl = time::seconds(3600));
22
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
27 insertCertificate(ptr_lib::shared_ptr<const IdentityCertificate> certificate);
Alexander Afanasyevaa0e7da2014-03-17 14:37:33 -070028
29 virtual ptr_lib::shared_ptr<const IdentityCertificate>
Yingdi Yu7640cb32014-01-29 20:00:50 -080030 getCertificate(const Name & certificateNameWithoutVersion);
31
Alexander Afanasyevaa0e7da2014-03-17 14:37:33 -070032private:
Yingdi Yu7640cb32014-01-29 20:00:50 -080033 void
34 insert(ptr_lib::shared_ptr<const IdentityCertificate> certificate);
Alexander Afanasyevaa0e7da2014-03-17 14:37:33 -070035
Yingdi Yu7640cb32014-01-29 20:00:50 -080036 void
37 remove(const Name &certificateName);
38
39protected:
40 typedef std::map<Name, ptr_lib::shared_ptr<const IdentityCertificate> > Cache;
41 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