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: Yingdi Yu <yingdi@cs.ucla.edu> |
| 5 | * @author: Jeff Thompson <jefft0@remap.ucla.edu> |
| 6 | * See COPYING for copyright and distribution information. |
| 7 | */ |
| 8 | |
Yingdi Yu | fc40d87 | 2014-02-18 12:56:04 -0800 | [diff] [blame] | 9 | #ifndef NDN_SECURITY_CERTIFICATE_SUBJECT_DESCRIPTION_HPP |
| 10 | #define NDN_SECURITY_CERTIFICATE_SUBJECT_DESCRIPTION_HPP |
Jeff Thompson | 958bf9b | 2013-10-12 17:20:51 -0700 | [diff] [blame] | 11 | |
Yingdi Yu | 4f32463 | 2014-01-15 18:10:03 -0800 | [diff] [blame] | 12 | #include "../common.hpp" |
| 13 | #include "../encoding/oid.hpp" |
Jeff Thompson | 958bf9b | 2013-10-12 17:20:51 -0700 | [diff] [blame] | 14 | |
Alexander Afanasyev | 0ea6e08 | 2013-12-26 15:16:37 -0800 | [diff] [blame] | 15 | namespace CryptoPP { class BufferedTransformation; } |
| 16 | |
Jeff Thompson | 958bf9b | 2013-10-12 17:20:51 -0700 | [diff] [blame] | 17 | namespace ndn { |
| 18 | |
Jeff Thompson | 958bf9b | 2013-10-12 17:20:51 -0700 | [diff] [blame] | 19 | /** |
| 20 | * A CertificateSubjectDescription represents the SubjectDescription entry in a Certificate. |
| 21 | */ |
| 22 | class CertificateSubjectDescription { |
| 23 | public: |
Alexander Afanasyev | 0ea6e08 | 2013-12-26 15:16:37 -0800 | [diff] [blame] | 24 | CertificateSubjectDescription(CryptoPP::BufferedTransformation &in) |
Jeff Thompson | 958bf9b | 2013-10-12 17:20:51 -0700 | [diff] [blame] | 25 | { |
Alexander Afanasyev | 0ea6e08 | 2013-12-26 15:16:37 -0800 | [diff] [blame] | 26 | decode(in); |
Jeff Thompson | 958bf9b | 2013-10-12 17:20:51 -0700 | [diff] [blame] | 27 | } |
| 28 | |
| 29 | /** |
Alexander Afanasyev | 0ea6e08 | 2013-12-26 15:16:37 -0800 | [diff] [blame] | 30 | * Create a new CertificateSubjectDescription. |
| 31 | * @param oid The oid of the subject description entry. |
| 32 | * @param value The value of the subject description entry. |
Jeff Thompson | 958bf9b | 2013-10-12 17:20:51 -0700 | [diff] [blame] | 33 | */ |
Alexander Afanasyev | 0ea6e08 | 2013-12-26 15:16:37 -0800 | [diff] [blame] | 34 | CertificateSubjectDescription(const OID &oid, const std::string &value) |
| 35 | : oid_(oid), value_(value) |
| 36 | { |
| 37 | } |
| 38 | |
| 39 | void |
| 40 | encode(CryptoPP::BufferedTransformation &out) const; |
| 41 | |
| 42 | void |
| 43 | decode(CryptoPP::BufferedTransformation &in); |
| 44 | |
Jeff Thompson | 958bf9b | 2013-10-12 17:20:51 -0700 | [diff] [blame] | 45 | std::string |
Jeff Thompson | 61a25ff | 2013-12-20 10:40:04 -0800 | [diff] [blame] | 46 | getOidString() const |
Jeff Thompson | 958bf9b | 2013-10-12 17:20:51 -0700 | [diff] [blame] | 47 | { |
| 48 | return oid_.toString(); |
| 49 | } |
| 50 | |
| 51 | const std::string & |
| 52 | getValue() const |
| 53 | { |
| 54 | return value_; |
| 55 | } |
| 56 | |
| 57 | private: |
| 58 | OID oid_; |
| 59 | std::string value_; |
| 60 | }; |
| 61 | |
Yingdi Yu | fc40d87 | 2014-02-18 12:56:04 -0800 | [diff] [blame] | 62 | } // namespace ndn |
Jeff Thompson | 958bf9b | 2013-10-12 17:20:51 -0700 | [diff] [blame] | 63 | |
Yingdi Yu | fc40d87 | 2014-02-18 12:56:04 -0800 | [diff] [blame] | 64 | #endif //NDN_SECURITY_CERTIFICATE_SUBJECT_DESCRIPTION_HPP |