blob: 97b18f4115a46389ca288d1a6e95441e165653a7 [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
45 throw std::runtime_error("MemoryIdentityStorage::revokeIdentity not implemented");
46#endif
47}
48
49Name
50MemoryIdentityStorage::getNewKeyName(const Name& identityName, bool useKsk)
51{
52#if 1
53 throw std::runtime_error("MemoryIdentityStorage::getNewKeyName not implemented");
54#endif
55}
56
57bool
58MemoryIdentityStorage::doesKeyExist(const Name& keyName)
59{
60#if 1
61 throw std::runtime_error("MemoryIdentityStorage::doesKeyExist not implemented");
62#endif
63}
64
65Name
66MemoryIdentityStorage::getKeyNameForCertificate(const Name& certificateName)
67{
68 int i = certificateName.getComponentCount() - 1;
69
70 for (; i >= 0; --i) {
71 if(certificateName.getComponent(i).toEscapedString() == string("ID-CERT"))
72 break;
73 }
74
75 return certificateName.getSubName(0, i);
76}
77
78void
Jeff Thompsonbd04b072013-09-27 15:14:09 -070079MemoryIdentityStorage::addKey(const Name& keyName, KeyType keyType, const Blob& publicKeyDer)
Jeff Thompson6c314bc2013-09-23 18:09:38 -070080{
81#if 1
82 throw std::runtime_error("MemoryIdentityStorage::addKey not implemented");
83#endif
84}
85
86Blob
87MemoryIdentityStorage::getKey(const Name& keyName)
88{
89#if 1
90 throw std::runtime_error("MemoryIdentityStorage::getKey not implemented");
91#endif
92}
93
94void
95MemoryIdentityStorage::activateKey(const Name& keyName)
96{
97#if 1
98 throw std::runtime_error("MemoryIdentityStorage::activateKey not implemented");
99#endif
100}
101
102void
103MemoryIdentityStorage::deactivateKey(const Name& keyName)
104{
105#if 1
106 throw std::runtime_error("MemoryIdentityStorage::deactivateKey not implemented");
107#endif
108}
109
110bool
111MemoryIdentityStorage::doesCertificateExist(const Name& certificateName)
112{
113#if 1
114 throw std::runtime_error("MemoryIdentityStorage::doesCertificateExist not implemented");
115#endif
116}
117
118void
119MemoryIdentityStorage::addCertificate(const Certificate& certificate)
120{
121#if 1
122 throw std::runtime_error("MemoryIdentityStorage::addCertificate not implemented");
123#endif
124}
125
Jeff Thompsona6fd6382013-09-24 15:23:37 -0700126ptr_lib::shared_ptr<Certificate>
Jeff Thompson6c314bc2013-09-23 18:09:38 -0700127MemoryIdentityStorage::getCertificate(const Name &certificateName, bool allowAny)
128{
129#if 1
130 throw std::runtime_error("MemoryIdentityStorage::getCertificate not implemented");
131#endif
132}
133
134Name
135MemoryIdentityStorage::getDefaultIdentity()
136{
Jeff Thompson81842272013-09-25 16:12:33 -0700137 return Name(defaultIdentity_);
Jeff Thompson6c314bc2013-09-23 18:09:38 -0700138}
139
140Name
141MemoryIdentityStorage::getDefaultKeyNameForIdentity(const Name& identityName)
142{
143#if 1
144 throw std::runtime_error("MemoryIdentityStorage::getDefaultKeyNameForIdentity not implemented");
145#endif
146}
147
148Name
149MemoryIdentityStorage::getDefaultCertificateNameForKey(const Name& keyName)
150{
151#if 1
152 throw std::runtime_error("MemoryIdentityStorage::getDefaultCertificateNameForKey not implemented");
153#endif
154}
155
156void
157MemoryIdentityStorage::setDefaultIdentity(const Name& identityName)
158{
Jeff Thompson81842272013-09-25 16:12:33 -0700159 string identityUri = identityName.toUri();
160 if (find(identityStore_.begin(), identityStore_.end(), identityUri) != identityStore_.end())
161 defaultIdentity_ = identityUri;
162 else
163 // The identity doesn't exist, so clear the default.
164 defaultIdentity_.clear();
Jeff Thompson6c314bc2013-09-23 18:09:38 -0700165}
166
167void
Jeff Thompsonabcea7d2013-10-02 15:03:21 -0700168MemoryIdentityStorage::setDefaultKeyNameForIdentity(const Name& keyName, const Name& identityNameCheck)
Jeff Thompson6c314bc2013-09-23 18:09:38 -0700169{
170#if 1
171 throw std::runtime_error("MemoryIdentityStorage::setDefaultKeyNameForIdentity not implemented");
172#endif
173}
174
175void
176MemoryIdentityStorage::setDefaultCertificateNameForKey(const Name& keyName, const Name& certificateName)
177{
178#if 1
179 throw std::runtime_error("MemoryIdentityStorage::setDefaultCertificateNameForKey not implemented");
180#endif
181}
182
183}