blob: b47b8802203728488cfb5fedc01502c2b9a5fb8b [file] [log] [blame]
Jeff Thompson958bf9b2013-10-12 17:20:51 -07001/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil -*- */
2/**
3 * Copyright (C) 2013 Regents of the University of California.
Jeff Thompson173fd432013-10-12 18:16:41 -07004 * @author: Yingdi Yu <yingdi@cs.ucla.edu>
Jeff Thompson958bf9b2013-10-12 17:20:51 -07005 * @author: Jeff Thompson <jefft0@remap.ucla.edu>
6 * See COPYING for copyright and distribution information.
7 */
8
9#ifndef NDN_CERTIFICATE_EXTENSION_HPP
10#define NDN_CERTIFICATE_EXTENSION_HPP
11
12#include "../../common.hpp"
13#include "../../util/blob.hpp"
14#include "../../encoding/oid.hpp"
15
16namespace ndn {
17
18namespace der { class DerNode; }
19
20/**
21 * A CertificateExtension represents the Extension entry in a certificate.
22 */
23class CertificateExtension
24{
25public:
26 /**
27 * Create a new CertificateExtension.
28 * @param oid The oid of subject description entry.
29 * @param isCritical If true, the extension must be handled.
Jeff Thompson415da1e2013-10-17 16:52:59 -070030 * @param value The extension value.
Jeff Thompson958bf9b2013-10-12 17:20:51 -070031 */
Jeff Thompson415da1e2013-10-17 16:52:59 -070032 CertificateExtension(const std::string& oid, const bool isCritical, const Blob& value)
Jeff Thompson958bf9b2013-10-12 17:20:51 -070033 : extensionId_(oid), isCritical_(isCritical), extensionValue_(value)
34 {
35 }
36
37 /**
38 * Create a new CertificateExtension.
39 * @param oid The oid of subject description entry.
40 * @param isCritical If true, the extension must be handled.
Jeff Thompson415da1e2013-10-17 16:52:59 -070041 * @param value The extension value.
Jeff Thompson958bf9b2013-10-12 17:20:51 -070042 */
Jeff Thompson415da1e2013-10-17 16:52:59 -070043 CertificateExtension(const OID& oid, const bool isCritical, const Blob& value)
Jeff Thompson958bf9b2013-10-12 17:20:51 -070044 : extensionId_(oid), isCritical_(isCritical), extensionValue_(value)
45 {
46 }
47
48 /**
49 * The virtual destructor.
50 */
51 virtual
52 ~CertificateExtension() {}
53
54 /**
55 * encode the object into DER syntax tree
56 * @return the encoded DER syntax tree
57 */
58 ptr_lib::shared_ptr<der::DerNode>
Jeff Thompson9afac392013-12-20 10:42:15 -080059 toDer() const;
Jeff Thompson958bf9b2013-10-12 17:20:51 -070060
61 Blob
Jeff Thompson9afac392013-12-20 10:42:15 -080062 toDerBlob() const;
Jeff Thompson958bf9b2013-10-12 17:20:51 -070063
64 inline const OID&
65 getOid() const { return extensionId_; }
66
67 inline const bool
68 getIsCritical() const { return isCritical_; }
69
70 inline const Blob&
71 getValue() const { return extensionValue_; }
72
73protected:
74 OID extensionId_;
75 bool isCritical_;
76 Blob extensionValue_;
77};
78
79}
80
81#endif