Jeff Thompson | 6c314bc | 2013-09-23 18:09:38 -0700 | [diff] [blame] | 1 | /* -*- 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 Thompson | 1130afc | 2013-10-01 14:45:50 -0700 | [diff] [blame] | 8 | #if 1 |
Jeff Thompson | 6c314bc | 2013-09-23 18:09:38 -0700 | [diff] [blame] | 9 | #include <stdexcept> |
Jeff Thompson | 1130afc | 2013-10-01 14:45:50 -0700 | [diff] [blame] | 10 | #endif |
| 11 | #include <algorithm> |
Jeff Thompson | 25b4e61 | 2013-10-10 16:03:24 -0700 | [diff] [blame] | 12 | #include <ndn-cpp/security/security-exception.hpp> |
| 13 | #include <ndn-cpp/security/identity/memory-identity-storage.hpp> |
Jeff Thompson | 6c314bc | 2013-09-23 18:09:38 -0700 | [diff] [blame] | 14 | |
| 15 | using namespace std; |
| 16 | using namespace ndn::ptr_lib; |
| 17 | |
| 18 | namespace ndn { |
| 19 | |
| 20 | MemoryIdentityStorage::~MemoryIdentityStorage() |
| 21 | { |
| 22 | } |
| 23 | |
| 24 | bool |
| 25 | MemoryIdentityStorage::doesIdentityExist(const Name& identityName) |
| 26 | { |
Jeff Thompson | 8184227 | 2013-09-25 16:12:33 -0700 | [diff] [blame] | 27 | string identityUri = identityName.toUri(); |
| 28 | return find(identityStore_.begin(), identityStore_.end(), identityUri) != identityStore_.end(); |
Jeff Thompson | 6c314bc | 2013-09-23 18:09:38 -0700 | [diff] [blame] | 29 | } |
| 30 | |
| 31 | void |
| 32 | MemoryIdentityStorage::addIdentity(const Name& identityName) |
| 33 | { |
Jeff Thompson | 8184227 | 2013-09-25 16:12:33 -0700 | [diff] [blame] | 34 | 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 Thompson | 6c314bc | 2013-09-23 18:09:38 -0700 | [diff] [blame] | 39 | } |
| 40 | |
| 41 | bool |
| 42 | MemoryIdentityStorage::revokeIdentity() |
| 43 | { |
| 44 | #if 1 |
Jeff Thompson | 4affbf5 | 2013-10-18 14:36:46 -0700 | [diff] [blame] | 45 | throw runtime_error("MemoryIdentityStorage::revokeIdentity not implemented"); |
Jeff Thompson | 6c314bc | 2013-09-23 18:09:38 -0700 | [diff] [blame] | 46 | #endif |
| 47 | } |
| 48 | |
Jeff Thompson | 6c314bc | 2013-09-23 18:09:38 -0700 | [diff] [blame] | 49 | bool |
| 50 | MemoryIdentityStorage::doesKeyExist(const Name& keyName) |
| 51 | { |
| 52 | #if 1 |
Jeff Thompson | 4affbf5 | 2013-10-18 14:36:46 -0700 | [diff] [blame] | 53 | throw runtime_error("MemoryIdentityStorage::doesKeyExist not implemented"); |
Jeff Thompson | 6c314bc | 2013-09-23 18:09:38 -0700 | [diff] [blame] | 54 | #endif |
| 55 | } |
| 56 | |
Jeff Thompson | 6c314bc | 2013-09-23 18:09:38 -0700 | [diff] [blame] | 57 | void |
Jeff Thompson | bd04b07 | 2013-09-27 15:14:09 -0700 | [diff] [blame] | 58 | MemoryIdentityStorage::addKey(const Name& keyName, KeyType keyType, const Blob& publicKeyDer) |
Jeff Thompson | 6c314bc | 2013-09-23 18:09:38 -0700 | [diff] [blame] | 59 | { |
| 60 | #if 1 |
Jeff Thompson | 4affbf5 | 2013-10-18 14:36:46 -0700 | [diff] [blame] | 61 | throw runtime_error("MemoryIdentityStorage::addKey not implemented"); |
Jeff Thompson | 6c314bc | 2013-09-23 18:09:38 -0700 | [diff] [blame] | 62 | #endif |
| 63 | } |
| 64 | |
| 65 | Blob |
| 66 | MemoryIdentityStorage::getKey(const Name& keyName) |
| 67 | { |
| 68 | #if 1 |
Jeff Thompson | 4affbf5 | 2013-10-18 14:36:46 -0700 | [diff] [blame] | 69 | throw runtime_error("MemoryIdentityStorage::getKey not implemented"); |
Jeff Thompson | 6c314bc | 2013-09-23 18:09:38 -0700 | [diff] [blame] | 70 | #endif |
| 71 | } |
| 72 | |
| 73 | void |
| 74 | MemoryIdentityStorage::activateKey(const Name& keyName) |
| 75 | { |
| 76 | #if 1 |
Jeff Thompson | 4affbf5 | 2013-10-18 14:36:46 -0700 | [diff] [blame] | 77 | throw runtime_error("MemoryIdentityStorage::activateKey not implemented"); |
Jeff Thompson | 6c314bc | 2013-09-23 18:09:38 -0700 | [diff] [blame] | 78 | #endif |
| 79 | } |
| 80 | |
| 81 | void |
| 82 | MemoryIdentityStorage::deactivateKey(const Name& keyName) |
| 83 | { |
| 84 | #if 1 |
Jeff Thompson | 4affbf5 | 2013-10-18 14:36:46 -0700 | [diff] [blame] | 85 | throw runtime_error("MemoryIdentityStorage::deactivateKey not implemented"); |
Jeff Thompson | 6c314bc | 2013-09-23 18:09:38 -0700 | [diff] [blame] | 86 | #endif |
| 87 | } |
| 88 | |
| 89 | bool |
| 90 | MemoryIdentityStorage::doesCertificateExist(const Name& certificateName) |
| 91 | { |
| 92 | #if 1 |
Jeff Thompson | 4affbf5 | 2013-10-18 14:36:46 -0700 | [diff] [blame] | 93 | throw runtime_error("MemoryIdentityStorage::doesCertificateExist not implemented"); |
Jeff Thompson | 6c314bc | 2013-09-23 18:09:38 -0700 | [diff] [blame] | 94 | #endif |
| 95 | } |
| 96 | |
| 97 | void |
Jeff Thompson | c69163b | 2013-10-12 13:49:50 -0700 | [diff] [blame] | 98 | MemoryIdentityStorage::addCertificate(const IdentityCertificate& certificate) |
Jeff Thompson | 6c314bc | 2013-09-23 18:09:38 -0700 | [diff] [blame] | 99 | { |
| 100 | #if 1 |
Jeff Thompson | 4affbf5 | 2013-10-18 14:36:46 -0700 | [diff] [blame] | 101 | throw runtime_error("MemoryIdentityStorage::addCertificate not implemented"); |
Jeff Thompson | 6c314bc | 2013-09-23 18:09:38 -0700 | [diff] [blame] | 102 | #endif |
| 103 | } |
| 104 | |
Jeff Thompson | 3bd90bc | 2013-10-19 16:40:14 -0700 | [diff] [blame] | 105 | ptr_lib::shared_ptr<Data> |
Jeff Thompson | 6c314bc | 2013-09-23 18:09:38 -0700 | [diff] [blame] | 106 | MemoryIdentityStorage::getCertificate(const Name &certificateName, bool allowAny) |
| 107 | { |
| 108 | #if 1 |
Jeff Thompson | 4affbf5 | 2013-10-18 14:36:46 -0700 | [diff] [blame] | 109 | throw runtime_error("MemoryIdentityStorage::getCertificate not implemented"); |
Jeff Thompson | 6c314bc | 2013-09-23 18:09:38 -0700 | [diff] [blame] | 110 | #endif |
| 111 | } |
| 112 | |
| 113 | Name |
| 114 | MemoryIdentityStorage::getDefaultIdentity() |
| 115 | { |
Jeff Thompson | 8184227 | 2013-09-25 16:12:33 -0700 | [diff] [blame] | 116 | return Name(defaultIdentity_); |
Jeff Thompson | 6c314bc | 2013-09-23 18:09:38 -0700 | [diff] [blame] | 117 | } |
| 118 | |
| 119 | Name |
| 120 | MemoryIdentityStorage::getDefaultKeyNameForIdentity(const Name& identityName) |
| 121 | { |
| 122 | #if 1 |
Jeff Thompson | 4affbf5 | 2013-10-18 14:36:46 -0700 | [diff] [blame] | 123 | throw runtime_error("MemoryIdentityStorage::getDefaultKeyNameForIdentity not implemented"); |
Jeff Thompson | 6c314bc | 2013-09-23 18:09:38 -0700 | [diff] [blame] | 124 | #endif |
| 125 | } |
| 126 | |
| 127 | Name |
| 128 | MemoryIdentityStorage::getDefaultCertificateNameForKey(const Name& keyName) |
| 129 | { |
| 130 | #if 1 |
Jeff Thompson | 4affbf5 | 2013-10-18 14:36:46 -0700 | [diff] [blame] | 131 | throw runtime_error("MemoryIdentityStorage::getDefaultCertificateNameForKey not implemented"); |
Jeff Thompson | 6c314bc | 2013-09-23 18:09:38 -0700 | [diff] [blame] | 132 | #endif |
| 133 | } |
| 134 | |
| 135 | void |
| 136 | MemoryIdentityStorage::setDefaultIdentity(const Name& identityName) |
| 137 | { |
Jeff Thompson | 8184227 | 2013-09-25 16:12:33 -0700 | [diff] [blame] | 138 | 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 Thompson | 6c314bc | 2013-09-23 18:09:38 -0700 | [diff] [blame] | 144 | } |
| 145 | |
| 146 | void |
Jeff Thompson | abcea7d | 2013-10-02 15:03:21 -0700 | [diff] [blame] | 147 | MemoryIdentityStorage::setDefaultKeyNameForIdentity(const Name& keyName, const Name& identityNameCheck) |
Jeff Thompson | 6c314bc | 2013-09-23 18:09:38 -0700 | [diff] [blame] | 148 | { |
| 149 | #if 1 |
Jeff Thompson | 4affbf5 | 2013-10-18 14:36:46 -0700 | [diff] [blame] | 150 | throw runtime_error("MemoryIdentityStorage::setDefaultKeyNameForIdentity not implemented"); |
Jeff Thompson | 6c314bc | 2013-09-23 18:09:38 -0700 | [diff] [blame] | 151 | #endif |
| 152 | } |
| 153 | |
| 154 | void |
| 155 | MemoryIdentityStorage::setDefaultCertificateNameForKey(const Name& keyName, const Name& certificateName) |
| 156 | { |
| 157 | #if 1 |
Jeff Thompson | 4affbf5 | 2013-10-18 14:36:46 -0700 | [diff] [blame] | 158 | throw runtime_error("MemoryIdentityStorage::setDefaultCertificateNameForKey not implemented"); |
Jeff Thompson | 6c314bc | 2013-09-23 18:09:38 -0700 | [diff] [blame] | 159 | #endif |
| 160 | } |
| 161 | |
| 162 | } |