blob: 7c3b7b1b7153c5b71d4ada52259f41d92f52d7da [file] [log] [blame]
Alexander Afanasyevc169a812014-05-20 20:37:29 -04001/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
Jeff Thompson7ca11f22013-10-04 19:01:30 -07002/**
Alexander Afanasyevc169a812014-05-20 20:37:29 -04003 * Copyright (c) 2013-2014 Regents of the University of California.
Alexander Afanasyevdfa52c42014-04-24 21:10:11 -07004 *
5 * This file is part of ndn-cxx library (NDN C++ library with eXperimental eXtensions).
Alexander Afanasyevdfa52c42014-04-24 21:10:11 -07006 *
Alexander Afanasyevc169a812014-05-20 20:37:29 -04007 * ndn-cxx library is free software: you can redistribute it and/or modify it under the
8 * terms of the GNU Lesser General Public License as published by the Free Software
9 * Foundation, either version 3 of the License, or (at your option) any later version.
10 *
11 * ndn-cxx library is distributed in the hope that it will be useful, but WITHOUT ANY
12 * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A
13 * PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details.
14 *
15 * You should have received copies of the GNU General Public License and GNU Lesser
16 * General Public License along with ndn-cxx, e.g., in COPYING.md file. If not, see
17 * <http://www.gnu.org/licenses/>.
18 *
19 * See AUTHORS.md for complete list of ndn-cxx authors and contributors.
Alexander Afanasyevdfa52c42014-04-24 21:10:11 -070020 *
21 * @author Yingdi Yu <http://irl.cs.ucla.edu/~yingdi/>
22 * @author Jeff Thompson <jefft0@remap.ucla.edu>
Jeff Thompson7ca11f22013-10-04 19:01:30 -070023 */
24
Yingdi Yufc40d872014-02-18 12:56:04 -080025#ifndef NDN_SECURITY_SEC_PUBLIC_INFO_SQLITE3_HPP
26#define NDN_SECURITY_SEC_PUBLIC_INFO_SQLITE3_HPP
Jeff Thompson7ca11f22013-10-04 19:01:30 -070027
Yingdi Yu4f324632014-01-15 18:10:03 -080028#include "../common.hpp"
Yingdi Yu87581582014-01-14 14:28:39 -080029#include "sec-public-info.hpp"
Jeff Thompson7ca11f22013-10-04 19:01:30 -070030
Yingdi Yu874678f2014-01-22 19:30:34 -080031struct sqlite3;
32
Yingdi Yufc40d872014-02-18 12:56:04 -080033namespace ndn {
Alexander Afanasyevfdbfc6d2014-04-14 15:12:11 -070034
Alexander Afanasyev2a7f7202014-04-23 14:25:29 -070035class SecPublicInfoSqlite3 : public SecPublicInfo
36{
Jeff Thompson7ca11f22013-10-04 19:01:30 -070037public:
Alexander Afanasyevfdbfc6d2014-04-14 15:12:11 -070038 class Error : public SecPublicInfo::Error
39 {
40 public:
41 explicit
42 Error(const std::string& what)
43 : SecPublicInfo::Error(what)
44 {
45 }
46 };
Alexander Afanasyevbf1a67a2014-01-05 23:36:13 -080047
Yingdi Yu87581582014-01-14 14:28:39 -080048 SecPublicInfoSqlite3();
Alexander Afanasyevfdbfc6d2014-04-14 15:12:11 -070049
50 virtual
Yingdi Yu87581582014-01-14 14:28:39 -080051 ~SecPublicInfoSqlite3();
Jeff Thompson7ca11f22013-10-04 19:01:30 -070052
Yingdi Yu2e57a582014-02-20 23:34:43 -080053 /**********************
54 * from SecPublicInfo *
55 **********************/
Alexander Afanasyevfdbfc6d2014-04-14 15:12:11 -070056 virtual bool
Jeff Thompson7ca11f22013-10-04 19:01:30 -070057 doesIdentityExist(const Name& identityName);
58
Jeff Thompson7ca11f22013-10-04 19:01:30 -070059 virtual void
60 addIdentity(const Name& identityName);
61
Alexander Afanasyevfdbfc6d2014-04-14 15:12:11 -070062 virtual bool
Jeff Thompson7ca11f22013-10-04 19:01:30 -070063 revokeIdentity();
64
Alexander Afanasyevfdbfc6d2014-04-14 15:12:11 -070065 virtual bool
Yingdi Yu87581582014-01-14 14:28:39 -080066 doesPublicKeyExist(const Name& keyName);
Jeff Thompson7ca11f22013-10-04 19:01:30 -070067
Alexander Afanasyevfdbfc6d2014-04-14 15:12:11 -070068 virtual void
Yingdi Yu87581582014-01-14 14:28:39 -080069 addPublicKey(const Name& keyName, KeyType keyType, const PublicKey& publicKeyDer);
Jeff Thompson7ca11f22013-10-04 19:01:30 -070070
Yingdi Yu4b8c6a22014-04-15 23:00:54 -070071 virtual shared_ptr<PublicKey>
Yingdi Yu87581582014-01-14 14:28:39 -080072 getPublicKey(const Name& keyName);
Jeff Thompson7ca11f22013-10-04 19:01:30 -070073
Jeff Thompson7ca11f22013-10-04 19:01:30 -070074 virtual bool
75 doesCertificateExist(const Name& certificateName);
76
Alexander Afanasyevfdbfc6d2014-04-14 15:12:11 -070077 virtual void
Jeff Thompsonc69163b2013-10-12 13:49:50 -070078 addCertificate(const IdentityCertificate& certificate);
Jeff Thompson7ca11f22013-10-04 19:01:30 -070079
Yingdi Yu4b8c6a22014-04-15 23:00:54 -070080 virtual shared_ptr<IdentityCertificate>
Alexander Afanasyevfdbfc6d2014-04-14 15:12:11 -070081 getCertificate(const Name& certificateName);
Jeff Thompson7ca11f22013-10-04 19:01:30 -070082
83
Jeff Thompson7ca11f22013-10-04 19:01:30 -070084
Alexander Afanasyevfdbfc6d2014-04-14 15:12:11 -070085 virtual Name
Jeff Thompson7ca11f22013-10-04 19:01:30 -070086 getDefaultIdentity();
87
Alexander Afanasyevfdbfc6d2014-04-14 15:12:11 -070088 virtual Name
Jeff Thompson7ca11f22013-10-04 19:01:30 -070089 getDefaultKeyNameForIdentity(const Name& identityName);
90
Alexander Afanasyevfdbfc6d2014-04-14 15:12:11 -070091 virtual Name
Jeff Thompson7ca11f22013-10-04 19:01:30 -070092 getDefaultCertificateNameForKey(const Name& keyName);
93
Yingdi Yu28fd32f2014-01-28 19:03:03 -080094 virtual void
Alexander Afanasyevfdbfc6d2014-04-14 15:12:11 -070095 getAllIdentities(std::vector<Name>& nameList, bool isDefault);
Alexander Afanasyev0c632112013-12-30 15:59:31 -080096
Yingdi Yu28fd32f2014-01-28 19:03:03 -080097 virtual void
Alexander Afanasyevfdbfc6d2014-04-14 15:12:11 -070098 getAllKeyNames(std::vector<Name>& nameList, bool isDefault);
Alexander Afanasyev0c632112013-12-30 15:59:31 -080099
Yingdi Yu28fd32f2014-01-28 19:03:03 -0800100 virtual void
Alexander Afanasyevfdbfc6d2014-04-14 15:12:11 -0700101 getAllKeyNamesOfIdentity(const Name& identity, std::vector<Name>& nameList, bool isDefault);
Alexander Afanasyev0c632112013-12-30 15:59:31 -0800102
Yingdi Yu28fd32f2014-01-28 19:03:03 -0800103 virtual void
Alexander Afanasyevfdbfc6d2014-04-14 15:12:11 -0700104 getAllCertificateNames(std::vector<Name>& nameList, bool isDefault);
105
106 virtual void
107 getAllCertificateNamesOfKey(const Name& keyName, std::vector<Name>& nameList, bool isDefault);
108
Yingdi Yuf56c68f2014-04-24 21:50:13 -0700109 virtual void
110 deleteCertificateInfo(const Name& certificateName);
111
112 virtual void
113 deletePublicKeyInfo(const Name& keyName);
114
115 virtual void
116 deleteIdentityInfo(const Name& identity);
117
Yingdi Yu87581582014-01-14 14:28:39 -0800118protected:
Alexander Afanasyevfdbfc6d2014-04-14 15:12:11 -0700119 virtual void
Yingdi Yu87581582014-01-14 14:28:39 -0800120 setDefaultIdentityInternal(const Name& identityName);
Jeff Thompson7ca11f22013-10-04 19:01:30 -0700121
122 virtual void
Yingdi Yu87581582014-01-14 14:28:39 -0800123 setDefaultKeyNameForIdentityInternal(const Name& keyName);
124
Alexander Afanasyevfdbfc6d2014-04-14 15:12:11 -0700125 virtual void
126 setDefaultCertificateNameForKeyInternal(const Name& certificateName);
Yingdi Yu28fd32f2014-01-28 19:03:03 -0800127
Yingdi Yu87581582014-01-14 14:28:39 -0800128private:
Yingdi Yu28fd32f2014-01-28 19:03:03 -0800129 sqlite3 * m_database;
Jeff Thompson7ca11f22013-10-04 19:01:30 -0700130};
131
Yingdi Yufc40d872014-02-18 12:56:04 -0800132} // namespace ndn
Jeff Thompson7ca11f22013-10-04 19:01:30 -0700133
Yingdi Yufc40d872014-02-18 12:56:04 -0800134#endif //NDN_SECURITY_SEC_PUBLIC_INFO_SQLITE3_HPP