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 | |
Zhenkai Zhu | 9dd9adc | 2013-03-13 16:12:09 -0700 | [diff] [blame^] | 22 | #ifndef CCNX_CERT_H |
| 23 | #define CCNX_CERT_H |
Zhenkai Zhu | 3457ed4 | 2013-03-12 15:15:21 -0700 | [diff] [blame] | 24 | |
| 25 | #include "ccnx-common.h" |
| 26 | #include "ccnx-name.h" |
| 27 | #include "ccnx-pco.h" |
| 28 | #include "hash-helper.h" |
| 29 | #include <boost/shared_ptr.hpp> |
| 30 | |
| 31 | namespace Ccnx { |
| 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 | 3457ed4 | 2013-03-12 15:15:21 -0700 | [diff] [blame] | 46 | |
| 47 | void |
| 48 | updateMeta(const PcoPtr &metaObject); |
| 49 | |
| 50 | Name |
| 51 | name() { return m_name; } |
| 52 | |
| 53 | Bytes |
| 54 | raw() { return m_raw; } |
| 55 | |
| 56 | Hash |
Zhenkai Zhu | 9dd9adc | 2013-03-13 16:12:09 -0700 | [diff] [blame^] | 57 | keyDigest() { return m_hash; } |
Zhenkai Zhu | 3457ed4 | 2013-03-12 15:15:21 -0700 | [diff] [blame] | 58 | |
| 59 | std::string |
| 60 | realworldID() { return m_meta.realworldID; } |
| 61 | |
| 62 | std::string |
| 63 | affilication() { return m_meta.affiliation; } |
| 64 | |
| 65 | VALIDITY |
| 66 | validity(); |
| 67 | |
| 68 | private: |
Zhenkai Zhu | 9dd9adc | 2013-03-13 16:12:09 -0700 | [diff] [blame^] | 69 | struct Meta |
Zhenkai Zhu | 3457ed4 | 2013-03-12 15:15:21 -0700 | [diff] [blame] | 70 | { |
Zhenkai Zhu | 9dd9adc | 2013-03-13 16:12:09 -0700 | [diff] [blame^] | 71 | 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] | 72 | : realworldID(id) |
| 73 | , affiliation(affi) |
| 74 | , validFrom(from) |
| 75 | , validTo(to) |
| 76 | { |
| 77 | } |
| 78 | std::string realworldID; |
| 79 | std::string affiliation; |
| 80 | time_t validFrom; |
| 81 | time_t validTo; |
| 82 | }; |
| 83 | |
| 84 | Name m_name; |
| 85 | Hash m_hash; // publisherPublicKeyHash |
| 86 | Bytes m_raw; |
Zhenkai Zhu | 9dd9adc | 2013-03-13 16:12:09 -0700 | [diff] [blame^] | 87 | Meta m_meta; |
Zhenkai Zhu | 3457ed4 | 2013-03-12 15:15:21 -0700 | [diff] [blame] | 88 | }; |
| 89 | |
Zhenkai Zhu | 9dd9adc | 2013-03-13 16:12:09 -0700 | [diff] [blame^] | 90 | typedef boost::shared_ptr<Cert> CertPtr; |
Zhenkai Zhu | 3457ed4 | 2013-03-12 15:15:21 -0700 | [diff] [blame] | 91 | |
| 92 | } |
| 93 | |
Zhenkai Zhu | 9dd9adc | 2013-03-13 16:12:09 -0700 | [diff] [blame^] | 94 | #endif // CCNX_CERT_H |