Zhenkai Zhu | 3457ed4 | 2013-03-12 15:15:21 -0700 | [diff] [blame] | 1 | /* -*- 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 Afanasyev | 1dd37ed | 2013-08-14 18:08:09 -0700 | [diff] [blame^] | 22 | #ifndef NDNX_CERT_H |
| 23 | #define NDNX_CERT_H |
Zhenkai Zhu | 3457ed4 | 2013-03-12 15:15:21 -0700 | [diff] [blame] | 24 | |
Alexander Afanasyev | 1dd37ed | 2013-08-14 18:08:09 -0700 | [diff] [blame^] | 25 | #include "ndnx-common.h" |
| 26 | #include "ndnx-name.h" |
| 27 | #include "ndnx-pco.h" |
Zhenkai Zhu | 3457ed4 | 2013-03-12 15:15:21 -0700 | [diff] [blame] | 28 | #include "hash-helper.h" |
| 29 | #include <boost/shared_ptr.hpp> |
| 30 | |
Alexander Afanasyev | 1dd37ed | 2013-08-14 18:08:09 -0700 | [diff] [blame^] | 31 | namespace Ndnx { |
Zhenkai Zhu | 3457ed4 | 2013-03-12 15:15:21 -0700 | [diff] [blame] | 32 | |
Zhenkai Zhu | 9dd9adc | 2013-03-13 16:12:09 -0700 | [diff] [blame] | 33 | class Cert |
Zhenkai Zhu | 3457ed4 | 2013-03-12 15:15:21 -0700 | [diff] [blame] | 34 | { |
| 35 | public: |
| 36 | enum VALIDITY |
| 37 | { |
| 38 | NOT_YET_VALID, |
Zhenkai Zhu | dd1f14d | 2013-03-13 12:04:28 -0700 | [diff] [blame] | 39 | WITHIN_VALID_TIME_SPAN, |
Zhenkai Zhu | 3457ed4 | 2013-03-12 15:15:21 -0700 | [diff] [blame] | 40 | EXPIRED, |
| 41 | OTHER |
| 42 | }; |
| 43 | |
Zhenkai Zhu | 9dd9adc | 2013-03-13 16:12:09 -0700 | [diff] [blame] | 44 | Cert(); |
| 45 | Cert(const PcoPtr &keyObject, const PcoPtr &metaObject); |
Zhenkai Zhu | d5d99be | 2013-03-13 19:15:56 -0700 | [diff] [blame] | 46 | ~Cert(); |
Zhenkai Zhu | 3457ed4 | 2013-03-12 15:15:21 -0700 | [diff] [blame] | 47 | |
| 48 | void |
| 49 | updateMeta(const PcoPtr &metaObject); |
| 50 | |
| 51 | Name |
| 52 | name() { return m_name; } |
| 53 | |
| 54 | Bytes |
Zhenkai Zhu | d5d99be | 2013-03-13 19:15:56 -0700 | [diff] [blame] | 55 | rawKeyBytes() { return m_rawKeyBytes; } |
Zhenkai Zhu | 3457ed4 | 2013-03-12 15:15:21 -0700 | [diff] [blame] | 56 | |
| 57 | Hash |
Zhenkai Zhu | d5d99be | 2013-03-13 19:15:56 -0700 | [diff] [blame] | 58 | keyDigest() { return m_keyHash; } |
Zhenkai Zhu | 3457ed4 | 2013-03-12 15:15:21 -0700 | [diff] [blame] | 59 | |
| 60 | std::string |
| 61 | realworldID() { return m_meta.realworldID; } |
| 62 | |
| 63 | std::string |
| 64 | affilication() { return m_meta.affiliation; } |
| 65 | |
Alexander Afanasyev | 1dd37ed | 2013-08-14 18:08:09 -0700 | [diff] [blame^] | 66 | ndn_pkey * |
Zhenkai Zhu | d5d99be | 2013-03-13 19:15:56 -0700 | [diff] [blame] | 67 | pkey() { return m_pkey; } |
| 68 | |
Zhenkai Zhu | 3457ed4 | 2013-03-12 15:15:21 -0700 | [diff] [blame] | 69 | VALIDITY |
| 70 | validity(); |
| 71 | |
| 72 | private: |
Zhenkai Zhu | 9dd9adc | 2013-03-13 16:12:09 -0700 | [diff] [blame] | 73 | struct Meta |
Zhenkai Zhu | 3457ed4 | 2013-03-12 15:15:21 -0700 | [diff] [blame] | 74 | { |
Zhenkai Zhu | 9dd9adc | 2013-03-13 16:12:09 -0700 | [diff] [blame] | 75 | Meta(std::string id, std::string affi, time_t from, time_t to) |
Zhenkai Zhu | 3457ed4 | 2013-03-12 15:15:21 -0700 | [diff] [blame] | 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; |
Zhenkai Zhu | d5d99be | 2013-03-13 19:15:56 -0700 | [diff] [blame] | 89 | Hash m_keyHash; // publisherPublicKeyHash |
| 90 | Bytes m_rawKeyBytes; |
Alexander Afanasyev | 1dd37ed | 2013-08-14 18:08:09 -0700 | [diff] [blame^] | 91 | ndn_pkey *m_pkey; |
Zhenkai Zhu | 9dd9adc | 2013-03-13 16:12:09 -0700 | [diff] [blame] | 92 | Meta m_meta; |
Zhenkai Zhu | 3457ed4 | 2013-03-12 15:15:21 -0700 | [diff] [blame] | 93 | }; |
| 94 | |
Zhenkai Zhu | 9dd9adc | 2013-03-13 16:12:09 -0700 | [diff] [blame] | 95 | typedef boost::shared_ptr<Cert> CertPtr; |
Zhenkai Zhu | 3457ed4 | 2013-03-12 15:15:21 -0700 | [diff] [blame] | 96 | |
| 97 | } |
| 98 | |
Alexander Afanasyev | 1dd37ed | 2013-08-14 18:08:09 -0700 | [diff] [blame^] | 99 | #endif // NDNX_CERT_H |