Jeff Thompson | cf0fdd9 | 2013-10-12 11:54:35 -0700 | [diff] [blame] | 1 | /* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil -*- */ |
| 2 | /** |
| 3 | * Copyright (C) 2013 Regents of the University of California. |
Jeff Thompson | c69163b | 2013-10-12 13:49:50 -0700 | [diff] [blame] | 4 | * @author: Yingdi Yu <yingdi@cs.ucla.edu> |
Jeff Thompson | cf0fdd9 | 2013-10-12 11:54:35 -0700 | [diff] [blame] | 5 | * @author: Jeff Thompson <jefft0@remap.ucla.edu> |
| 6 | * See COPYING for copyright and distribution information. |
| 7 | */ |
| 8 | |
| 9 | #ifndef NDN_IDENTITY_CERTIFICATE_HPP |
Jeff Thompson | e589c3f | 2013-10-12 17:30:50 -0700 | [diff] [blame] | 10 | #define NDN_IDENTITY_CERTIFICATE_HPP |
Jeff Thompson | cf0fdd9 | 2013-10-12 11:54:35 -0700 | [diff] [blame] | 11 | |
| 12 | #include "certificate.hpp" |
| 13 | |
| 14 | namespace ndn { |
| 15 | |
| 16 | class IdentityCertificate : public Certificate |
| 17 | { |
Jeff Thompson | c69163b | 2013-10-12 13:49:50 -0700 | [diff] [blame] | 18 | public: |
| 19 | /** |
| 20 | * The default constructor. |
| 21 | */ |
Jeff Thompson | 173fd43 | 2013-10-12 18:16:41 -0700 | [diff] [blame] | 22 | IdentityCertificate() |
| 23 | { |
| 24 | } |
Jeff Thompson | cf0fdd9 | 2013-10-12 11:54:35 -0700 | [diff] [blame] | 25 | |
Jeff Thompson | 04e2cd6 | 2013-11-20 19:11:27 -0800 | [diff] [blame] | 26 | // Note: The copy constructor works because publicKeyName_ has a copy constructor. |
| 27 | |
Jeff Thompson | c69163b | 2013-10-12 13:49:50 -0700 | [diff] [blame] | 28 | /** |
| 29 | * Create an IdentityCertificate from the content in the data packet. |
| 30 | * @param data The data packet with the content to decode. |
| 31 | */ |
| 32 | IdentityCertificate(const Data& data); |
Jeff Thompson | 965569b | 2013-10-12 17:52:52 -0700 | [diff] [blame] | 33 | |
| 34 | /** |
Jeff Thompson | a4aa4ce | 2013-11-21 10:56:24 -0800 | [diff] [blame] | 35 | * The copy constructor. |
| 36 | */ |
| 37 | IdentityCertificate(const IdentityCertificate& identityCertificate); |
| 38 | |
| 39 | /** |
Jeff Thompson | 965569b | 2013-10-12 17:52:52 -0700 | [diff] [blame] | 40 | * The virtual destructor. |
| 41 | */ |
| 42 | virtual |
| 43 | ~IdentityCertificate(); |
Jeff Thompson | 173fd43 | 2013-10-12 18:16:41 -0700 | [diff] [blame] | 44 | |
Jeff Thompson | 6d59197 | 2013-10-17 11:16:32 -0700 | [diff] [blame] | 45 | /** |
| 46 | * Override the base class method to check that the name is a valid identity certificate name. |
| 47 | * @param name The identity certificate name which is copied. |
| 48 | * @return This Data so that you can chain calls to update values. |
| 49 | */ |
| 50 | virtual Data & |
Jeff Thompson | 173fd43 | 2013-10-12 18:16:41 -0700 | [diff] [blame] | 51 | setName(const Name& name); |
Jeff Thompson | 965569b | 2013-10-12 17:52:52 -0700 | [diff] [blame] | 52 | |
Jeff Thompson | 43a57b1 | 2013-10-22 16:25:38 -0700 | [diff] [blame] | 53 | Name |
| 54 | getPublicKeyName () const { return publicKeyName_; } |
Jeff Thompson | 965569b | 2013-10-12 17:52:52 -0700 | [diff] [blame] | 55 | |
| 56 | static bool |
| 57 | isIdentityCertificate(const Certificate& certificate); |
| 58 | |
Jeff Thompson | 7494261 | 2013-10-24 16:42:32 -0700 | [diff] [blame] | 59 | /** |
| 60 | * Get the public key name from the full certificate name. |
| 61 | * @param certificateName The full certificate name. |
| 62 | * @return The related public key name. |
| 63 | */ |
| 64 | static Name |
| 65 | certificateNameToPublicKeyName(const Name& certificateName); |
| 66 | |
Jeff Thompson | 965569b | 2013-10-12 17:52:52 -0700 | [diff] [blame] | 67 | private: |
| 68 | static bool |
| 69 | isCorrectName(const Name& name); |
Jeff Thompson | 43a57b1 | 2013-10-22 16:25:38 -0700 | [diff] [blame] | 70 | |
| 71 | void |
| 72 | setPublicKeyName(); |
| 73 | |
| 74 | protected: |
| 75 | Name publicKeyName_; |
Jeff Thompson | cf0fdd9 | 2013-10-12 11:54:35 -0700 | [diff] [blame] | 76 | }; |
| 77 | |
| 78 | } |
| 79 | |
| 80 | #endif |