blob: b3b7c69de277fd2ed5e4dbe6457c15fc5cf1111a [file] [log] [blame]
Jeff Thompson6c314bc2013-09-23 18:09:38 -07001/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil -*- */
2/**
3 * Copyright (C) 2013 Regents of the University of California.
4 * @author: Jeff Thompson <jefft0@remap.ucla.edu>
5 * See COPYING for copyright and distribution information.
6 */
7
Jeff Thompson1130afc2013-10-01 14:45:50 -07008#if 1
Jeff Thompson6c314bc2013-09-23 18:09:38 -07009#include <stdexcept>
Jeff Thompson1130afc2013-10-01 14:45:50 -070010#endif
11#include <algorithm>
Jeff Thompson25b4e612013-10-10 16:03:24 -070012#include <ndn-cpp/security/security-exception.hpp>
13#include <ndn-cpp/security/identity/memory-identity-storage.hpp>
Jeff Thompson6c314bc2013-09-23 18:09:38 -070014
15using namespace std;
16using namespace ndn::ptr_lib;
17
18namespace ndn {
19
20MemoryIdentityStorage::~MemoryIdentityStorage()
21{
22}
23
24bool
25MemoryIdentityStorage::doesIdentityExist(const Name& identityName)
26{
Jeff Thompson81842272013-09-25 16:12:33 -070027 string identityUri = identityName.toUri();
28 return find(identityStore_.begin(), identityStore_.end(), identityUri) != identityStore_.end();
Jeff Thompson6c314bc2013-09-23 18:09:38 -070029}
30
31void
32MemoryIdentityStorage::addIdentity(const Name& identityName)
33{
Jeff Thompson81842272013-09-25 16:12:33 -070034 string identityUri = identityName.toUri();
35 if (find(identityStore_.begin(), identityStore_.end(), identityUri) != identityStore_.end())
36 throw SecurityException("Identity already exists: " + identityUri);
37
38 identityStore_.push_back(identityUri);
Jeff Thompson6c314bc2013-09-23 18:09:38 -070039}
40
41bool
42MemoryIdentityStorage::revokeIdentity()
43{
44#if 1
Jeff Thompson4affbf52013-10-18 14:36:46 -070045 throw runtime_error("MemoryIdentityStorage::revokeIdentity not implemented");
Jeff Thompson6c314bc2013-09-23 18:09:38 -070046#endif
47}
48
Jeff Thompson6c314bc2013-09-23 18:09:38 -070049bool
50MemoryIdentityStorage::doesKeyExist(const Name& keyName)
51{
52#if 1
Jeff Thompson4affbf52013-10-18 14:36:46 -070053 throw runtime_error("MemoryIdentityStorage::doesKeyExist not implemented");
Jeff Thompson6c314bc2013-09-23 18:09:38 -070054#endif
55}
56
Jeff Thompson6c314bc2013-09-23 18:09:38 -070057void
Jeff Thompsonbd04b072013-09-27 15:14:09 -070058MemoryIdentityStorage::addKey(const Name& keyName, KeyType keyType, const Blob& publicKeyDer)
Jeff Thompson6c314bc2013-09-23 18:09:38 -070059{
60#if 1
Jeff Thompson4affbf52013-10-18 14:36:46 -070061 throw runtime_error("MemoryIdentityStorage::addKey not implemented");
Jeff Thompson6c314bc2013-09-23 18:09:38 -070062#endif
63}
64
65Blob
66MemoryIdentityStorage::getKey(const Name& keyName)
67{
68#if 1
Jeff Thompson4affbf52013-10-18 14:36:46 -070069 throw runtime_error("MemoryIdentityStorage::getKey not implemented");
Jeff Thompson6c314bc2013-09-23 18:09:38 -070070#endif
71}
72
73void
74MemoryIdentityStorage::activateKey(const Name& keyName)
75{
76#if 1
Jeff Thompson4affbf52013-10-18 14:36:46 -070077 throw runtime_error("MemoryIdentityStorage::activateKey not implemented");
Jeff Thompson6c314bc2013-09-23 18:09:38 -070078#endif
79}
80
81void
82MemoryIdentityStorage::deactivateKey(const Name& keyName)
83{
84#if 1
Jeff Thompson4affbf52013-10-18 14:36:46 -070085 throw runtime_error("MemoryIdentityStorage::deactivateKey not implemented");
Jeff Thompson6c314bc2013-09-23 18:09:38 -070086#endif
87}
88
89bool
90MemoryIdentityStorage::doesCertificateExist(const Name& certificateName)
91{
92#if 1
Jeff Thompson4affbf52013-10-18 14:36:46 -070093 throw runtime_error("MemoryIdentityStorage::doesCertificateExist not implemented");
Jeff Thompson6c314bc2013-09-23 18:09:38 -070094#endif
95}
96
97void
Jeff Thompsonc69163b2013-10-12 13:49:50 -070098MemoryIdentityStorage::addCertificate(const IdentityCertificate& certificate)
Jeff Thompson6c314bc2013-09-23 18:09:38 -070099{
100#if 1
Jeff Thompson4affbf52013-10-18 14:36:46 -0700101 throw runtime_error("MemoryIdentityStorage::addCertificate not implemented");
Jeff Thompson6c314bc2013-09-23 18:09:38 -0700102#endif
103}
104
Jeff Thompson3bd90bc2013-10-19 16:40:14 -0700105ptr_lib::shared_ptr<Data>
Jeff Thompson6c314bc2013-09-23 18:09:38 -0700106MemoryIdentityStorage::getCertificate(const Name &certificateName, bool allowAny)
107{
108#if 1
Jeff Thompson4affbf52013-10-18 14:36:46 -0700109 throw runtime_error("MemoryIdentityStorage::getCertificate not implemented");
Jeff Thompson6c314bc2013-09-23 18:09:38 -0700110#endif
111}
112
113Name
114MemoryIdentityStorage::getDefaultIdentity()
115{
Jeff Thompson81842272013-09-25 16:12:33 -0700116 return Name(defaultIdentity_);
Jeff Thompson6c314bc2013-09-23 18:09:38 -0700117}
118
119Name
120MemoryIdentityStorage::getDefaultKeyNameForIdentity(const Name& identityName)
121{
122#if 1
Jeff Thompson4affbf52013-10-18 14:36:46 -0700123 throw runtime_error("MemoryIdentityStorage::getDefaultKeyNameForIdentity not implemented");
Jeff Thompson6c314bc2013-09-23 18:09:38 -0700124#endif
125}
126
127Name
128MemoryIdentityStorage::getDefaultCertificateNameForKey(const Name& keyName)
129{
130#if 1
Jeff Thompson4affbf52013-10-18 14:36:46 -0700131 throw runtime_error("MemoryIdentityStorage::getDefaultCertificateNameForKey not implemented");
Jeff Thompson6c314bc2013-09-23 18:09:38 -0700132#endif
133}
134
135void
136MemoryIdentityStorage::setDefaultIdentity(const Name& identityName)
137{
Jeff Thompson81842272013-09-25 16:12:33 -0700138 string identityUri = identityName.toUri();
139 if (find(identityStore_.begin(), identityStore_.end(), identityUri) != identityStore_.end())
140 defaultIdentity_ = identityUri;
141 else
142 // The identity doesn't exist, so clear the default.
143 defaultIdentity_.clear();
Jeff Thompson6c314bc2013-09-23 18:09:38 -0700144}
145
146void
Jeff Thompsonabcea7d2013-10-02 15:03:21 -0700147MemoryIdentityStorage::setDefaultKeyNameForIdentity(const Name& keyName, const Name& identityNameCheck)
Jeff Thompson6c314bc2013-09-23 18:09:38 -0700148{
149#if 1
Jeff Thompson4affbf52013-10-18 14:36:46 -0700150 throw runtime_error("MemoryIdentityStorage::setDefaultKeyNameForIdentity not implemented");
Jeff Thompson6c314bc2013-09-23 18:09:38 -0700151#endif
152}
153
154void
155MemoryIdentityStorage::setDefaultCertificateNameForKey(const Name& keyName, const Name& certificateName)
156{
157#if 1
Jeff Thompson4affbf52013-10-18 14:36:46 -0700158 throw runtime_error("MemoryIdentityStorage::setDefaultCertificateNameForKey not implemented");
Jeff Thompson6c314bc2013-09-23 18:09:38 -0700159#endif
160}
161
162}