blob: 859aed3376d3fa03ad1e6826f5b0714c2b320d5a [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 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 Afanasyevfdbfc6d2014-04-14 15:12:11 -070024 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 }
Alexander Afanasyevfdbfc6d2014-04-14 15:12:11 -070028
Jeff Thompson958bf9b2013-10-12 17:20:51 -070029 /**
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 Afanasyevfdbfc6d2014-04-14 15:12:11 -070034 CertificateSubjectDescription(const OID& oid, const std::string& value)
Alexander Afanasyev0ea6e082013-12-26 15:16:37 -080035 : oid_(oid), value_(value)
36 {
37 }
38
39 void
Alexander Afanasyevfdbfc6d2014-04-14 15:12:11 -070040 encode(CryptoPP::BufferedTransformation& out) const;
Alexander Afanasyev0ea6e082013-12-26 15:16:37 -080041
42 void
Alexander Afanasyevfdbfc6d2014-04-14 15:12:11 -070043 decode(CryptoPP::BufferedTransformation& in);
44
Jeff Thompson958bf9b2013-10-12 17:20:51 -070045 std::string
Jeff Thompson61a25ff2013-12-20 10:40:04 -080046 getOidString() const
Jeff Thompson958bf9b2013-10-12 17:20:51 -070047 {
48 return oid_.toString();
49 }
50
Alexander Afanasyevfdbfc6d2014-04-14 15:12:11 -070051 const std::string&
Jeff Thompson958bf9b2013-10-12 17:20:51 -070052 getValue() const
53 {
54 return value_;
55 }
Alexander Afanasyevfdbfc6d2014-04-14 15:12:11 -070056
Jeff Thompson958bf9b2013-10-12 17:20:51 -070057private:
58 OID oid_;
59 std::string value_;
60};
61
Yingdi Yufc40d872014-02-18 12:56:04 -080062} // namespace ndn
Jeff Thompson958bf9b2013-10-12 17:20:51 -070063
Yingdi Yufc40d872014-02-18 12:56:04 -080064#endif //NDN_SECURITY_CERTIFICATE_SUBJECT_DESCRIPTION_HPP