/* -*- 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_SECURITY_PIB_MEMORY_HPP
#define NDN_SECURITY_PIB_MEMORY_HPP

#include "pib-impl.hpp"

namespace ndn {
namespace security {

/**
 * @brief An in-memory implementation of Pib
 *
 * All the contents in Pib are stored in memory
 * and have the same lifetime as the implementation instance.
 */
class PibMemory : public PibImpl
{
public:
  class Error : public PibImpl::Error
  {
  public:
    explicit
    Error(const std::string& what)
      : PibImpl::Error(what)
    {
    }
  };

public:
  PibMemory();

public: // TpmLocator management

  void
  setTpmLocator(const std::string& tpmLocator) override;

  std::string
  getTpmLocator() const override;

public: // Identity management

  bool
  hasIdentity(const Name& identity) const override;

  void
  addIdentity(const Name& identity) override;

  void
  removeIdentity(const Name& identity) override;

  std::set<Name>
  getIdentities() const override;

  void
  setDefaultIdentity(const Name& identityName) override;

  Name
  getDefaultIdentity() const override;

public: // Key management

  bool
  hasKey(const Name& identity, const name::Component& keyId) const override;

  void
  addKey(const Name& identity, const name::Component& keyId, const v1::PublicKey& publicKey) override;

  void
  removeKey(const Name& identity, const name::Component& keyId) override;

  v1::PublicKey
  getKeyBits(const Name& identity, const name::Component& keyId) const override;

  std::set<name::Component>
  getKeysOfIdentity(const Name& identity) const override;

  void
  setDefaultKeyOfIdentity(const Name& identity, const name::Component& keyId) override;

  name::Component
  getDefaultKeyOfIdentity(const Name& identity) const override;

public: // Certificate management

  bool
  hasCertificate(const Name& certName) const override;

  void
  addCertificate(const v1::IdentityCertificate& certificate) override;

  void
  removeCertificate(const Name& certName) override;

  v1::IdentityCertificate
  getCertificate(const Name& certName) const override;

  std::set<Name>
  getCertificatesOfKey(const Name& identity, const name::Component& keyId) const override;

  void
  setDefaultCertificateOfKey(const Name& identity, const name::Component& keyId, const Name& certName) override;

  v1::IdentityCertificate
  getDefaultCertificateOfKey(const Name& identity, const name::Component& keyId) const override;

private: // Key management

  Name
  getKeyName(const Name& identity, const name::Component& keyId) const;

private:

  std::set<Name> m_identities;
  bool m_hasDefaultIdentity;
  Name m_defaultIdentity;

  /// @brief keyName => keyBits
  std::map<Name, v1::PublicKey> m_keys;

  /// @brief identity => default key Name
  std::map<Name, Name> m_defaultKey;

  /// @brief certificate Name => certificate
  std::map<Name, v1::IdentityCertificate> m_certs;

  /// @brief keyName => default certificate Name
  std::map<Name, Name> m_defaultCert;
};

} // namespace security
} // namespace ndn

#endif // NDN_SECURITY_PIB_MEMORY_HPP
