Yingdi Yu | 0a312e5 | 2015-07-22 13:14:53 -0700 | [diff] [blame^] | 1 | /* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */ |
| 2 | /** |
| 3 | * Copyright (c) 2014-2015, Regents of the University of California. |
| 4 | * |
| 5 | * This file is part of ndn-tools (Named Data Networking Essential Tools). |
| 6 | * See AUTHORS.md for complete list of ndn-tools authors and contributors. |
| 7 | * |
| 8 | * ndn-tools is free software: you can redistribute it and/or modify it under the terms |
| 9 | * of the GNU General Public License as published by the Free Software Foundation, |
| 10 | * either version 3 of the License, or (at your option) any later version. |
| 11 | * |
| 12 | * ndn-tools is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; |
| 13 | * without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR |
| 14 | * PURPOSE. See the GNU General Public License for more details. |
| 15 | * |
| 16 | * You should have received a copy of the GNU General Public License along with |
| 17 | * ndn-tools, e.g., in COPYING.md file. If not, see <http://www.gnu.org/licenses/>. |
| 18 | * |
| 19 | * @author Yingdi Yu <yingdi@cs.ucla.edu> |
| 20 | */ |
| 21 | |
| 22 | #include "identity-management-time-fixture.hpp" |
| 23 | |
| 24 | namespace ndn { |
| 25 | namespace tests { |
| 26 | |
| 27 | IdentityManagementTimeFixture::IdentityManagementTimeFixture() |
| 28 | : m_keyChainTmpPath(boost::filesystem::path(TMP_TESTS_PATH) / "PibIdMgmtTimeTest") |
| 29 | , m_keyChain(std::string("pib-sqlite3:").append(m_keyChainTmpPath.string()), |
| 30 | std::string("tpm-file:").append(m_keyChainTmpPath.string())) |
| 31 | { |
| 32 | } |
| 33 | |
| 34 | IdentityManagementTimeFixture::~IdentityManagementTimeFixture() |
| 35 | { |
| 36 | for (const auto& identity : m_identities) { |
| 37 | m_keyChain.deleteIdentity(identity); |
| 38 | } |
| 39 | |
| 40 | boost::filesystem::remove_all(m_keyChainTmpPath); |
| 41 | } |
| 42 | |
| 43 | bool |
| 44 | IdentityManagementTimeFixture::addIdentity(const Name& identity, const KeyParams& params) |
| 45 | { |
| 46 | try { |
| 47 | m_keyChain.createIdentity(identity, params); |
| 48 | m_identities.push_back(identity); |
| 49 | return true; |
| 50 | } |
| 51 | catch (std::runtime_error&) { |
| 52 | return false; |
| 53 | } |
| 54 | } |
| 55 | |
| 56 | |
| 57 | } // namespace tests |
| 58 | } // namespace ndn |