blob: feb07a5172879208199a8e25ea41f483c38ac897 [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 {
Jeff Thompson7ca11f22013-10-04 19:01:30 -070018
Yingdi Yu87581582014-01-14 14:28:39 -080019class SecPublicInfoSqlite3 : public SecPublicInfo {
Jeff Thompson7ca11f22013-10-04 19:01:30 -070020public:
Yingdi Yu87581582014-01-14 14:28:39 -080021 struct Error : public SecPublicInfo::Error { Error(const std::string &what) : SecPublicInfo::Error(what) {} };
Alexander Afanasyevbf1a67a2014-01-05 23:36:13 -080022
Yingdi Yu87581582014-01-14 14:28:39 -080023 SecPublicInfoSqlite3();
Jeff Thompson7ca11f22013-10-04 19:01:30 -070024
Jeff Thompson7ca11f22013-10-04 19:01:30 -070025 virtual
Yingdi Yu87581582014-01-14 14:28:39 -080026 ~SecPublicInfoSqlite3();
Jeff Thompson7ca11f22013-10-04 19:01:30 -070027
Yingdi Yu2e57a582014-02-20 23:34:43 -080028 /**********************
29 * from SecPublicInfo *
30 **********************/
Jeff Thompson7ca11f22013-10-04 19:01:30 -070031 virtual bool
32 doesIdentityExist(const Name& identityName);
33
Jeff Thompson7ca11f22013-10-04 19:01:30 -070034 virtual void
35 addIdentity(const Name& identityName);
36
Jeff Thompson7ca11f22013-10-04 19:01:30 -070037 virtual bool
38 revokeIdentity();
39
Jeff Thompson7ca11f22013-10-04 19:01:30 -070040 virtual bool
Yingdi Yu87581582014-01-14 14:28:39 -080041 doesPublicKeyExist(const Name& keyName);
Jeff Thompson7ca11f22013-10-04 19:01:30 -070042
Jeff Thompson7ca11f22013-10-04 19:01:30 -070043 virtual void
Yingdi Yu87581582014-01-14 14:28:39 -080044 addPublicKey(const Name& keyName, KeyType keyType, const PublicKey& publicKeyDer);
Jeff Thompson7ca11f22013-10-04 19:01:30 -070045
Alexander Afanasyevbf1a67a2014-01-05 23:36:13 -080046 virtual ptr_lib::shared_ptr<PublicKey>
Yingdi Yu87581582014-01-14 14:28:39 -080047 getPublicKey(const Name& keyName);
Jeff Thompson7ca11f22013-10-04 19:01:30 -070048
Jeff Thompson7ca11f22013-10-04 19:01:30 -070049 virtual bool
50 doesCertificateExist(const Name& certificateName);
51
Jeff Thompson7ca11f22013-10-04 19:01:30 -070052 virtual void
Jeff Thompsonc69163b2013-10-12 13:49:50 -070053 addCertificate(const IdentityCertificate& certificate);
Jeff Thompson7ca11f22013-10-04 19:01:30 -070054
Alexander Afanasyevbf1a67a2014-01-05 23:36:13 -080055 virtual ptr_lib::shared_ptr<IdentityCertificate>
Yingdi Yu88663af2014-01-15 15:21:38 -080056 getCertificate(const Name &certificateName);
Jeff Thompson7ca11f22013-10-04 19:01:30 -070057
58
Jeff Thompson7ca11f22013-10-04 19:01:30 -070059
Jeff Thompson7ca11f22013-10-04 19:01:30 -070060 virtual Name
61 getDefaultIdentity();
62
Jeff Thompson7ca11f22013-10-04 19:01:30 -070063 virtual Name
64 getDefaultKeyNameForIdentity(const Name& identityName);
65
Jeff Thompson7ca11f22013-10-04 19:01:30 -070066 virtual Name
67 getDefaultCertificateNameForKey(const Name& keyName);
68
Yingdi Yu28fd32f2014-01-28 19:03:03 -080069 virtual void
70 getAllIdentities(std::vector<Name> &nameList, bool isDefault);
Alexander Afanasyev0c632112013-12-30 15:59:31 -080071
Yingdi Yu28fd32f2014-01-28 19:03:03 -080072 virtual void
73 getAllKeyNames(std::vector<Name> &nameList, bool isDefault);
Alexander Afanasyev0c632112013-12-30 15:59:31 -080074
Yingdi Yu28fd32f2014-01-28 19:03:03 -080075 virtual void
76 getAllKeyNamesOfIdentity(const Name& identity, std::vector<Name> &nameList, bool isDefault);
Alexander Afanasyev0c632112013-12-30 15:59:31 -080077
Yingdi Yu28fd32f2014-01-28 19:03:03 -080078 virtual void
79 getAllCertificateNames(std::vector<Name> &nameList, bool isDefault);
Alexander Afanasyev0c632112013-12-30 15:59:31 -080080
Yingdi Yu28fd32f2014-01-28 19:03:03 -080081 virtual void
82 getAllCertificateNamesOfKey(const Name& keyName, std::vector<Name> &nameList, bool isDefault);
Alexander Afanasyev0c632112013-12-30 15:59:31 -080083
Yingdi Yu87581582014-01-14 14:28:39 -080084protected:
Yingdi Yu87581582014-01-14 14:28:39 -080085 virtual void
86 setDefaultIdentityInternal(const Name& identityName);
Jeff Thompson7ca11f22013-10-04 19:01:30 -070087
88 virtual void
Yingdi Yu87581582014-01-14 14:28:39 -080089 setDefaultKeyNameForIdentityInternal(const Name& keyName);
90
Yingdi Yu87581582014-01-14 14:28:39 -080091 virtual void
92 setDefaultCertificateNameForKeyInternal(const Name& certificateName);
Yingdi Yu28fd32f2014-01-28 19:03:03 -080093
Yingdi Yu28fd32f2014-01-28 19:03:03 -080094 virtual void
95 deleteCertificateInfo(const Name &certificateName);
96
Yingdi Yu28fd32f2014-01-28 19:03:03 -080097 virtual void
98 deletePublicKeyInfo(const Name &keyName);
99
Yingdi Yu28fd32f2014-01-28 19:03:03 -0800100 virtual void
101 deleteIdentityInfo(const Name &identity);
Yingdi Yu87581582014-01-14 14:28:39 -0800102
103private:
Yingdi Yu28fd32f2014-01-28 19:03:03 -0800104 sqlite3 * m_database;
Jeff Thompson7ca11f22013-10-04 19:01:30 -0700105};
106
Yingdi Yufc40d872014-02-18 12:56:04 -0800107} // namespace ndn
Jeff Thompson7ca11f22013-10-04 19:01:30 -0700108
Yingdi Yufc40d872014-02-18 12:56:04 -0800109#endif //NDN_SECURITY_SEC_PUBLIC_INFO_SQLITE3_HPP