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