blob: a86ee5e272ec8eac32d0796d6c45e7df215eee0c [file] [log] [blame]
Yingdi Yu7640cb32014-01-29 20:00:50 -08001/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil -*- */
2/**
Alexander Afanasyevdfa52c42014-04-24 21:10:11 -07003 * Copyright (c) 2013-2014, Regents of the University of California.
4 * All rights reserved.
5 *
6 * This file is part of ndn-cxx library (NDN C++ library with eXperimental eXtensions).
7 * See AUTHORS.md for complete list of ndn-cxx authors and contributors.
8 *
9 * This file licensed under New BSD License. See COPYING for detailed information about
10 * ndn-cxx library copyright, permissions, and redistribution restrictions.
11 *
12 * @author Yingdi Yu <http://irl.cs.ucla.edu/~yingdi/>
Yingdi Yu7640cb32014-01-29 20:00:50 -080013 */
14
Yingdi Yufc40d872014-02-18 12:56:04 -080015#ifndef NDN_SECURITY_CERTIFICATE_CACHE_TTL_HPP
16#define NDN_SECURITY_CERTIFICATE_CACHE_TTL_HPP
Yingdi Yu7640cb32014-01-29 20:00:50 -080017
Alexander Afanasyeve2dcdfd2014-02-07 15:53:28 -080018#include "../common.hpp"
Yingdi Yu7640cb32014-01-29 20:00:50 -080019#include "certificate-cache.hpp"
20#include "../util/scheduler.hpp"
Yingdi Yu7640cb32014-01-29 20:00:50 -080021
Alexander Afanasyeve2dcdfd2014-02-07 15:53:28 -080022namespace ndn {
Alexander Afanasyevaa0e7da2014-03-17 14:37:33 -070023
Yingdi Yu7640cb32014-01-29 20:00:50 -080024class CertificateCacheTtl : public CertificateCache
25{
26public:
Yingdi Yu4b8c6a22014-04-15 23:00:54 -070027 CertificateCacheTtl(shared_ptr<boost::asio::io_service> io,
28 const time::seconds& defaultTtl = time::seconds(3600));
Alexander Afanasyevaa0e7da2014-03-17 14:37:33 -070029
Yingdi Yu7640cb32014-01-29 20:00:50 -080030 virtual
31 ~CertificateCacheTtl();
Alexander Afanasyevaa0e7da2014-03-17 14:37:33 -070032
Yingdi Yu7640cb32014-01-29 20:00:50 -080033 virtual void
Yingdi Yu4b8c6a22014-04-15 23:00:54 -070034 insertCertificate(shared_ptr<const IdentityCertificate> certificate);
Alexander Afanasyevaa0e7da2014-03-17 14:37:33 -070035
Yingdi Yu4b8c6a22014-04-15 23:00:54 -070036 virtual shared_ptr<const IdentityCertificate>
Alexander Afanasyevfdbfc6d2014-04-14 15:12:11 -070037 getCertificate(const Name& certificateNameWithoutVersion);
Yingdi Yu7640cb32014-01-29 20:00:50 -080038
Alexander Afanasyevaa0e7da2014-03-17 14:37:33 -070039private:
Yingdi Yu7640cb32014-01-29 20:00:50 -080040 void
Yingdi Yu4b8c6a22014-04-15 23:00:54 -070041 insert(shared_ptr<const IdentityCertificate> certificate);
Alexander Afanasyevaa0e7da2014-03-17 14:37:33 -070042
Yingdi Yu7640cb32014-01-29 20:00:50 -080043 void
Alexander Afanasyevfdbfc6d2014-04-14 15:12:11 -070044 remove(const Name& certificateName);
Yingdi Yu7640cb32014-01-29 20:00:50 -080045
46protected:
Yingdi Yu4b8c6a22014-04-15 23:00:54 -070047 typedef std::map<Name, shared_ptr<const IdentityCertificate> > Cache;
Yingdi Yu7640cb32014-01-29 20:00:50 -080048 typedef std::map<Name, EventId> EventTracker;
49
Alexander Afanasyevaa0e7da2014-03-17 14:37:33 -070050 time::seconds m_defaultTtl;
Yingdi Yu7640cb32014-01-29 20:00:50 -080051 Cache m_cache;
52 EventTracker m_tracker;
53 Scheduler m_scheduler;
54};
55
Yingdi Yufc40d872014-02-18 12:56:04 -080056} // namespace ndn
Yingdi Yu7640cb32014-01-29 20:00:50 -080057
Yingdi Yufc40d872014-02-18 12:56:04 -080058#endif //NDN_SECURITY_CERTIFICATE_CACHE_TTL_HPP