blob: 17f06d52111360d1e30ff4b1fa13e34133491e56 [file] [log] [blame]
Zhenkai Zhu3457ed42013-03-12 15:15:21 -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
Alexander Afanasyev1dd37ed2013-08-14 18:08:09 -070022#ifndef NDNX_CERT_H
23#define NDNX_CERT_H
Zhenkai Zhu3457ed42013-03-12 15:15:21 -070024
Alexander Afanasyev1dd37ed2013-08-14 18:08:09 -070025#include "ndnx-common.h"
26#include "ndnx-name.h"
27#include "ndnx-pco.h"
Zhenkai Zhu3457ed42013-03-12 15:15:21 -070028#include "hash-helper.h"
29#include <boost/shared_ptr.hpp>
30
Alexander Afanasyev1dd37ed2013-08-14 18:08:09 -070031namespace Ndnx {
Zhenkai Zhu3457ed42013-03-12 15:15:21 -070032
Zhenkai Zhu9dd9adc2013-03-13 16:12:09 -070033class Cert
Zhenkai Zhu3457ed42013-03-12 15:15:21 -070034{
35public:
36 enum VALIDITY
37 {
38 NOT_YET_VALID,
Zhenkai Zhudd1f14d2013-03-13 12:04:28 -070039 WITHIN_VALID_TIME_SPAN,
Zhenkai Zhu3457ed42013-03-12 15:15:21 -070040 EXPIRED,
41 OTHER
42 };
43
Zhenkai Zhu9dd9adc2013-03-13 16:12:09 -070044 Cert();
45 Cert(const PcoPtr &keyObject, const PcoPtr &metaObject);
Zhenkai Zhud5d99be2013-03-13 19:15:56 -070046 ~Cert();
Zhenkai Zhu3457ed42013-03-12 15:15:21 -070047
48 void
49 updateMeta(const PcoPtr &metaObject);
50
51 Name
52 name() { return m_name; }
53
54 Bytes
Zhenkai Zhud5d99be2013-03-13 19:15:56 -070055 rawKeyBytes() { return m_rawKeyBytes; }
Zhenkai Zhu3457ed42013-03-12 15:15:21 -070056
57 Hash
Zhenkai Zhud5d99be2013-03-13 19:15:56 -070058 keyDigest() { return m_keyHash; }
Zhenkai Zhu3457ed42013-03-12 15:15:21 -070059
60 std::string
61 realworldID() { return m_meta.realworldID; }
62
63 std::string
64 affilication() { return m_meta.affiliation; }
65
Alexander Afanasyev1dd37ed2013-08-14 18:08:09 -070066 ndn_pkey *
Zhenkai Zhud5d99be2013-03-13 19:15:56 -070067 pkey() { return m_pkey; }
68
Zhenkai Zhu3457ed42013-03-12 15:15:21 -070069 VALIDITY
70 validity();
71
72private:
Zhenkai Zhu9dd9adc2013-03-13 16:12:09 -070073 struct Meta
Zhenkai Zhu3457ed42013-03-12 15:15:21 -070074 {
Zhenkai Zhu9dd9adc2013-03-13 16:12:09 -070075 Meta(std::string id, std::string affi, time_t from, time_t to)
Zhenkai Zhu3457ed42013-03-12 15:15:21 -070076 : 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;
Zhenkai Zhud5d99be2013-03-13 19:15:56 -070089 Hash m_keyHash; // publisherPublicKeyHash
90 Bytes m_rawKeyBytes;
Alexander Afanasyev1dd37ed2013-08-14 18:08:09 -070091 ndn_pkey *m_pkey;
Zhenkai Zhu9dd9adc2013-03-13 16:12:09 -070092 Meta m_meta;
Zhenkai Zhu3457ed42013-03-12 15:15:21 -070093};
94
Zhenkai Zhu9dd9adc2013-03-13 16:12:09 -070095typedef boost::shared_ptr<Cert> CertPtr;
Zhenkai Zhu3457ed42013-03-12 15:15:21 -070096
97}
98
Alexander Afanasyev1dd37ed2013-08-14 18:08:09 -070099#endif // NDNX_CERT_H