blob: 4f5115f0fe88f1aec36d66af7e97b2dd25d29bfd [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
Alexander Afanasyev2a7f7202014-04-23 14:25:29 -070019class SecPublicInfoSqlite3 : public SecPublicInfo
20{
Jeff Thompson7ca11f22013-10-04 19:01:30 -070021public:
Alexander Afanasyevfdbfc6d2014-04-14 15:12:11 -070022 class Error : public SecPublicInfo::Error
23 {
24 public:
25 explicit
26 Error(const std::string& what)
27 : SecPublicInfo::Error(what)
28 {
29 }
30 };
Alexander Afanasyevbf1a67a2014-01-05 23:36:13 -080031
Yingdi Yu87581582014-01-14 14:28:39 -080032 SecPublicInfoSqlite3();
Alexander Afanasyevfdbfc6d2014-04-14 15:12:11 -070033
34 virtual
Yingdi Yu87581582014-01-14 14:28:39 -080035 ~SecPublicInfoSqlite3();
Jeff Thompson7ca11f22013-10-04 19:01:30 -070036
Yingdi Yu2e57a582014-02-20 23:34:43 -080037 /**********************
38 * from SecPublicInfo *
39 **********************/
Alexander Afanasyevfdbfc6d2014-04-14 15:12:11 -070040 virtual bool
Jeff Thompson7ca11f22013-10-04 19:01:30 -070041 doesIdentityExist(const Name& identityName);
42
Jeff Thompson7ca11f22013-10-04 19:01:30 -070043 virtual void
44 addIdentity(const Name& identityName);
45
Alexander Afanasyevfdbfc6d2014-04-14 15:12:11 -070046 virtual bool
Jeff Thompson7ca11f22013-10-04 19:01:30 -070047 revokeIdentity();
48
Alexander Afanasyevfdbfc6d2014-04-14 15:12:11 -070049 virtual bool
Yingdi Yu87581582014-01-14 14:28:39 -080050 doesPublicKeyExist(const Name& keyName);
Jeff Thompson7ca11f22013-10-04 19:01:30 -070051
Alexander Afanasyevfdbfc6d2014-04-14 15:12:11 -070052 virtual void
Yingdi Yu87581582014-01-14 14:28:39 -080053 addPublicKey(const Name& keyName, KeyType keyType, const PublicKey& publicKeyDer);
Jeff Thompson7ca11f22013-10-04 19:01:30 -070054
Yingdi Yu4b8c6a22014-04-15 23:00:54 -070055 virtual shared_ptr<PublicKey>
Yingdi Yu87581582014-01-14 14:28:39 -080056 getPublicKey(const Name& keyName);
Jeff Thompson7ca11f22013-10-04 19:01:30 -070057
Jeff Thompson7ca11f22013-10-04 19:01:30 -070058 virtual bool
59 doesCertificateExist(const Name& certificateName);
60
Alexander Afanasyevfdbfc6d2014-04-14 15:12:11 -070061 virtual void
Jeff Thompsonc69163b2013-10-12 13:49:50 -070062 addCertificate(const IdentityCertificate& certificate);
Jeff Thompson7ca11f22013-10-04 19:01:30 -070063
Yingdi Yu4b8c6a22014-04-15 23:00:54 -070064 virtual shared_ptr<IdentityCertificate>
Alexander Afanasyevfdbfc6d2014-04-14 15:12:11 -070065 getCertificate(const Name& certificateName);
Jeff Thompson7ca11f22013-10-04 19:01:30 -070066
67
Jeff Thompson7ca11f22013-10-04 19:01:30 -070068
Alexander Afanasyevfdbfc6d2014-04-14 15:12:11 -070069 virtual Name
Jeff Thompson7ca11f22013-10-04 19:01:30 -070070 getDefaultIdentity();
71
Alexander Afanasyevfdbfc6d2014-04-14 15:12:11 -070072 virtual Name
Jeff Thompson7ca11f22013-10-04 19:01:30 -070073 getDefaultKeyNameForIdentity(const Name& identityName);
74
Alexander Afanasyevfdbfc6d2014-04-14 15:12:11 -070075 virtual Name
Jeff Thompson7ca11f22013-10-04 19:01:30 -070076 getDefaultCertificateNameForKey(const Name& keyName);
77
Yingdi Yu28fd32f2014-01-28 19:03:03 -080078 virtual void
Alexander Afanasyevfdbfc6d2014-04-14 15:12:11 -070079 getAllIdentities(std::vector<Name>& nameList, bool isDefault);
Alexander Afanasyev0c632112013-12-30 15:59:31 -080080
Yingdi Yu28fd32f2014-01-28 19:03:03 -080081 virtual void
Alexander Afanasyevfdbfc6d2014-04-14 15:12:11 -070082 getAllKeyNames(std::vector<Name>& nameList, bool isDefault);
Alexander Afanasyev0c632112013-12-30 15:59:31 -080083
Yingdi Yu28fd32f2014-01-28 19:03:03 -080084 virtual void
Alexander Afanasyevfdbfc6d2014-04-14 15:12:11 -070085 getAllKeyNamesOfIdentity(const Name& identity, std::vector<Name>& nameList, bool isDefault);
Alexander Afanasyev0c632112013-12-30 15:59:31 -080086
Yingdi Yu28fd32f2014-01-28 19:03:03 -080087 virtual void
Alexander Afanasyevfdbfc6d2014-04-14 15:12:11 -070088 getAllCertificateNames(std::vector<Name>& nameList, bool isDefault);
89
90 virtual void
91 getAllCertificateNamesOfKey(const Name& keyName, std::vector<Name>& nameList, bool isDefault);
92
Yingdi Yu87581582014-01-14 14:28:39 -080093protected:
Alexander Afanasyevfdbfc6d2014-04-14 15:12:11 -070094 virtual void
Yingdi Yu87581582014-01-14 14:28:39 -080095 setDefaultIdentityInternal(const Name& identityName);
Jeff Thompson7ca11f22013-10-04 19:01:30 -070096
97 virtual void
Yingdi Yu87581582014-01-14 14:28:39 -080098 setDefaultKeyNameForIdentityInternal(const Name& keyName);
99
Alexander Afanasyevfdbfc6d2014-04-14 15:12:11 -0700100 virtual void
101 setDefaultCertificateNameForKeyInternal(const Name& certificateName);
Yingdi Yu28fd32f2014-01-28 19:03:03 -0800102
Yingdi Yu28fd32f2014-01-28 19:03:03 -0800103 virtual void
Alexander Afanasyevfdbfc6d2014-04-14 15:12:11 -0700104 deleteCertificateInfo(const Name& certificateName);
Yingdi Yu28fd32f2014-01-28 19:03:03 -0800105
Yingdi Yu28fd32f2014-01-28 19:03:03 -0800106 virtual void
Alexander Afanasyevfdbfc6d2014-04-14 15:12:11 -0700107 deletePublicKeyInfo(const Name& keyName);
Yingdi Yu28fd32f2014-01-28 19:03:03 -0800108
Yingdi Yu28fd32f2014-01-28 19:03:03 -0800109 virtual void
Alexander Afanasyevfdbfc6d2014-04-14 15:12:11 -0700110 deleteIdentityInfo(const Name& identity);
111
Yingdi Yu87581582014-01-14 14:28:39 -0800112private:
Yingdi Yu28fd32f2014-01-28 19:03:03 -0800113 sqlite3 * m_database;
Jeff Thompson7ca11f22013-10-04 19:01:30 -0700114};
115
Yingdi Yufc40d872014-02-18 12:56:04 -0800116} // namespace ndn
Jeff Thompson7ca11f22013-10-04 19:01:30 -0700117
Yingdi Yufc40d872014-02-18 12:56:04 -0800118#endif //NDN_SECURITY_SEC_PUBLIC_INFO_SQLITE3_HPP