blob: 624181744ecbcdb2a5c74b4daa75b7094f4ee79d [file] [log] [blame]
Jeff Thompson7ca11f22013-10-04 19:01:30 -07001/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil -*- */
2/**
3 * Copyright (C) 2013 Regents of the University of California.
4 * @author: Yingdi Yu <yingdi@cs.ucla.edu>
Jeff Thompson22285ec2013-10-22 17:43:02 -07005 * @author: Jeff Thompson <jefft0@remap.ucla.edu>
Jeff Thompson7ca11f22013-10-04 19:01:30 -07006 * See COPYING for copyright and distribution information.
7 */
8
Yingdi Yufc40d872014-02-18 12:56:04 -08009#ifndef NDN_SECURITY_SEC_PUBLIC_INFO_SQLITE3_HPP
10#define NDN_SECURITY_SEC_PUBLIC_INFO_SQLITE3_HPP
Jeff Thompson7ca11f22013-10-04 19:01:30 -070011
Yingdi Yu4f324632014-01-15 18:10:03 -080012#include "../common.hpp"
Yingdi Yu87581582014-01-14 14:28:39 -080013#include "sec-public-info.hpp"
Jeff Thompson7ca11f22013-10-04 19:01:30 -070014
Yingdi Yu874678f2014-01-22 19:30:34 -080015struct sqlite3;
16
Yingdi Yufc40d872014-02-18 12:56:04 -080017namespace ndn {
Alexander Afanasyevfdbfc6d2014-04-14 15:12:11 -070018
Yingdi Yu87581582014-01-14 14:28:39 -080019class SecPublicInfoSqlite3 : public SecPublicInfo {
Jeff Thompson7ca11f22013-10-04 19:01:30 -070020public:
Alexander Afanasyevfdbfc6d2014-04-14 15:12:11 -070021 class Error : public SecPublicInfo::Error
22 {
23 public:
24 explicit
25 Error(const std::string& what)
26 : SecPublicInfo::Error(what)
27 {
28 }
29 };
Alexander Afanasyevbf1a67a2014-01-05 23:36:13 -080030
Yingdi Yu87581582014-01-14 14:28:39 -080031 SecPublicInfoSqlite3();
Alexander Afanasyevfdbfc6d2014-04-14 15:12:11 -070032
33 virtual
Yingdi Yu87581582014-01-14 14:28:39 -080034 ~SecPublicInfoSqlite3();
Jeff Thompson7ca11f22013-10-04 19:01:30 -070035
Yingdi Yu2e57a582014-02-20 23:34:43 -080036 /**********************
37 * from SecPublicInfo *
38 **********************/
Alexander Afanasyevfdbfc6d2014-04-14 15:12:11 -070039 virtual bool
Jeff Thompson7ca11f22013-10-04 19:01:30 -070040 doesIdentityExist(const Name& identityName);
41
Jeff Thompson7ca11f22013-10-04 19:01:30 -070042 virtual void
43 addIdentity(const Name& identityName);
44
Alexander Afanasyevfdbfc6d2014-04-14 15:12:11 -070045 virtual bool
Jeff Thompson7ca11f22013-10-04 19:01:30 -070046 revokeIdentity();
47
Alexander Afanasyevfdbfc6d2014-04-14 15:12:11 -070048 virtual bool
Yingdi Yu87581582014-01-14 14:28:39 -080049 doesPublicKeyExist(const Name& keyName);
Jeff Thompson7ca11f22013-10-04 19:01:30 -070050
Alexander Afanasyevfdbfc6d2014-04-14 15:12:11 -070051 virtual void
Yingdi Yu87581582014-01-14 14:28:39 -080052 addPublicKey(const Name& keyName, KeyType keyType, const PublicKey& publicKeyDer);
Jeff Thompson7ca11f22013-10-04 19:01:30 -070053
Yingdi Yu4b8c6a22014-04-15 23:00:54 -070054 virtual shared_ptr<PublicKey>
Yingdi Yu87581582014-01-14 14:28:39 -080055 getPublicKey(const Name& keyName);
Jeff Thompson7ca11f22013-10-04 19:01:30 -070056
Jeff Thompson7ca11f22013-10-04 19:01:30 -070057 virtual bool
58 doesCertificateExist(const Name& certificateName);
59
Alexander Afanasyevfdbfc6d2014-04-14 15:12:11 -070060 virtual void
Jeff Thompsonc69163b2013-10-12 13:49:50 -070061 addCertificate(const IdentityCertificate& certificate);
Jeff Thompson7ca11f22013-10-04 19:01:30 -070062
Yingdi Yu4b8c6a22014-04-15 23:00:54 -070063 virtual shared_ptr<IdentityCertificate>
Alexander Afanasyevfdbfc6d2014-04-14 15:12:11 -070064 getCertificate(const Name& certificateName);
Jeff Thompson7ca11f22013-10-04 19:01:30 -070065
66
Jeff Thompson7ca11f22013-10-04 19:01:30 -070067
Alexander Afanasyevfdbfc6d2014-04-14 15:12:11 -070068 virtual Name
Jeff Thompson7ca11f22013-10-04 19:01:30 -070069 getDefaultIdentity();
70
Alexander Afanasyevfdbfc6d2014-04-14 15:12:11 -070071 virtual Name
Jeff Thompson7ca11f22013-10-04 19:01:30 -070072 getDefaultKeyNameForIdentity(const Name& identityName);
73
Alexander Afanasyevfdbfc6d2014-04-14 15:12:11 -070074 virtual Name
Jeff Thompson7ca11f22013-10-04 19:01:30 -070075 getDefaultCertificateNameForKey(const Name& keyName);
76
Yingdi Yu28fd32f2014-01-28 19:03:03 -080077 virtual void
Alexander Afanasyevfdbfc6d2014-04-14 15:12:11 -070078 getAllIdentities(std::vector<Name>& nameList, bool isDefault);
Alexander Afanasyev0c632112013-12-30 15:59:31 -080079
Yingdi Yu28fd32f2014-01-28 19:03:03 -080080 virtual void
Alexander Afanasyevfdbfc6d2014-04-14 15:12:11 -070081 getAllKeyNames(std::vector<Name>& nameList, bool isDefault);
Alexander Afanasyev0c632112013-12-30 15:59:31 -080082
Yingdi Yu28fd32f2014-01-28 19:03:03 -080083 virtual void
Alexander Afanasyevfdbfc6d2014-04-14 15:12:11 -070084 getAllKeyNamesOfIdentity(const Name& identity, std::vector<Name>& nameList, bool isDefault);
Alexander Afanasyev0c632112013-12-30 15:59:31 -080085
Yingdi Yu28fd32f2014-01-28 19:03:03 -080086 virtual void
Alexander Afanasyevfdbfc6d2014-04-14 15:12:11 -070087 getAllCertificateNames(std::vector<Name>& nameList, bool isDefault);
88
89 virtual void
90 getAllCertificateNamesOfKey(const Name& keyName, std::vector<Name>& nameList, bool isDefault);
91
Yingdi Yu87581582014-01-14 14:28:39 -080092protected:
Alexander Afanasyevfdbfc6d2014-04-14 15:12:11 -070093 virtual void
Yingdi Yu87581582014-01-14 14:28:39 -080094 setDefaultIdentityInternal(const Name& identityName);
Jeff Thompson7ca11f22013-10-04 19:01:30 -070095
96 virtual void
Yingdi Yu87581582014-01-14 14:28:39 -080097 setDefaultKeyNameForIdentityInternal(const Name& keyName);
98
Alexander Afanasyevfdbfc6d2014-04-14 15:12:11 -070099 virtual void
100 setDefaultCertificateNameForKeyInternal(const Name& certificateName);
Yingdi Yu28fd32f2014-01-28 19:03:03 -0800101
Yingdi Yu28fd32f2014-01-28 19:03:03 -0800102 virtual void
Alexander Afanasyevfdbfc6d2014-04-14 15:12:11 -0700103 deleteCertificateInfo(const Name& certificateName);
Yingdi Yu28fd32f2014-01-28 19:03:03 -0800104
Yingdi Yu28fd32f2014-01-28 19:03:03 -0800105 virtual void
Alexander Afanasyevfdbfc6d2014-04-14 15:12:11 -0700106 deletePublicKeyInfo(const Name& keyName);
Yingdi Yu28fd32f2014-01-28 19:03:03 -0800107
Yingdi Yu28fd32f2014-01-28 19:03:03 -0800108 virtual void
Alexander Afanasyevfdbfc6d2014-04-14 15:12:11 -0700109 deleteIdentityInfo(const Name& identity);
110
Yingdi Yu87581582014-01-14 14:28:39 -0800111private:
Yingdi Yu28fd32f2014-01-28 19:03:03 -0800112 sqlite3 * m_database;
Jeff Thompson7ca11f22013-10-04 19:01:30 -0700113};
114
Yingdi Yufc40d872014-02-18 12:56:04 -0800115} // namespace ndn
Jeff Thompson7ca11f22013-10-04 19:01:30 -0700116
Yingdi Yufc40d872014-02-18 12:56:04 -0800117#endif //NDN_SECURITY_SEC_PUBLIC_INFO_SQLITE3_HPP