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. |
Jeff Thompson | 173fd43 | 2013-10-12 18:16:41 -0700 | [diff] [blame] | 4 | * @author: Yingdi Yu <yingdi@cs.ucla.edu> |
Jeff Thompson | 958bf9b | 2013-10-12 17:20:51 -0700 | [diff] [blame] | 5 | * @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 | |
| 16 | namespace ndn { |
| 17 | |
| 18 | namespace der { class DerNode; } |
| 19 | |
| 20 | /** |
| 21 | * A CertificateExtension represents the Extension entry in a certificate. |
| 22 | */ |
| 23 | class CertificateExtension |
| 24 | { |
| 25 | public: |
| 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 Thompson | 415da1e | 2013-10-17 16:52:59 -0700 | [diff] [blame] | 30 | * @param value The extension value. |
Jeff Thompson | 958bf9b | 2013-10-12 17:20:51 -0700 | [diff] [blame] | 31 | */ |
Jeff Thompson | 415da1e | 2013-10-17 16:52:59 -0700 | [diff] [blame] | 32 | CertificateExtension(const std::string& oid, const bool isCritical, const Blob& value) |
Jeff Thompson | 958bf9b | 2013-10-12 17:20:51 -0700 | [diff] [blame] | 33 | : 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 Thompson | 415da1e | 2013-10-17 16:52:59 -0700 | [diff] [blame] | 41 | * @param value The extension value. |
Jeff Thompson | 958bf9b | 2013-10-12 17:20:51 -0700 | [diff] [blame] | 42 | */ |
Jeff Thompson | 415da1e | 2013-10-17 16:52:59 -0700 | [diff] [blame] | 43 | CertificateExtension(const OID& oid, const bool isCritical, const Blob& value) |
Jeff Thompson | 958bf9b | 2013-10-12 17:20:51 -0700 | [diff] [blame] | 44 | : 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 Thompson | 9afac39 | 2013-12-20 10:42:15 -0800 | [diff] [blame] | 59 | toDer() const; |
Jeff Thompson | 958bf9b | 2013-10-12 17:20:51 -0700 | [diff] [blame] | 60 | |
| 61 | Blob |
Jeff Thompson | 9afac39 | 2013-12-20 10:42:15 -0800 | [diff] [blame] | 62 | toDerBlob() const; |
Jeff Thompson | 958bf9b | 2013-10-12 17:20:51 -0700 | [diff] [blame] | 63 | |
| 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 | |
| 73 | protected: |
| 74 | OID extensionId_; |
| 75 | bool isCritical_; |
| 76 | Blob extensionValue_; |
| 77 | }; |
| 78 | |
| 79 | } |
| 80 | |
| 81 | #endif |