blob: fcf24a1727add2dd8add114f826e5d62e79f97fe [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 Yu71c01872013-11-03 16:22:05 -080061 void
62 addTrustScope(const ndn::Name& nameSpace)
63 {
64 m_trustScopeName.push_back(nameSpace);
65 m_trustScope.push_back(ndn::Regex::fromName(nameSpace));
66 }
67
68 bool
69 canBeTrustedFor(const ndn::Name& name);
70
71 inline const std::vector<ndn::Name>&
72 getTrustScopeList() const
73 { return m_trustScopeName; }
74
Yingdi Yud04ed1a2013-10-14 14:07:03 -070075protected:
Yingdi Yudbeb8e22013-10-14 09:36:31 -070076 EndorseCertificate m_selfEndorseCertificate;
77
78 ndn::Name m_namespace;
79 std::string m_alias;
80
81 std::string m_name;
82 std::string m_institution;
Yingdi Yuec5e72a2013-11-03 15:05:26 -080083
84 bool m_isIntroducer;
Yingdi Yu71c01872013-11-03 16:22:05 -080085
86 std::vector<ndn::Ptr<ndn::Regex> > m_trustScope;
87 std::vector<ndn::Name> m_trustScopeName;
Yingdi Yudbeb8e22013-10-14 09:36:31 -070088};
89
90#endif