<commit_before>/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil -*- */
/**
 * Copyright (C) 2013 Regents of the University of California.
 * @author: <NAME> <<EMAIL>>
 * @author: <NAME> <<EMAIL>>
 * See COPYING for copyright and distribution information.
 */

#include <ndn-cpp/security/security-exception.hpp>
#include <ndn-cpp/security/certificate/identity-certificate.hpp>

using namespace std;

namespace ndn {

IdentityCertificate::IdentityCertificate(const Data& data)
  : Certificate(data)
{
  if (!isCorrectName(data.getName()))
    throw SecurityException("Wrong Identity Certificate Name!");
}

bool
IdentityCertificate::isCorrectName(const Name& name)
{
  int i = name.size() - 1;
  
  for (; i >= 0; i--) {
    if(name.get(i).toEscapedString() == string("ID-CERT"))
      break;
  }

  if (i < 0)
    return false;
  
  return true;
}

Data& 
IdentityCertificate::setName(const Name& name)
{
  if (!isCorrectName(name))
    throw SecurityException("Wrong Identity Certificate Name!");
  <commit_msg>security: IdentityCertificate: Need to define the virtual destructor.<commit_after>/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil -*- */
/**
 * Copyright (C) 2013 Regents of the University of California.
 * @author: <NAME> <<EMAIL>>
 * @author: <NAME> <<EMAIL>>
 * See COPYING for copyright and distribution information.
 */

#include <ndn-cpp/security/security-exception.hpp>
#include <ndn-cpp/security/certificate/identity-certificate.hpp>

using namespace std;

namespace ndn {

IdentityCertificate::IdentityCertificate(const Data& data)
  : Certificate(data)
{
  if (!isCorrectName(data.getName()))
    throw SecurityException("Wrong Identity Certificate Name!");
}

IdentityCertificate::~IdentityCertificate()
{
}

bool
IdentityCertificate::isCorrectName(const Name& name)
{
  int i = name.size() - 1;
  
  for (; i >= 0; i--) {
    if(name.get(i).toEscapedString() == string("ID-CERT"))
      break;
  }

  if (i < 0)
    return false;
  
  return true;
}

Data& 
IdentityCertificate::setName(const Name& name)
{
  if (!isCorrectName(name))
    throw SecurityException("Wrong Identity Certificate Name!");
  
{'fraction_non_alphanumeric': 0.15384615384615385, 'fraction_numerical': 0.006526806526806527, 'mean_word_length': 4.325062034739454, 'pattern_counts': {'":': 0, '<': 21, '<?xml version=': 0, '>': 21, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '931405', 'n_tokens_mistral': 700, 'n_tokens_neox': 670, 'n_words': 166}