blob: 238f64723d104837dc044188c4552eac7b5bc827 [file] [log] [blame]
Yingdi Yudbeb8e22013-10-14 09:36:31 -07001/* -*- 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 Yud04ed1a2013-10-14 14:07:03 -070011#ifndef LINKNDN_CONTACT_ITEM_H
12#define LINKNDN_CONTACT_ITEM_H
Yingdi Yudbeb8e22013-10-14 09:36:31 -070013
Yingdi Yu76dd8002013-12-24 11:16:32 +080014#include <ndn-cpp/data.hpp>
15#include <ndn-cpp-et/regex/regex.hpp>
Yingdi Yudbeb8e22013-10-14 09:36:31 -070016#include <vector>
17#include "endorse-certificate.h"
18
19class ContactItem
20{
Yingdi Yu76dd8002013-12-24 11:16:32 +080021 typedef std::vector<ndn::ptr_lib::shared_ptr<EndorseCertificate> > EndorseCertificateList;
Yingdi Yudbeb8e22013-10-14 09:36:31 -070022
23public:
24 ContactItem(const EndorseCertificate& selfEndorseCertificate,
Yingdi Yu71c01872013-11-03 16:22:05 -080025 bool isIntroducer = false,
Yingdi Yudbeb8e22013-10-14 09:36:31 -070026 const std::string& alias = std::string());
Yingdi Yuec5e72a2013-11-03 15:05:26 -080027
28 ContactItem(const ContactItem& contactItem);
Yingdi Yudbeb8e22013-10-14 09:36:31 -070029
Yingdi Yuec5e72a2013-11-03 15:05:26 -080030 virtual
Yingdi Yudbeb8e22013-10-14 09:36:31 -070031 ~ContactItem() {}
32
Yingdi Yu76dd8002013-12-24 11:16:32 +080033 const EndorseCertificate&
Yingdi Yud04ed1a2013-10-14 14:07:03 -070034 getSelfEndorseCertificate() const
35 { return m_selfEndorseCertificate; }
36
Yingdi Yu76dd8002013-12-24 11:16:32 +080037 const ndn::Name&
Yingdi Yudbeb8e22013-10-14 09:36:31 -070038 getNameSpace() const
39 { return m_namespace; }
40
Yingdi Yu76dd8002013-12-24 11:16:32 +080041 const std::string&
Yingdi Yudbeb8e22013-10-14 09:36:31 -070042 getAlias() const
43 { return m_alias; }
44
Yingdi Yu76dd8002013-12-24 11:16:32 +080045 const std::string&
Yingdi Yudbeb8e22013-10-14 09:36:31 -070046 getName() const
47 { return m_name; }
48
Yingdi Yu76dd8002013-12-24 11:16:32 +080049 const std::string&
Yingdi Yudbeb8e22013-10-14 09:36:31 -070050 getInstitution() const
51 { return m_institution; }
52
Yingdi Yu76dd8002013-12-24 11:16:32 +080053 const ndn::Name
Yingdi Yud04ed1a2013-10-14 14:07:03 -070054 getPublicKeyName() const
55 { return m_selfEndorseCertificate.getPublicKeyName(); }
56
Yingdi Yu76dd8002013-12-24 11:16:32 +080057 bool
Yingdi Yu71c01872013-11-03 16:22:05 -080058 isIntroducer() const
Yingdi Yuec5e72a2013-11-03 15:05:26 -080059 { return m_isIntroducer; }
60
Yingdi Yu76dd8002013-12-24 11:16:32 +080061 void
Yingdi Yub2e747d2013-11-05 23:06:43 -080062 setIsIntroducer(bool isIntroducer)
63 { m_isIntroducer = isIntroducer; }
64
Yingdi Yu71c01872013-11-03 16:22:05 -080065 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
Yingdi Yu76dd8002013-12-24 11:16:32 +080075 const std::vector<ndn::Name>&
Yingdi Yu71c01872013-11-03 16:22:05 -080076 getTrustScopeList() const
77 { return m_trustScopeName; }
78
Yingdi Yud04ed1a2013-10-14 14:07:03 -070079protected:
Yingdi Yudbeb8e22013-10-14 09:36:31 -070080 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 Yuec5e72a2013-11-03 15:05:26 -080087
88 bool m_isIntroducer;
Yingdi Yu71c01872013-11-03 16:22:05 -080089
Yingdi Yu76dd8002013-12-24 11:16:32 +080090 std::vector<ndn::ptr_lib::shared_ptr<ndn::Regex> > m_trustScope;
Yingdi Yu71c01872013-11-03 16:22:05 -080091 std::vector<ndn::Name> m_trustScopeName;
Yingdi Yudbeb8e22013-10-14 09:36:31 -070092};
93
94#endif