blob: 00f432d849c7a78be877fe41f399e15b7684dc24 [file] [log] [blame]
Jeff Thompsonfa306642013-06-17 15:06:57 -07001/* -*- Mode: C++; c-file-style: "gnu"; indent-tabs-mode:nil -*- */
2/*
3 * Copyright (c) 2013 University of California, Los Angeles
4 *
5 * This program is free software; you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License version 2 as
7 * published by the Free Software Foundation;
8 *
9 * This program is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
13 *
14 * You should have received a copy of the GNU General Public License
15 * along with this program; if not, write to the Free Software
16 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
17 *
18 * Author: Zhenkai Zhu <zhenkai@cs.ucla.edu>
19 * Alexander Afanasyev <alexander.afanasyev@ucla.edu>
20 */
21
22#ifndef NDN_CERT_H
23#define NDN_CERT_H
24
25#include "ndn.cxx/common.h"
26#include "ndn.cxx/name.h"
27#include "ndn.cxx/pco.h"
28#include "ndn.cxx/hash.h"
29#include <boost/shared_ptr.hpp>
30
31namespace ndn {
32
33class Cert
34{
35public:
36 enum VALIDITY
37 {
38 NOT_YET_VALID,
39 WITHIN_VALID_TIME_SPAN,
40 EXPIRED,
41 OTHER
42 };
43
44 Cert();
45 Cert(const PcoPtr &keyObject, const PcoPtr &metaObject);
46 ~Cert();
47
48 void
49 updateMeta(const PcoPtr &metaObject);
50
51 Name
52 name() { return m_name; }
53
54 Bytes
55 rawKeyBytes() { return m_rawKeyBytes; }
56
57 Hash
58 keyDigest() { return m_keyHash; }
59
60 std::string
61 realworldID() { return m_meta.realworldID; }
62
63 std::string
64 affilication() { return m_meta.affiliation; }
65
66 ccn_pkey *
67 pkey() { return m_pkey; }
68
69 VALIDITY
70 validity();
71
72private:
73 struct Meta
74 {
75 Meta(std::string id, std::string affi, time_t from, time_t to)
76 : realworldID(id)
77 , affiliation(affi)
78 , validFrom(from)
79 , validTo(to)
80 {
81 }
82 std::string realworldID;
83 std::string affiliation;
84 time_t validFrom;
85 time_t validTo;
86 };
87
88 Name m_name;
89 Hash m_keyHash; // publisherPublicKeyHash
90 Bytes m_rawKeyBytes;
91 ccn_pkey *m_pkey;
92 Meta m_meta;
93};
94
95typedef boost::shared_ptr<Cert> CertPtr;
96
97}
98
99#endif // NDN_CERT_H