<commit_before>/*---------------------------------------------------------------------\
|                                                                      |
|                     _     _   _   _     __     _                     |
|                    | |   | | | \_/ |   /  \   | |                    |
|                    | |   | | | |_| |  / /\ \  | |                    |
|                    | |__ | | | | | | / ____ \ | |__                  |
|                    |____||_| |_| |_|/ /    \ \|____|                 |
|                                                                      |
|                             ca-mgm library                           |
|                                                                      |
|                                         (C) SUSE Linux Products GmbH |
\----------------------------------------------------------------------/

  File:       RequestGenerationData.cpp

  Author:     <<NAME>>     <<EMAIL>>
  Maintainer: <<NAME>>     <<EMAIL>>

  Purpose:

/-*/


#include  <limal/ca-mgm/RequestGenerationData.hpp>
#include  <limal/ca-mgm/CA.hpp>
#include  <limal/Exception.hpp>
#include  <blocxx/Format.hpp>

#include  "Utils.hpp"

using namespace limal;
using namespace limal::ca_mgm;
using namespace blocxx;


RequestGenerationData::RequestGenerationData()
    : subject(DNObject()),
      keysize(0),
      messageDigest(SHA1),
      challengePassword(""),
      unstructuredName(""),
      extensions(X509v3RequestExtensions())
{
}

RequestGenerationData::RequestGenerationData(CAConfig* caConfig, Type type)
    : subject(DNObject()),
      keysize(0),
      messageDigest(SHA1),
      challengePassword(""),
      unstructuredName(""),
      extensions(X509v3RequestExtensions(caConfig, type))
{
    keysize = caConfig->getValue(type2Section(type, false), "default_bits").toUInt32();

    String md = caConfig->getValue(type2Section(type, false), "default_md");
    if(md.equalsIgnoreCase("sha1")) {
        messageDigest = SHA1;
    } else if(md.equalsIgnoreCase("md5")) {
        messageDigest = MD5;
    } else if(md.equalsIgnoreCase("mdc2")) {
        messageDigest = MDC2;
    } else {
        LOGIT_INFO("unsupported message digest: " << md);
        LOGIT_INFO("select default sha1.");
        messageDigest = SHA1;
    }
}

RequestGenerationData::RequestGenerationData(const RequestGenerationData& data)
    : subject(data.subject),
      keysize(data.keysize),
      messageDigest(data.messageDigest),
      challengePassword(data.challengePassword),
      unstructuredName(data.unstructuredName),
      extensions(data.extensions)<commit_msg>use new constructor for DN parsing<commit_after>/*---------------------------------------------------------------------\
|                                                                      |
|                     _     _   _   _     __     _                     |
|                    | |   | | | \_/ |   /  \   | |                    |
|                    | |   | | | |_| |  / /\ \  | |                    |
|                    | |__ | | | | | | / ____ \ | |__                  |
|                    |____||_| |_| |_|/ /    \ \|____|                 |
|                                                                      |
|                             ca-mgm library                           |
|                                                                      |
|                                         (C) SUSE Linux Products GmbH |
\----------------------------------------------------------------------/

  File:       RequestGenerationData.cpp

  Author:     <<NAME>>     <<EMAIL>>
  Maintainer: <<NAME>>     <<EMAIL>>

  Purpose:

/-*/


#include  <limal/ca-mgm/RequestGenerationData.hpp>
#include  <limal/ca-mgm/CA.hpp>
#include  <limal/Exception.hpp>
#include  <blocxx/Format.hpp>

#include  "Utils.hpp"

using namespace limal;
using namespace limal::ca_mgm;
using namespace blocxx;


RequestGenerationData::RequestGenerationData()
    : subject(DNObject()),
      keysize(0),
      messageDigest(SHA1),
      challengePassword(""),
      unstructuredName(""),
      extensions(X509v3RequestExtensions())
{
}

RequestGenerationData::RequestGenerationData(CAConfig* caConfig, Type type)
    : subject(DNObject(caConfig, type)),
      keysize(0),
      messageDigest(SHA1),
      challengePassword(""),
      unstructuredName(""),
      extensions(X509v3RequestExtensions(caConfig, type))
{
    keysize = caConfig->getValue(type2Section(type, false), "default_bits").toUInt32();

    String md = caConfig->getValue(type2Section(type, false), "default_md");
    if(md.equalsIgnoreCase("sha1")) {
        messageDigest = SHA1;
    } else if(md.equalsIgnoreCase("md5")) {
        messageDigest = MD5;
    } else if(md.equalsIgnoreCase("mdc2")) {
        messageDigest = MDC2;
    } else {
        LOGIT_INFO("unsupported message digest: " << md);
        LOGIT_INFO("select default sha1.");
        messageDigest = SHA1;
    }
}

RequestGenerationData::RequestGenerationData(const RequestGenerationData& data)
    : subject(data.subject),
      keysize(data.keysize),
      messageDigest(data.messageDigest),
      challengePassword(data.challengePassword),
      unstructuredName(data.unstructuredName),
      extensions(data.extensions)
{'fraction_non_alphanumeric': 0.17219170297404812, 'fraction_numerical': 0.009092631180147755, 'mean_word_length': 1.3645320197044335, 'pattern_counts': {'":': 0, '<': 31, '<?xml version=': 0, '>': 31, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 26, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4797579', 'n_tokens_mistral': 1429, 'n_tokens_neox': 1361, 'n_words': 191}