blob: 5990cd4a8883c0b54822f075789dff664faf382b [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.
4 * @author: Jeff Thompson <jefft0@remap.ucla.edu>
5 * See COPYING for copyright and distribution information.
6 */
7
8#ifndef NDN_CERTIFICATE_EXTENSION_HPP
9#define NDN_CERTIFICATE_EXTENSION_HPP
10
11#include "../../common.hpp"
12#include "../../util/blob.hpp"
13#include "../../encoding/oid.hpp"
14
15namespace ndn {
16
17namespace der { class DerNode; }
18
19/**
20 * A CertificateExtension represents the Extension entry in a certificate.
21 */
22class CertificateExtension
23{
24public:
25 /**
26 * Create a new CertificateExtension.
27 * @param oid The oid of subject description entry.
28 * @param isCritical If true, the extension must be handled.
29 * @param value The extension value. This makes a copy of the value.
30 */
31 CertificateExtension(const std::string& oid, const bool isCritical, const std::vector<uint8_t>& value)
32 : extensionId_(oid), isCritical_(isCritical), extensionValue_(value)
33 {
34 }
35
36 /**
37 * Create a new CertificateExtension.
38 * @param oid The oid of subject description entry.
39 * @param isCritical If true, the extension must be handled.
40 * @param value The extension value. This makes a copy of the value.
41 */
42 CertificateExtension(const OID& oid, const bool isCritical, const std::vector<uint8_t>& value)
43 : extensionId_(oid), isCritical_(isCritical), extensionValue_(value)
44 {
45 }
46
47 /**
48 * The virtual destructor.
49 */
50 virtual
51 ~CertificateExtension() {}
52
53 /**
54 * encode the object into DER syntax tree
55 * @return the encoded DER syntax tree
56 */
57 ptr_lib::shared_ptr<der::DerNode>
58 toDer();
59
60 Blob
61 toDerBlob();
62
63 inline const OID&
64 getOid() const { return extensionId_; }
65
66 inline const bool
67 getIsCritical() const { return isCritical_; }
68
69 inline const Blob&
70 getValue() const { return extensionValue_; }
71
72protected:
73 OID extensionId_;
74 bool isCritical_;
75 Blob extensionValue_;
76};
77
78}
79
80#endif