/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
/**
 * Copyright (c) 2017-2019, Regents of the University of California.
 *
 * This file is part of ndncert, a certificate management system based on NDN.
 *
 * ndncert is free software: you can redistribute it and/or modify it under the terms
 * of the GNU General Public License as published by the Free Software Foundation, either
 * version 3 of the License, or (at your option) any later version.
 *
 * ndncert 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 General Public License for more details.
 *
 * You should have received copies of the GNU General Public License along with
 * ndncert, e.g., in COPYING.md file.  If not, see <http://www.gnu.org/licenses/>.
 *
 * See AUTHORS.md for complete list of ndncert authors and contributors.
 */

#include "certificate-request.hpp"
#include <ndn-cxx/util/indented-stream.hpp>

namespace ndn {
namespace ndncert {

CertificateRequest::CertificateRequest() = default;

CertificateRequest::CertificateRequest(const Name& caName, const std::string& requestId, int status,
                                       const security::v2::Certificate& cert)
  : m_caName(caName)
  , m_requestId(requestId)
  , m_status(status)
  , m_cert(cert)
{
}

CertificateRequest::CertificateRequest(const Name& caName, const std::string& requestId, int status,
                                       const std::string& challengeStatus, const std::string& challengeType,
                                       const std::string& challengeTp, int remainingTime, int remainingTries,
                                       const JsonSection& challengeSecrets, const security::v2::Certificate& cert)
  : m_caName(caName)
  , m_requestId(requestId)
  , m_status(status)
  , m_cert(cert)
  , m_challengeStatus(challengeStatus)
  , m_challengeType(challengeType)
  , m_challengeTp(challengeTp)
  , m_remainingTime(remainingTime)
  , m_remainingTries(remainingTries)
  , m_challengeSecrets(challengeSecrets)
{
}

void
CertificateRequest::setProbeToken(const shared_ptr<Data>& probeToken)
{
  m_probeToken = probeToken;
}

std::ostream&
operator<<(std::ostream& os, const CertificateRequest& request)
{
  os << "Request CA name:\n";
  os << "  " << request.m_caName << "\n";
  os << "Request ID:\n";
  os << "  " << request.m_requestId << "\n";
  if (request.m_status != -1) {
    os << "Request Status:\n";
    os << "  " << request.m_status << "\n";
  }
  if (request.m_challengeStatus != "") {
    os << "Challenge Status:\n";
    os << "  " << request.m_challengeStatus << "\n";
  }
  if (request.m_challengeType != "") {
    os << "Request Challenge Type:\n";
    os << "  " << request.m_challengeType << "\n";
  }
  os << "Certificate:\n";
  util::IndentedStream os2(os, "  ");
  os2 << request.m_cert;
  return os;
}

} // namespace ndncert
} // namespace ndn
