Yingdi Yu | dbeb8e2 | 2013-10-14 09:36:31 -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 |
| 4 | * Yingdi Yu |
| 5 | * |
| 6 | * BSD license, See the LICENSE file for more information |
| 7 | * |
| 8 | * Author: Yingdi Yu <yingdi@cs.ucla.edu> |
| 9 | */ |
| 10 | |
Yingdi Yu | d04ed1a | 2013-10-14 14:07:03 -0700 | [diff] [blame] | 11 | #ifndef LINKNDN_CONTACT_ITEM_H |
| 12 | #define LINKNDN_CONTACT_ITEM_H |
Yingdi Yu | dbeb8e2 | 2013-10-14 09:36:31 -0700 | [diff] [blame] | 13 | |
| 14 | #include <ndn.cxx/data.h> |
Yingdi Yu | 71c0187 | 2013-11-03 16:22:05 -0800 | [diff] [blame] | 15 | #include <ndn.cxx/regex/regex.h> |
Yingdi Yu | dbeb8e2 | 2013-10-14 09:36:31 -0700 | [diff] [blame] | 16 | #include <vector> |
| 17 | #include "endorse-certificate.h" |
| 18 | |
| 19 | class ContactItem |
| 20 | { |
Yingdi Yu | d04ed1a | 2013-10-14 14:07:03 -0700 | [diff] [blame] | 21 | typedef std::vector<ndn::Ptr<EndorseCertificate> > EndorseCertificateList; |
Yingdi Yu | dbeb8e2 | 2013-10-14 09:36:31 -0700 | [diff] [blame] | 22 | |
| 23 | public: |
| 24 | ContactItem(const EndorseCertificate& selfEndorseCertificate, |
Yingdi Yu | 71c0187 | 2013-11-03 16:22:05 -0800 | [diff] [blame] | 25 | bool isIntroducer = false, |
Yingdi Yu | dbeb8e2 | 2013-10-14 09:36:31 -0700 | [diff] [blame] | 26 | const std::string& alias = std::string()); |
Yingdi Yu | ec5e72a | 2013-11-03 15:05:26 -0800 | [diff] [blame] | 27 | |
| 28 | ContactItem(const ContactItem& contactItem); |
Yingdi Yu | dbeb8e2 | 2013-10-14 09:36:31 -0700 | [diff] [blame] | 29 | |
Yingdi Yu | ec5e72a | 2013-11-03 15:05:26 -0800 | [diff] [blame] | 30 | virtual |
Yingdi Yu | dbeb8e2 | 2013-10-14 09:36:31 -0700 | [diff] [blame] | 31 | ~ContactItem() {} |
| 32 | |
Yingdi Yu | d04ed1a | 2013-10-14 14:07:03 -0700 | [diff] [blame] | 33 | inline const EndorseCertificate& |
| 34 | getSelfEndorseCertificate() const |
| 35 | { return m_selfEndorseCertificate; } |
| 36 | |
| 37 | inline const ndn::Name& |
Yingdi Yu | dbeb8e2 | 2013-10-14 09:36:31 -0700 | [diff] [blame] | 38 | getNameSpace() const |
| 39 | { return m_namespace; } |
| 40 | |
Yingdi Yu | d04ed1a | 2013-10-14 14:07:03 -0700 | [diff] [blame] | 41 | inline const std::string& |
Yingdi Yu | dbeb8e2 | 2013-10-14 09:36:31 -0700 | [diff] [blame] | 42 | getAlias() const |
| 43 | { return m_alias; } |
| 44 | |
Yingdi Yu | d04ed1a | 2013-10-14 14:07:03 -0700 | [diff] [blame] | 45 | inline const std::string& |
Yingdi Yu | dbeb8e2 | 2013-10-14 09:36:31 -0700 | [diff] [blame] | 46 | getName() const |
| 47 | { return m_name; } |
| 48 | |
Yingdi Yu | d04ed1a | 2013-10-14 14:07:03 -0700 | [diff] [blame] | 49 | inline const std::string& |
Yingdi Yu | dbeb8e2 | 2013-10-14 09:36:31 -0700 | [diff] [blame] | 50 | getInstitution() const |
| 51 | { return m_institution; } |
| 52 | |
Yingdi Yu | d04ed1a | 2013-10-14 14:07:03 -0700 | [diff] [blame] | 53 | inline const ndn::Name |
| 54 | getPublicKeyName() const |
| 55 | { return m_selfEndorseCertificate.getPublicKeyName(); } |
| 56 | |
Yingdi Yu | ec5e72a | 2013-11-03 15:05:26 -0800 | [diff] [blame] | 57 | inline bool |
Yingdi Yu | 71c0187 | 2013-11-03 16:22:05 -0800 | [diff] [blame] | 58 | isIntroducer() const |
Yingdi Yu | ec5e72a | 2013-11-03 15:05:26 -0800 | [diff] [blame] | 59 | { return m_isIntroducer; } |
| 60 | |
Yingdi Yu | b2e747d | 2013-11-05 23:06:43 -0800 | [diff] [blame^] | 61 | inline void |
| 62 | setIsIntroducer(bool isIntroducer) |
| 63 | { m_isIntroducer = isIntroducer; } |
| 64 | |
Yingdi Yu | 71c0187 | 2013-11-03 16:22:05 -0800 | [diff] [blame] | 65 | void |
| 66 | addTrustScope(const ndn::Name& nameSpace) |
| 67 | { |
| 68 | m_trustScopeName.push_back(nameSpace); |
| 69 | m_trustScope.push_back(ndn::Regex::fromName(nameSpace)); |
| 70 | } |
| 71 | |
| 72 | bool |
| 73 | canBeTrustedFor(const ndn::Name& name); |
| 74 | |
| 75 | inline const std::vector<ndn::Name>& |
| 76 | getTrustScopeList() const |
| 77 | { return m_trustScopeName; } |
| 78 | |
Yingdi Yu | d04ed1a | 2013-10-14 14:07:03 -0700 | [diff] [blame] | 79 | protected: |
Yingdi Yu | dbeb8e2 | 2013-10-14 09:36:31 -0700 | [diff] [blame] | 80 | EndorseCertificate m_selfEndorseCertificate; |
| 81 | |
| 82 | ndn::Name m_namespace; |
| 83 | std::string m_alias; |
| 84 | |
| 85 | std::string m_name; |
| 86 | std::string m_institution; |
Yingdi Yu | ec5e72a | 2013-11-03 15:05:26 -0800 | [diff] [blame] | 87 | |
| 88 | bool m_isIntroducer; |
Yingdi Yu | 71c0187 | 2013-11-03 16:22:05 -0800 | [diff] [blame] | 89 | |
| 90 | std::vector<ndn::Ptr<ndn::Regex> > m_trustScope; |
| 91 | std::vector<ndn::Name> m_trustScopeName; |
Yingdi Yu | dbeb8e2 | 2013-10-14 09:36:31 -0700 | [diff] [blame] | 92 | }; |
| 93 | |
| 94 | #endif |