blob: f2b585f348bf203c60968fac7cfb56a48e981bed [file] [log] [blame]
Jeff Thompsoncf0fdd92013-10-12 11:54:35 -07001/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil -*- */
2/**
3 * Copyright (C) 2013 Regents of the University of California.
Jeff Thompsonc69163b2013-10-12 13:49:50 -07004 * @author: Yingdi Yu <yingdi@cs.ucla.edu>
Jeff Thompsoncf0fdd92013-10-12 11:54:35 -07005 * @author: Jeff Thompson <jefft0@remap.ucla.edu>
6 * See COPYING for copyright and distribution information.
7 */
8
9#ifndef NDN_IDENTITY_CERTIFICATE_HPP
Jeff Thompsone589c3f2013-10-12 17:30:50 -070010#define NDN_IDENTITY_CERTIFICATE_HPP
Jeff Thompsoncf0fdd92013-10-12 11:54:35 -070011
12#include "certificate.hpp"
13
14namespace ndn {
15
16class IdentityCertificate : public Certificate
17{
Jeff Thompsonc69163b2013-10-12 13:49:50 -070018public:
19 /**
20 * The default constructor.
21 */
Jeff Thompson173fd432013-10-12 18:16:41 -070022 IdentityCertificate()
23 {
24 }
Jeff Thompsoncf0fdd92013-10-12 11:54:35 -070025
Jeff Thompson04e2cd62013-11-20 19:11:27 -080026 // Note: The copy constructor works because publicKeyName_ has a copy constructor.
27
Jeff Thompsonc69163b2013-10-12 13:49:50 -070028 /**
29 * Create an IdentityCertificate from the content in the data packet.
30 * @param data The data packet with the content to decode.
31 */
32 IdentityCertificate(const Data& data);
Jeff Thompson965569b2013-10-12 17:52:52 -070033
34 /**
35 * The virtual destructor.
36 */
37 virtual
38 ~IdentityCertificate();
Jeff Thompson173fd432013-10-12 18:16:41 -070039
Jeff Thompson6d591972013-10-17 11:16:32 -070040 /**
41 * Override the base class method to check that the name is a valid identity certificate name.
42 * @param name The identity certificate name which is copied.
43 * @return This Data so that you can chain calls to update values.
44 */
45 virtual Data &
Jeff Thompson173fd432013-10-12 18:16:41 -070046 setName(const Name& name);
Jeff Thompson965569b2013-10-12 17:52:52 -070047
Jeff Thompson43a57b12013-10-22 16:25:38 -070048 Name
49 getPublicKeyName () const { return publicKeyName_; }
Jeff Thompson965569b2013-10-12 17:52:52 -070050
51 static bool
52 isIdentityCertificate(const Certificate& certificate);
53
Jeff Thompson74942612013-10-24 16:42:32 -070054 /**
55 * Get the public key name from the full certificate name.
56 * @param certificateName The full certificate name.
57 * @return The related public key name.
58 */
59 static Name
60 certificateNameToPublicKeyName(const Name& certificateName);
61
Jeff Thompson965569b2013-10-12 17:52:52 -070062private:
63 static bool
64 isCorrectName(const Name& name);
Jeff Thompson43a57b12013-10-22 16:25:38 -070065
66 void
67 setPublicKeyName();
68
69protected:
70 Name publicKeyName_;
Jeff Thompsoncf0fdd92013-10-12 11:54:35 -070071};
72
73}
74
75#endif