Commit f69933a7 authored by Yann Garcia's avatar Yann Garcia
Browse files

STF 637: Workaroud on XML transform. To be enhanced using libxslt-dev - see opened issues

parent e27aaa84
Loading
Loading
Loading
Loading
+53 −3
Original line number Diff line number Diff line
@@ -76,9 +76,59 @@ int xml_converters::xml_transform(const std::string& p_to_transform, std::string

  // <Payload xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:type="XmlEntityPayload">
  first = p_transformed.find("<Payload ");
  int l = 9;
  if ((first != -1) && (first < p_to_transform.length())) {
    next = p_transformed.find("\">", first + 8 + 1);
    p_transformed = p_transformed.substr(0, first + 8) + p_transformed.substr(next + 1,  p_transformed.length() - next - 1);
    next = p_transformed.find("\">", first + l + 1);
    loggers::get_instance().log("xml_converters::xml_transform: New p_transformed (3): '%s'", p_transformed.c_str());
    p_transformed = p_transformed.substr(0, first + l) + p_transformed.substr(next + 1,  p_transformed.length() - next - 1);
  }
  // <Agent xsi:type="ns6:Organization" xmlns:ns6="http://www.cise.eu/datamodel/v1/entity/organization/">
  first = p_transformed.find("<Agent ");
  l = 7;
  if ((first != -1) && (first < p_to_transform.length())) {
    next = p_transformed.find("\">", first + l + 1);
    loggers::get_instance().log("xml_converters::xml_transform: New p_transformed (4): '%s'", p_transformed.c_str());
    p_transformed = p_transformed.substr(0, first + l) + p_transformed.substr(next + 1,  p_transformed.length() - next - 1);
  }
  // <Location xsi:type=...">
  first = p_transformed.find("<Location ");
  l = 10;
  if ((first != -1) && (first < p_to_transform.length())) {
    next = p_transformed.find("\">", first + l + 1);
    loggers::get_instance().log("xml_converters::xml_transform: New p_transformed (5): '%s'", p_transformed.c_str());
    p_transformed = p_transformed.substr(0, first + l) + p_transformed.substr(next + 1,  p_transformed.length() - next - 1);
  }
  // <Object xsi:type=...">
  first = p_transformed.find("<Object ");
  l = 8;
  if ((first != -1) && (first < p_to_transform.length())) {
    next = p_transformed.find("\">", first + l + 1);
    loggers::get_instance().log("xml_converters::xml_transform: New p_transformed (6): '%s'", p_transformed.c_str());
    p_transformed = p_transformed.substr(0, first + l) + p_transformed.substr(next + 1,  p_transformed.length() - next - 1);
  }
  // <Event xsi:type=...">
  first = p_transformed.find("<Event ");
  l = 7;
  if ((first != -1) && (first < p_to_transform.length())) {
    next = p_transformed.find("\">", first + l + 1);
    loggers::get_instance().log("xml_converters::xml_transform: New p_transformed (7): '%s'", p_transformed.c_str());
    p_transformed = p_transformed.substr(0, first + l) + p_transformed.substr(next + 1,  p_transformed.length() - next - 1);
  }
  // <Document xsi:type=...">
  first = p_transformed.find("<Document ");
  l = 10;
  if ((first != -1) && (first < p_to_transform.length())) {
    next = p_transformed.find("\">", first + l + 1);
    loggers::get_instance().log("xml_converters::xml_transform: New p_transformed (8): '%s'", p_transformed.c_str());
    p_transformed = p_transformed.substr(0, first + l) + p_transformed.substr(next + 1,  p_transformed.length() - next - 1);
  }
  // <Document xsi:type=...">
  first = p_transformed.find("<Requests ");
  l = 10;
  if ((first != -1) && (first < p_to_transform.length())) {
    next = p_transformed.find("\">", first + l + 1);
    loggers::get_instance().log("xml_converters::xml_transform: New p_transformed (8): '%s'", p_transformed.c_str());
    p_transformed = p_transformed.substr(0, first + l) + p_transformed.substr(next + 1,  p_transformed.length() - next - 1);
  }
  
  loggers::get_instance().log("<<< xml_converters::xml_transform: '%s'", p_transformed.c_str());
+2 −1
Original line number Diff line number Diff line
@@ -50,10 +50,11 @@ int security_services::do_sign(const OCTETSTRING& p_encoded_message, const OCTET
  // Transform: Remove all CR, LS, TAB and SPACE outside of the tags
  std::string transformed;
  xml_converters::get_instance().xml_transform(std::string((const char*)(static_cast<const unsigned char*>(p_encoded_message)), p_encoded_message.lengthof()), transformed);
  loggers::get_instance().log("security_services::do_sign: p_pull_request_transormed: ", transformed.c_str());
  loggers::get_instance().log("security_services::do_sign: p_pull_request_transormed: '%s'", transformed.c_str());
  // Canonicalization
  std::string canonicalized;
  xml_converters::get_instance().xml_canonicalization(transformed, canonicalized);
  loggers::get_instance().log("security_services::do_sign: canonicalized: '%s'", canonicalized.c_str());
  p_pull_request_canonicalized = CHARSTRING(canonicalized.c_str());
  OCTETSTRING encoded_message(char2oct(p_pull_request_canonicalized));
  loggers::get_instance().log_msg("security_services::do_sign: p_pull_request_canonicalized: ", p_pull_request_canonicalized);
+14 −9
Original line number Diff line number Diff line
@@ -179,6 +179,11 @@ module LibHelpers_Functions {
         */
        external function fx_generate_uuid() return charstring;

        /**
         * @brief Retrieve the current local date/time formatted as yyyy-mm-ddThh:mm:ss.lll+nn:00
         * @param p_shift_time The algebric number of seconds to add to the current time
         * @return The the current date/time on success, a null string otherwise 
         */
        external function fx_get_current_date_time(in integer p_shift_time) return charstring;

    } // End of externals
+4 −4

File changed.

Contains only whitespace changes.