blob: beaff10c860470fa6e2f73283fb60d67a4436ccb [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 Yu40b53092014-06-17 17:10:02 -070069 addKey(const Name& keyName, 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
Yingdi Yu40b53092014-06-17 17:10:02 -070074 virtual KeyType
75 getPublicKeyType(const Name& keyName);
76
Jeff Thompson7ca11f22013-10-04 19:01:30 -070077 virtual bool
78 doesCertificateExist(const Name& certificateName);
79
Alexander Afanasyevfdbfc6d2014-04-14 15:12:11 -070080 virtual void
Jeff Thompsonc69163b2013-10-12 13:49:50 -070081 addCertificate(const IdentityCertificate& certificate);
Jeff Thompson7ca11f22013-10-04 19:01:30 -070082
Yingdi Yu4b8c6a22014-04-15 23:00:54 -070083 virtual shared_ptr<IdentityCertificate>
Alexander Afanasyevfdbfc6d2014-04-14 15:12:11 -070084 getCertificate(const Name& certificateName);
Jeff Thompson7ca11f22013-10-04 19:01:30 -070085
86
Jeff Thompson7ca11f22013-10-04 19:01:30 -070087
Alexander Afanasyevfdbfc6d2014-04-14 15:12:11 -070088 virtual Name
Jeff Thompson7ca11f22013-10-04 19:01:30 -070089 getDefaultIdentity();
90
Alexander Afanasyevfdbfc6d2014-04-14 15:12:11 -070091 virtual Name
Jeff Thompson7ca11f22013-10-04 19:01:30 -070092 getDefaultKeyNameForIdentity(const Name& identityName);
93
Alexander Afanasyevfdbfc6d2014-04-14 15:12:11 -070094 virtual Name
Jeff Thompson7ca11f22013-10-04 19:01:30 -070095 getDefaultCertificateNameForKey(const Name& keyName);
96
Yingdi Yu28fd32f2014-01-28 19:03:03 -080097 virtual void
Alexander Afanasyevfdbfc6d2014-04-14 15:12:11 -070098 getAllIdentities(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 getAllKeyNames(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 getAllKeyNamesOfIdentity(const Name& identity, std::vector<Name>& nameList, bool isDefault);
Alexander Afanasyev0c632112013-12-30 15:59:31 -0800105
Yingdi Yu28fd32f2014-01-28 19:03:03 -0800106 virtual void
Alexander Afanasyevfdbfc6d2014-04-14 15:12:11 -0700107 getAllCertificateNames(std::vector<Name>& nameList, bool isDefault);
108
109 virtual void
110 getAllCertificateNamesOfKey(const Name& keyName, std::vector<Name>& nameList, bool isDefault);
111
Yingdi Yuf56c68f2014-04-24 21:50:13 -0700112 virtual void
113 deleteCertificateInfo(const Name& certificateName);
114
115 virtual void
116 deletePublicKeyInfo(const Name& keyName);
117
118 virtual void
119 deleteIdentityInfo(const Name& identity);
120
Yingdi Yu87581582014-01-14 14:28:39 -0800121protected:
Alexander Afanasyevfdbfc6d2014-04-14 15:12:11 -0700122 virtual void
Yingdi Yu87581582014-01-14 14:28:39 -0800123 setDefaultIdentityInternal(const Name& identityName);
Jeff Thompson7ca11f22013-10-04 19:01:30 -0700124
125 virtual void
Yingdi Yu87581582014-01-14 14:28:39 -0800126 setDefaultKeyNameForIdentityInternal(const Name& keyName);
127
Alexander Afanasyevfdbfc6d2014-04-14 15:12:11 -0700128 virtual void
129 setDefaultCertificateNameForKeyInternal(const Name& certificateName);
Yingdi Yu28fd32f2014-01-28 19:03:03 -0800130
Yingdi Yu87581582014-01-14 14:28:39 -0800131private:
Junxiao Shi98acbb02014-12-02 11:00:42 -0700132 sqlite3* m_database;
Jeff Thompson7ca11f22013-10-04 19:01:30 -0700133};
134
Yingdi Yufc40d872014-02-18 12:56:04 -0800135} // namespace ndn
Jeff Thompson7ca11f22013-10-04 19:01:30 -0700136
Junxiao Shi98acbb02014-12-02 11:00:42 -0700137#endif // NDN_SECURITY_SEC_PUBLIC_INFO_SQLITE3_HPP