| /* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */ |
| /** |
| * Copyright (c) 2013-2016 Regents of the University of California. |
| * |
| * This file is part of ndn-cxx library (NDN C++ library with eXperimental eXtensions). |
| * |
| * ndn-cxx library is free software: you can redistribute it and/or modify it under the |
| * terms of the GNU Lesser General Public License as published by the Free Software |
| * Foundation, either version 3 of the License, or (at your option) any later version. |
| * |
| * ndn-cxx library is distributed in the hope that it will be useful, but WITHOUT ANY |
| * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A |
| * PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. |
| * |
| * You should have received copies of the GNU General Public License and GNU Lesser |
| * General Public License along with ndn-cxx, e.g., in COPYING.md file. If not, see |
| * <http://www.gnu.org/licenses/>. |
| * |
| * See AUTHORS.md for complete list of ndn-cxx authors and contributors. |
| */ |
| |
| #ifndef NDN_SECURITTY_PIB_SQLITE3_HPP |
| #define NDN_SECURITTY_PIB_SQLITE3_HPP |
| |
| #include "pib-impl.hpp" |
| |
| struct sqlite3; |
| |
| namespace ndn { |
| namespace security { |
| |
| /** |
| * @brief Pib backend implementation based on SQLite3 database |
| * |
| * All the contents in Pib are stored in a SQLite3 database file. |
| * This backend provides more persistent storage than PibMemory. |
| */ |
| class PibSqlite3 : public PibImpl |
| { |
| public: |
| /** |
| * @brief Constructor of PibSqlite3 |
| * |
| * This method will create a SQLite3 database file under the directory @p dir. |
| * If the directory does not exist, it will be created automatically. |
| * It assumes that the directory does not contain a PIB database of an older version, |
| * It is user's responsibility to update the older version database or remove the database. |
| * |
| * @param dir The directory where the database file is located. By default, it points to the |
| * $HOME/.ndn directory. |
| * @throws PibImpl::Error when initialization fails. |
| */ |
| explicit |
| PibSqlite3(const std::string& dir = ""); |
| |
| /** |
| * @brief Destruct and cleanup internal state |
| */ |
| ~PibSqlite3(); |
| |
| public: // TpmLocator management |
| |
| void |
| setTpmLocator(const std::string& tpmLocator) final; |
| |
| std::string |
| getTpmLocator() const final; |
| |
| public: // Identity management |
| |
| bool |
| hasIdentity(const Name& identity) const final; |
| |
| void |
| addIdentity(const Name& identity) final; |
| |
| void |
| removeIdentity(const Name& identity) final; |
| |
| std::set<Name> |
| getIdentities() const final; |
| |
| void |
| setDefaultIdentity(const Name& identityName) final; |
| |
| Name |
| getDefaultIdentity() const final; |
| |
| public: // Key management |
| |
| bool |
| hasKey(const Name& identity, const name::Component& keyId) const final; |
| |
| void |
| addKey(const Name& identity, const name::Component& keyId, const v1::PublicKey& publicKey) final; |
| |
| void |
| removeKey(const Name& identity, const name::Component& keyId) final; |
| |
| v1::PublicKey |
| getKeyBits(const Name& identity, const name::Component& keyId) const final; |
| |
| std::set<name::Component> |
| getKeysOfIdentity(const Name& identity) const final; |
| |
| void |
| setDefaultKeyOfIdentity(const Name& identity, const name::Component& keyId) final; |
| |
| name::Component |
| getDefaultKeyOfIdentity(const Name& identity) const final; |
| |
| public: // Certificate Management |
| |
| bool |
| hasCertificate(const Name& certName) const final; |
| |
| void |
| addCertificate(const v1::IdentityCertificate& certificate) final; |
| |
| void |
| removeCertificate(const Name& certName) final; |
| |
| v1::IdentityCertificate |
| getCertificate(const Name& certName) const final; |
| |
| std::set<Name> |
| getCertificatesOfKey(const Name& identity, const name::Component& keyId) const final; |
| |
| void |
| setDefaultCertificateOfKey(const Name& identity, const name::Component& keyId, |
| const Name& certName) final; |
| |
| v1::IdentityCertificate |
| getDefaultCertificateOfKey(const Name& identity, const name::Component& keyId) const final; |
| |
| private: |
| sqlite3* m_database; |
| }; |
| |
| } // namespace security |
| } // namespace ndn |
| |
| #endif // NDN_SECURITTY_PIB_SQLITE3_HPP |