blob: c11ac44ba47bd25de9e68a466ba4f19b7f4887cc [file] [log] [blame]
Jeff Thompson7ca11f22013-10-04 19:01:30 -07001/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil -*- */
2/**
Alexander Afanasyevdfa52c42014-04-24 21:10:11 -07003 * Copyright (c) 2013-2014, Regents of the University of California.
4 * All rights reserved.
5 *
6 * This file is part of ndn-cxx library (NDN C++ library with eXperimental eXtensions).
7 * See AUTHORS.md for complete list of ndn-cxx authors and contributors.
8 *
9 * This file licensed under New BSD License. See COPYING for detailed information about
10 * ndn-cxx library copyright, permissions, and redistribution restrictions.
11 *
12 * @author Yingdi Yu <http://irl.cs.ucla.edu/~yingdi/>
13 * @author Jeff Thompson <jefft0@remap.ucla.edu>
Jeff Thompson7ca11f22013-10-04 19:01:30 -070014 */
15
Yingdi Yufc40d872014-02-18 12:56:04 -080016#ifndef NDN_SECURITY_SEC_PUBLIC_INFO_SQLITE3_HPP
17#define NDN_SECURITY_SEC_PUBLIC_INFO_SQLITE3_HPP
Jeff Thompson7ca11f22013-10-04 19:01:30 -070018
Yingdi Yu4f324632014-01-15 18:10:03 -080019#include "../common.hpp"
Yingdi Yu87581582014-01-14 14:28:39 -080020#include "sec-public-info.hpp"
Jeff Thompson7ca11f22013-10-04 19:01:30 -070021
Yingdi Yu874678f2014-01-22 19:30:34 -080022struct sqlite3;
23
Yingdi Yufc40d872014-02-18 12:56:04 -080024namespace ndn {
Alexander Afanasyevfdbfc6d2014-04-14 15:12:11 -070025
Alexander Afanasyev2a7f7202014-04-23 14:25:29 -070026class SecPublicInfoSqlite3 : public SecPublicInfo
27{
Jeff Thompson7ca11f22013-10-04 19:01:30 -070028public:
Alexander Afanasyevfdbfc6d2014-04-14 15:12:11 -070029 class Error : public SecPublicInfo::Error
30 {
31 public:
32 explicit
33 Error(const std::string& what)
34 : SecPublicInfo::Error(what)
35 {
36 }
37 };
Alexander Afanasyevbf1a67a2014-01-05 23:36:13 -080038
Yingdi Yu87581582014-01-14 14:28:39 -080039 SecPublicInfoSqlite3();
Alexander Afanasyevfdbfc6d2014-04-14 15:12:11 -070040
41 virtual
Yingdi Yu87581582014-01-14 14:28:39 -080042 ~SecPublicInfoSqlite3();
Jeff Thompson7ca11f22013-10-04 19:01:30 -070043
Yingdi Yu2e57a582014-02-20 23:34:43 -080044 /**********************
45 * from SecPublicInfo *
46 **********************/
Alexander Afanasyevfdbfc6d2014-04-14 15:12:11 -070047 virtual bool
Jeff Thompson7ca11f22013-10-04 19:01:30 -070048 doesIdentityExist(const Name& identityName);
49
Jeff Thompson7ca11f22013-10-04 19:01:30 -070050 virtual void
51 addIdentity(const Name& identityName);
52
Alexander Afanasyevfdbfc6d2014-04-14 15:12:11 -070053 virtual bool
Jeff Thompson7ca11f22013-10-04 19:01:30 -070054 revokeIdentity();
55
Alexander Afanasyevfdbfc6d2014-04-14 15:12:11 -070056 virtual bool
Yingdi Yu87581582014-01-14 14:28:39 -080057 doesPublicKeyExist(const Name& keyName);
Jeff Thompson7ca11f22013-10-04 19:01:30 -070058
Alexander Afanasyevfdbfc6d2014-04-14 15:12:11 -070059 virtual void
Yingdi Yu87581582014-01-14 14:28:39 -080060 addPublicKey(const Name& keyName, KeyType keyType, const PublicKey& publicKeyDer);
Jeff Thompson7ca11f22013-10-04 19:01:30 -070061
Yingdi Yu4b8c6a22014-04-15 23:00:54 -070062 virtual shared_ptr<PublicKey>
Yingdi Yu87581582014-01-14 14:28:39 -080063 getPublicKey(const Name& keyName);
Jeff Thompson7ca11f22013-10-04 19:01:30 -070064
Jeff Thompson7ca11f22013-10-04 19:01:30 -070065 virtual bool
66 doesCertificateExist(const Name& certificateName);
67
Alexander Afanasyevfdbfc6d2014-04-14 15:12:11 -070068 virtual void
Jeff Thompsonc69163b2013-10-12 13:49:50 -070069 addCertificate(const IdentityCertificate& certificate);
Jeff Thompson7ca11f22013-10-04 19:01:30 -070070
Yingdi Yu4b8c6a22014-04-15 23:00:54 -070071 virtual shared_ptr<IdentityCertificate>
Alexander Afanasyevfdbfc6d2014-04-14 15:12:11 -070072 getCertificate(const Name& certificateName);
Jeff Thompson7ca11f22013-10-04 19:01:30 -070073
74
Jeff Thompson7ca11f22013-10-04 19:01:30 -070075
Alexander Afanasyevfdbfc6d2014-04-14 15:12:11 -070076 virtual Name
Jeff Thompson7ca11f22013-10-04 19:01:30 -070077 getDefaultIdentity();
78
Alexander Afanasyevfdbfc6d2014-04-14 15:12:11 -070079 virtual Name
Jeff Thompson7ca11f22013-10-04 19:01:30 -070080 getDefaultKeyNameForIdentity(const Name& identityName);
81
Alexander Afanasyevfdbfc6d2014-04-14 15:12:11 -070082 virtual Name
Jeff Thompson7ca11f22013-10-04 19:01:30 -070083 getDefaultCertificateNameForKey(const Name& keyName);
84
Yingdi Yu28fd32f2014-01-28 19:03:03 -080085 virtual void
Alexander Afanasyevfdbfc6d2014-04-14 15:12:11 -070086 getAllIdentities(std::vector<Name>& nameList, bool isDefault);
Alexander Afanasyev0c632112013-12-30 15:59:31 -080087
Yingdi Yu28fd32f2014-01-28 19:03:03 -080088 virtual void
Alexander Afanasyevfdbfc6d2014-04-14 15:12:11 -070089 getAllKeyNames(std::vector<Name>& nameList, bool isDefault);
Alexander Afanasyev0c632112013-12-30 15:59:31 -080090
Yingdi Yu28fd32f2014-01-28 19:03:03 -080091 virtual void
Alexander Afanasyevfdbfc6d2014-04-14 15:12:11 -070092 getAllKeyNamesOfIdentity(const Name& identity, std::vector<Name>& nameList, bool isDefault);
Alexander Afanasyev0c632112013-12-30 15:59:31 -080093
Yingdi Yu28fd32f2014-01-28 19:03:03 -080094 virtual void
Alexander Afanasyevfdbfc6d2014-04-14 15:12:11 -070095 getAllCertificateNames(std::vector<Name>& nameList, bool isDefault);
96
97 virtual void
98 getAllCertificateNamesOfKey(const Name& keyName, std::vector<Name>& nameList, bool isDefault);
99
Yingdi Yuf56c68f2014-04-24 21:50:13 -0700100 virtual void
101 deleteCertificateInfo(const Name& certificateName);
102
103 virtual void
104 deletePublicKeyInfo(const Name& keyName);
105
106 virtual void
107 deleteIdentityInfo(const Name& identity);
108
Yingdi Yu87581582014-01-14 14:28:39 -0800109protected:
Alexander Afanasyevfdbfc6d2014-04-14 15:12:11 -0700110 virtual void
Yingdi Yu87581582014-01-14 14:28:39 -0800111 setDefaultIdentityInternal(const Name& identityName);
Jeff Thompson7ca11f22013-10-04 19:01:30 -0700112
113 virtual void
Yingdi Yu87581582014-01-14 14:28:39 -0800114 setDefaultKeyNameForIdentityInternal(const Name& keyName);
115
Alexander Afanasyevfdbfc6d2014-04-14 15:12:11 -0700116 virtual void
117 setDefaultCertificateNameForKeyInternal(const Name& certificateName);
Yingdi Yu28fd32f2014-01-28 19:03:03 -0800118
Yingdi Yu87581582014-01-14 14:28:39 -0800119private:
Yingdi Yu28fd32f2014-01-28 19:03:03 -0800120 sqlite3 * m_database;
Jeff Thompson7ca11f22013-10-04 19:01:30 -0700121};
122
Yingdi Yufc40d872014-02-18 12:56:04 -0800123} // namespace ndn
Jeff Thompson7ca11f22013-10-04 19:01:30 -0700124
Yingdi Yufc40d872014-02-18 12:56:04 -0800125#endif //NDN_SECURITY_SEC_PUBLIC_INFO_SQLITE3_HPP