Jeff Thompson | 958bf9b | 2013-10-12 17:20:51 -0700 | [diff] [blame] | 1 | /* -*- 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 | |
| 15 | namespace ndn { |
| 16 | |
| 17 | namespace der { class DerNode; } |
| 18 | |
| 19 | /** |
| 20 | * A CertificateExtension represents the Extension entry in a certificate. |
| 21 | */ |
| 22 | class CertificateExtension |
| 23 | { |
| 24 | public: |
| 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 | |
| 72 | protected: |
| 73 | OID extensionId_; |
| 74 | bool isCritical_; |
| 75 | Blob extensionValue_; |
| 76 | }; |
| 77 | |
| 78 | } |
| 79 | |
| 80 | #endif |