blob: 9576e0d302fcd253b45fc9cc179821548329dd9e [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: Yingdi Yu <yingdi@cs.ucla.edu>
5 * @author: Jeff Thompson <jefft0@remap.ucla.edu>
6 * See COPYING for copyright and distribution information.
7 */
8
9#ifndef NDN_CERTIFICATE_SUBJECT_DESCRIPTION_HPP
10#define NDN_CERTIFICATE_SUBJECT_DESCRIPTION_HPP
11
12#include "../../common.hpp"
13#include "../../encoding/oid.hpp"
14
Alexander Afanasyev0ea6e082013-12-26 15:16:37 -080015namespace CryptoPP { class BufferedTransformation; }
16
Jeff Thompson958bf9b2013-10-12 17:20:51 -070017namespace ndn {
18
Jeff Thompson958bf9b2013-10-12 17:20:51 -070019/**
20 * A CertificateSubjectDescription represents the SubjectDescription entry in a Certificate.
21 */
22class CertificateSubjectDescription {
23public:
Alexander Afanasyev0ea6e082013-12-26 15:16:37 -080024 CertificateSubjectDescription(CryptoPP::BufferedTransformation &in)
Jeff Thompson958bf9b2013-10-12 17:20:51 -070025 {
Alexander Afanasyev0ea6e082013-12-26 15:16:37 -080026 decode(in);
Jeff Thompson958bf9b2013-10-12 17:20:51 -070027 }
28
29 /**
Alexander Afanasyev0ea6e082013-12-26 15:16:37 -080030 * 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 Thompson958bf9b2013-10-12 17:20:51 -070033 */
Alexander Afanasyev0ea6e082013-12-26 15:16:37 -080034 CertificateSubjectDescription(const std::string &oid, const std::string &value)
35 : oid_(oid), value_(value)
36 {
37 }
Jeff Thompson958bf9b2013-10-12 17:20:51 -070038
Alexander Afanasyev0ea6e082013-12-26 15:16:37 -080039 /**
40 * Create a new CertificateSubjectDescription.
41 * @param oid The oid of the subject description entry.
42 * @param value The value of the subject description entry.
43 */
44 CertificateSubjectDescription(const OID &oid, const std::string &value)
45 : oid_(oid), value_(value)
46 {
47 }
48
49 void
50 encode(CryptoPP::BufferedTransformation &out) const;
51
52 void
53 decode(CryptoPP::BufferedTransformation &in);
54
Jeff Thompson958bf9b2013-10-12 17:20:51 -070055 std::string
Jeff Thompson61a25ff2013-12-20 10:40:04 -080056 getOidString() const
Jeff Thompson958bf9b2013-10-12 17:20:51 -070057 {
58 return oid_.toString();
59 }
60
61 const std::string &
62 getValue() const
63 {
64 return value_;
65 }
66
67private:
68 OID oid_;
69 std::string value_;
70};
71
72}
73
74#endif