blob: 7ea4fe4595f6cbed8a614332867f42acadd50e7c [file] [log] [blame]
Alexander Afanasyev2fa59392016-07-29 17:24:23 -07001/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
2/**
3 * Copyright (c) 2013-2016 Regents of the University of California.
4 *
5 * This file is part of ndn-cxx library (NDN C++ library with eXperimental eXtensions).
6 *
7 * ndn-cxx library is free software: you can redistribute it and/or modify it under the
8 * terms of the GNU Lesser General Public License as published by the Free Software
9 * Foundation, either version 3 of the License, or (at your option) any later version.
10 *
11 * ndn-cxx library is distributed in the hope that it will be useful, but WITHOUT ANY
12 * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A
13 * PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details.
14 *
15 * You should have received copies of the GNU General Public License and GNU Lesser
16 * General Public License along with ndn-cxx, e.g., in COPYING.md file. If not, see
17 * <http://www.gnu.org/licenses/>.
18 *
19 * See AUTHORS.md for complete list of ndn-cxx authors and contributors.
20 *
21 * @author Yingdi Yu <http://irl.cs.ucla.edu/~yingdi/>
22 */
23
24#ifndef NDN_SECURITY_V1_IDENTITY_CERTIFICATE_HPP
25#define NDN_SECURITY_V1_IDENTITY_CERTIFICATE_HPP
26
27#include "../../common.hpp"
28#include "certificate.hpp"
29
30namespace ndn {
31namespace security {
32namespace v1 {
33
34class IdentityCertificate : public Certificate
35{
36public:
37 class Error : public Certificate::Error
38 {
39 public:
40 explicit
41 Error(const std::string& what)
42 : Certificate::Error(what)
43 {
44 }
45 };
46
47 /**
48 * @brief The default constructor.
49 */
50 IdentityCertificate();
51
52 /**
53 * @brief Create an IdentityCertificate from the content in the data packet.
54 * @param data The data packet with the content to decode.
55 */
56 explicit
57 IdentityCertificate(const Data& data);
58
59 /**
60 * @brief Create an IdentityCertificate from a block.
61 * @param block The raw block of the certificate.
62 */
63 explicit
64 IdentityCertificate(const Block& block);
65
66 void
67 wireDecode(const Block& wire);
68
69 void
70 setName(const Name& name);
71
72 const Name&
73 getPublicKeyName() const
74 {
75 return m_publicKeyName;
76 }
77
78 static bool
79 isIdentityCertificate(const Certificate& certificate);
80
81 /**
82 * @brief Get the public key name from the full certificate name.
83 * @param certificateName The full certificate name.
84 * @return The related public key name.
85 */
86 static Name
87 certificateNameToPublicKeyName(const Name& certificateName);
88
89private:
90 static bool
91 isCorrectName(const Name& name);
92
93 void
94 setPublicKeyName();
95
96protected:
97 Name m_publicKeyName;
98};
99
100} // namespace v1
101} // namespace security
102
103#ifdef NDN_CXX_KEEP_SECURITY_V1_ALIASES
104/// @deprecated When needed, use explicit namespace
105using security::v1::IdentityCertificate;
106#endif // NDN_CXX_KEEP_SECURITY_V1_ALIASES
107
108} // namespace ndn
109
110#endif // NDN_SECURITY_V1_IDENTITY_CERTIFICATE_HPP