blob: 9ab478b6d57f63f6f1b47c6ab6dfb738df671031 [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
14#include <ndn.cxx/data.h>
Yingdi Yu71c01872013-11-03 16:22:05 -080015#include <ndn.cxx/regex/regex.h>
Yingdi Yudbeb8e22013-10-14 09:36:31 -070016#include <vector>
17#include "endorse-certificate.h"
18
19class ContactItem
20{
Yingdi Yud04ed1a2013-10-14 14:07:03 -070021 typedef std::vector<ndn::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 Yud04ed1a2013-10-14 14:07:03 -070033 inline const EndorseCertificate&
34 getSelfEndorseCertificate() const
35 { return m_selfEndorseCertificate; }
36
37 inline const ndn::Name&
Yingdi Yudbeb8e22013-10-14 09:36:31 -070038 getNameSpace() const
39 { return m_namespace; }
40
Yingdi Yud04ed1a2013-10-14 14:07:03 -070041 inline const std::string&
Yingdi Yudbeb8e22013-10-14 09:36:31 -070042 getAlias() const
43 { return m_alias; }
44
Yingdi Yud04ed1a2013-10-14 14:07:03 -070045 inline const std::string&
Yingdi Yudbeb8e22013-10-14 09:36:31 -070046 getName() const
47 { return m_name; }
48
Yingdi Yud04ed1a2013-10-14 14:07:03 -070049 inline const std::string&
Yingdi Yudbeb8e22013-10-14 09:36:31 -070050 getInstitution() const
51 { return m_institution; }
52
Yingdi Yud04ed1a2013-10-14 14:07:03 -070053 inline const ndn::Name
54 getPublicKeyName() const
55 { return m_selfEndorseCertificate.getPublicKeyName(); }
56
Yingdi Yuec5e72a2013-11-03 15:05:26 -080057 inline bool
Yingdi Yu71c01872013-11-03 16:22:05 -080058 isIntroducer() const
Yingdi Yuec5e72a2013-11-03 15:05:26 -080059 { return m_isIntroducer; }
60
Yingdi Yub2e747d2013-11-05 23:06:43 -080061 inline void
62 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
75 inline const std::vector<ndn::Name>&
76 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
90 std::vector<ndn::Ptr<ndn::Regex> > m_trustScope;
91 std::vector<ndn::Name> m_trustScopeName;
Yingdi Yudbeb8e22013-10-14 09:36:31 -070092};
93
94#endif