blob: e8732f076bc95a34e828ff29056279d38a961f2f [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
Yingdi Yufc40d872014-02-18 12:56:04 -08009#ifndef NDN_SECURITY_CERTIFICATE_SUBJECT_DESCRIPTION_HPP
10#define NDN_SECURITY_CERTIFICATE_SUBJECT_DESCRIPTION_HPP
Jeff Thompson958bf9b2013-10-12 17:20:51 -070011
Yingdi Yu4f324632014-01-15 18:10:03 -080012#include "../common.hpp"
13#include "../encoding/oid.hpp"
Jeff Thompson958bf9b2013-10-12 17:20:51 -070014
Alexander Afanasyev2a7f7202014-04-23 14:25:29 -070015namespace CryptoPP {
16class BufferedTransformation;
17}
Alexander Afanasyev0ea6e082013-12-26 15:16:37 -080018
Jeff Thompson958bf9b2013-10-12 17:20:51 -070019namespace ndn {
20
Jeff Thompson958bf9b2013-10-12 17:20:51 -070021/**
22 * A CertificateSubjectDescription represents the SubjectDescription entry in a Certificate.
23 */
Alexander Afanasyev2a7f7202014-04-23 14:25:29 -070024class CertificateSubjectDescription
25{
Jeff Thompson958bf9b2013-10-12 17:20:51 -070026public:
Alexander Afanasyevfdbfc6d2014-04-14 15:12:11 -070027 CertificateSubjectDescription(CryptoPP::BufferedTransformation& in)
Jeff Thompson958bf9b2013-10-12 17:20:51 -070028 {
Alexander Afanasyev0ea6e082013-12-26 15:16:37 -080029 decode(in);
Jeff Thompson958bf9b2013-10-12 17:20:51 -070030 }
Alexander Afanasyevfdbfc6d2014-04-14 15:12:11 -070031
Jeff Thompson958bf9b2013-10-12 17:20:51 -070032 /**
Alexander Afanasyev0ea6e082013-12-26 15:16:37 -080033 * Create a new CertificateSubjectDescription.
34 * @param oid The oid of the subject description entry.
35 * @param value The value of the subject description entry.
Jeff Thompson958bf9b2013-10-12 17:20:51 -070036 */
Alexander Afanasyevfdbfc6d2014-04-14 15:12:11 -070037 CertificateSubjectDescription(const OID& oid, const std::string& value)
Yingdi Yu4b8c6a22014-04-15 23:00:54 -070038 : m_oid(oid), m_value(value)
Alexander Afanasyev0ea6e082013-12-26 15:16:37 -080039 {
40 }
41
42 void
Alexander Afanasyevfdbfc6d2014-04-14 15:12:11 -070043 encode(CryptoPP::BufferedTransformation& out) const;
Alexander Afanasyev0ea6e082013-12-26 15:16:37 -080044
45 void
Alexander Afanasyevfdbfc6d2014-04-14 15:12:11 -070046 decode(CryptoPP::BufferedTransformation& in);
47
Jeff Thompson958bf9b2013-10-12 17:20:51 -070048 std::string
Jeff Thompson61a25ff2013-12-20 10:40:04 -080049 getOidString() const
Jeff Thompson958bf9b2013-10-12 17:20:51 -070050 {
Yingdi Yu4b8c6a22014-04-15 23:00:54 -070051 return m_oid.toString();
Jeff Thompson958bf9b2013-10-12 17:20:51 -070052 }
53
Alexander Afanasyevfdbfc6d2014-04-14 15:12:11 -070054 const std::string&
Jeff Thompson958bf9b2013-10-12 17:20:51 -070055 getValue() const
56 {
Yingdi Yu4b8c6a22014-04-15 23:00:54 -070057 return m_value;
Jeff Thompson958bf9b2013-10-12 17:20:51 -070058 }
Alexander Afanasyevfdbfc6d2014-04-14 15:12:11 -070059
Jeff Thompson958bf9b2013-10-12 17:20:51 -070060private:
Yingdi Yu4b8c6a22014-04-15 23:00:54 -070061 OID m_oid;
62 std::string m_value;
Jeff Thompson958bf9b2013-10-12 17:20:51 -070063};
64
Yingdi Yufc40d872014-02-18 12:56:04 -080065} // namespace ndn
Jeff Thompson958bf9b2013-10-12 17:20:51 -070066
Yingdi Yufc40d872014-02-18 12:56:04 -080067#endif //NDN_SECURITY_CERTIFICATE_SUBJECT_DESCRIPTION_HPP