Loading README.md +3 −1 Original line number Diff line number Diff line Loading @@ -132,7 +132,9 @@ $ vi ../../etc/AtsCise/AtsCise.cfg # To update it The paramaters to be updated are: - PICS_CISE_SECURITY - PICS_CISE_CERTIFICATES_DB_PATH - PX_SECURITY_SIGN_CERT - PICS_CISE_TS_CERTIFICATE - PICS_CISE_TS_SIGNING_PRIVATE_KEY - PICS_CISE_TS_SIGNING_PRIVATE_PASSWD - PICS_HEADER_HOST - system.httpPort.params - system.httpPort_notif.params Loading ccsrc/Protocols/Http/http_codec_cise.cc +25 −3 Original line number Diff line number Diff line Loading @@ -25,17 +25,39 @@ bool http_codec_cise::encode_body_xml(const LibHttp__XmlMessageBodyTypes::XmlBod } bool http_codec_cise::decode_body_xml(const OCTETSTRING &p_data, LibHttp__XmlMessageBodyTypes::XmlBody &p_body, const std::string& p_content_type, params* p_params) { loggers::get_instance().log(">>> http_codec_cise::decode_body_xml"); loggers::get_instance().log_msg(">>> http_codec_cise::decode_body_xml: ", p_body); if (_codecs["xml"].get() != nullptr) { p_body.raw().set_to_omit(); loggers::get_instance().log("http_codec_cise::decode_body: Call 'xml_codec'"); if (_codecs["xml"]->decode(p_data, (Record_Type&)p_body, p_params) == -1) { loggers::get_instance().warning("http_codec_cise::decode_body: Failed to decode JSON message"); p_body.raw() = CHARSTRING(p_data.lengthof(), (char*)static_cast<const unsigned char*>(p_data)); p_body.raw() = oct2char(p_data); } else { loggers::get_instance().log_msg("http_codec_cise::decode_body: Decoded message:", p_body); loggers::get_instance().log_msg("http_codec_cise::decode_body: Decoded message:", p_body.msg()); p_body.raw() = oct2char(p_data); } } return true; } bool http_codec_cise::decode_body_json(const OCTETSTRING &p_data, LibHttp__JsonMessageBodyTypes::JsonBody &p_json_body, const std::string& p_content_type, params* p_params) { loggers::get_instance().log(">>> http_codec_cise::decode_body_json: content: %s", p_content_type.c_str()); loggers::get_instance().log_msg(">>> http_codec_cise::decode_body_json: data: ", p_data); if (_codecs["json"].get() != nullptr) { loggers::get_instance().log("http_codec_cise::decode_body_json: Call 'json_codec'"); if (_codecs["json"]->decode(p_data, (Record_Type&)p_json_body, p_params) == -1) { loggers::get_instance().warning("http_codec_cise::decode_body_json: Failed to decode JSON message"); p_json_body.raw() = CHARSTRING(p_data.lengthof(), (char*)static_cast<const unsigned char*>(p_data)); } else { loggers::get_instance().log_msg("http_codec_cise::decode_body_json: Decoded message:", p_json_body); } } else { loggers::get_instance().error("http_codec_cise::decode_body_json: Codec not found"); return false; } return true; } ccsrc/Protocols/Http/http_codec_cise.hh +2 −0 Original line number Diff line number Diff line Loading @@ -13,4 +13,6 @@ public: protected: //! \protectedsection bool encode_body_xml(const LibHttp__XmlMessageBodyTypes::XmlBody &p_xml_body, OCTETSTRING &p_encoding_buffer, const std::string& p_content_type); bool decode_body_xml(const OCTETSTRING &p_data, LibHttp__XmlMessageBodyTypes::XmlBody &p_body, const std::string& p_content_type, params* p_params); bool decode_body_json(const OCTETSTRING &p_data, LibHttp__JsonMessageBodyTypes::JsonBody &p_json_body, const std::string& p_content_type, params* p_params); }; No newline at end of file ccsrc/Protocols/Xml/xml_codec.cc +56 −45 Original line number Diff line number Diff line Loading @@ -9,23 +9,28 @@ #include "LibHttp_XmlMessageBodyTypes.hh" int xml_codec::encode(const LibHttp__XmlMessageBodyTypes::XmlBody& msg, OCTETSTRING& data) int xml_codec::encode(const LibHttp__XmlMessageBodyTypes::XmlBody& body, OCTETSTRING& data) { loggers::get_instance().log_msg(">>> xml_codec::encode: ", (const Base_Type&)msg); loggers::get_instance().log_msg(">>> xml_codec::encode: ", (const Base_Type&)body); if (body.raw().is_present() && body.raw().is_bound()) { const CHARSTRING& v = static_cast<const CHARSTRING&>(*body.raw().get_opt_value()); data = char2oct(v); } else { TTCN_EncDec::clear_error(); TTCN_EncDec::set_error_behavior(TTCN_EncDec::ET_ALL, TTCN_EncDec::EB_DEFAULT); TTCN_Buffer encoding_buffer; if (msg.ischosen(LibHttp__XmlMessageBodyTypes::XmlBody::ALT_pull__request)) { const LibHttp__XmlMessageBodyTypes::XmlBodyMsg& msg = body.msg(); if (msg.ischosen(LibHttp__XmlMessageBodyTypes::XmlBodyMsg::ALT_pull__request)) { const http__www__cise__eu__servicemodel__v1__message::PullRequest& pull_request = msg.pull__request(); loggers::get_instance().log_msg("xml_codec::encode: Process PullRequest: ", (const Base_Type&)pull_request); pull_request.encode(http__www__cise__eu__servicemodel__v1__message::PullRequest_descr_, encoding_buffer, TTCN_EncDec::CT_XER, XER_EXTENDED); } else if (msg.ischosen(LibHttp__XmlMessageBodyTypes::XmlBody::ALT_pull__response)) { } else if (msg.ischosen(LibHttp__XmlMessageBodyTypes::XmlBodyMsg::ALT_pull__response)) { const http__www__cise__eu__servicemodel__v1__message::PullResponse& pull_response = msg.pull__response(); loggers::get_instance().log_msg("xml_codec::encode: Process PullResponse: ", (const Base_Type&)pull_response); pull_response.encode(http__www__cise__eu__servicemodel__v1__message::PullResponse_descr_, encoding_buffer, TTCN_EncDec::CT_XER, XER_EXTENDED); } else if (msg.ischosen(LibHttp__XmlMessageBodyTypes::XmlBody::ALT_raw)) { } else if (msg.ischosen(LibHttp__XmlMessageBodyTypes::XmlBodyMsg::ALT_raw)) { data = char2oct(msg.raw()); loggers::get_instance().log_msg("xml_codec::encode: Process Raw: ", data); return 0; Loading Loading @@ -59,6 +64,7 @@ int xml_codec::encode(const LibHttp__XmlMessageBodyTypes::XmlBody& msg, OCTETSTR // Add header CHARSTRING h("<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"no\" ?>\n"); data = char2oct(h) + data; } loggers::get_instance().log_msg("xml_codec::encode: After encoding: ", data); Loading @@ -66,7 +72,7 @@ int xml_codec::encode(const LibHttp__XmlMessageBodyTypes::XmlBody& msg, OCTETSTR return 0; } int xml_codec::decode (const OCTETSTRING& p_data, LibHttp__XmlMessageBodyTypes::XmlBody& msg, params* p_params) int xml_codec::decode (const OCTETSTRING& p_data, LibHttp__XmlMessageBodyTypes::XmlBody& body, params* p_params) { loggers::get_instance().log_msg(">>> xml_codec::decode: p_data=", p_data); Loading @@ -84,6 +90,9 @@ int xml_codec::decode (const OCTETSTRING& p_data, LibHttp__XmlMessageBodyTypes:: loggers::get_instance().log("xml_codec::decode: it->second='%s'", it->second.c_str()); } loggers::get_instance().log_msg("body: ", body); LibHttp__XmlMessageBodyTypes::XmlBodyMsg& msg = body.msg(); body.raw() = OPTIONAL<CHARSTRING>(CHARSTRING(it->second.c_str())); TTCN_EncDec::set_error_behavior(TTCN_EncDec::ET_ALL, TTCN_EncDec::EB_DEFAULT); TTCN_EncDec::clear_error(); TTCN_Buffer decoding_buffer(OCTETSTRING(it->second.length(), (const unsigned char*)it->second.c_str())); Loading @@ -91,6 +100,7 @@ int xml_codec::decode (const OCTETSTRING& p_data, LibHttp__XmlMessageBodyTypes:: if ((it->second.find("<PullRequest") != std::string::npos) || (it->second.find(":PullRequest") != std::string::npos)) { http__www__cise__eu__servicemodel__v1__message::PullRequest pull_request; pull_request.decode(http__www__cise__eu__servicemodel__v1__message::PullRequest_descr_, decoding_buffer, TTCN_EncDec::CT_XER, XER_EXTENDED); loggers::get_instance().log_msg("2222222222222222222222222222222222222222222222222222: ", pull_request); msg.pull__request() = pull_request; } else if ((it->second.find("<PullResponse") != std::string::npos) || (it->second.find(":PullResponse") != std::string::npos)) { http__www__cise__eu__servicemodel__v1__message::PullResponse pull_response; Loading @@ -100,6 +110,7 @@ int xml_codec::decode (const OCTETSTRING& p_data, LibHttp__XmlMessageBodyTypes:: loggers::get_instance().warning("xml_codec::decode: Unsupported variant"); return -1; } loggers::get_instance().log("3333333333333333333333333333333333333333333333333333"); loggers::get_instance().log_msg("<<< xml_codec::decode: ", (const Base_Type&)msg); return 0; Loading ccsrc/externals/cise_externals.cc +2 −1 Original line number Diff line number Diff line Loading @@ -76,7 +76,8 @@ namespace LibCise__Functions { loggers::get_instance().log(">>> fx__enc__PullRequest__1"); LibHttp__XmlMessageBodyTypes::XmlBody msg; msg.pull__request() = p; msg.msg().pull__request() = p; msg.raw().set_to_omit(); xml_codec c; OCTETSTRING os; int result = c.encode(msg, os); Loading Loading
README.md +3 −1 Original line number Diff line number Diff line Loading @@ -132,7 +132,9 @@ $ vi ../../etc/AtsCise/AtsCise.cfg # To update it The paramaters to be updated are: - PICS_CISE_SECURITY - PICS_CISE_CERTIFICATES_DB_PATH - PX_SECURITY_SIGN_CERT - PICS_CISE_TS_CERTIFICATE - PICS_CISE_TS_SIGNING_PRIVATE_KEY - PICS_CISE_TS_SIGNING_PRIVATE_PASSWD - PICS_HEADER_HOST - system.httpPort.params - system.httpPort_notif.params Loading
ccsrc/Protocols/Http/http_codec_cise.cc +25 −3 Original line number Diff line number Diff line Loading @@ -25,17 +25,39 @@ bool http_codec_cise::encode_body_xml(const LibHttp__XmlMessageBodyTypes::XmlBod } bool http_codec_cise::decode_body_xml(const OCTETSTRING &p_data, LibHttp__XmlMessageBodyTypes::XmlBody &p_body, const std::string& p_content_type, params* p_params) { loggers::get_instance().log(">>> http_codec_cise::decode_body_xml"); loggers::get_instance().log_msg(">>> http_codec_cise::decode_body_xml: ", p_body); if (_codecs["xml"].get() != nullptr) { p_body.raw().set_to_omit(); loggers::get_instance().log("http_codec_cise::decode_body: Call 'xml_codec'"); if (_codecs["xml"]->decode(p_data, (Record_Type&)p_body, p_params) == -1) { loggers::get_instance().warning("http_codec_cise::decode_body: Failed to decode JSON message"); p_body.raw() = CHARSTRING(p_data.lengthof(), (char*)static_cast<const unsigned char*>(p_data)); p_body.raw() = oct2char(p_data); } else { loggers::get_instance().log_msg("http_codec_cise::decode_body: Decoded message:", p_body); loggers::get_instance().log_msg("http_codec_cise::decode_body: Decoded message:", p_body.msg()); p_body.raw() = oct2char(p_data); } } return true; } bool http_codec_cise::decode_body_json(const OCTETSTRING &p_data, LibHttp__JsonMessageBodyTypes::JsonBody &p_json_body, const std::string& p_content_type, params* p_params) { loggers::get_instance().log(">>> http_codec_cise::decode_body_json: content: %s", p_content_type.c_str()); loggers::get_instance().log_msg(">>> http_codec_cise::decode_body_json: data: ", p_data); if (_codecs["json"].get() != nullptr) { loggers::get_instance().log("http_codec_cise::decode_body_json: Call 'json_codec'"); if (_codecs["json"]->decode(p_data, (Record_Type&)p_json_body, p_params) == -1) { loggers::get_instance().warning("http_codec_cise::decode_body_json: Failed to decode JSON message"); p_json_body.raw() = CHARSTRING(p_data.lengthof(), (char*)static_cast<const unsigned char*>(p_data)); } else { loggers::get_instance().log_msg("http_codec_cise::decode_body_json: Decoded message:", p_json_body); } } else { loggers::get_instance().error("http_codec_cise::decode_body_json: Codec not found"); return false; } return true; }
ccsrc/Protocols/Http/http_codec_cise.hh +2 −0 Original line number Diff line number Diff line Loading @@ -13,4 +13,6 @@ public: protected: //! \protectedsection bool encode_body_xml(const LibHttp__XmlMessageBodyTypes::XmlBody &p_xml_body, OCTETSTRING &p_encoding_buffer, const std::string& p_content_type); bool decode_body_xml(const OCTETSTRING &p_data, LibHttp__XmlMessageBodyTypes::XmlBody &p_body, const std::string& p_content_type, params* p_params); bool decode_body_json(const OCTETSTRING &p_data, LibHttp__JsonMessageBodyTypes::JsonBody &p_json_body, const std::string& p_content_type, params* p_params); }; No newline at end of file
ccsrc/Protocols/Xml/xml_codec.cc +56 −45 Original line number Diff line number Diff line Loading @@ -9,23 +9,28 @@ #include "LibHttp_XmlMessageBodyTypes.hh" int xml_codec::encode(const LibHttp__XmlMessageBodyTypes::XmlBody& msg, OCTETSTRING& data) int xml_codec::encode(const LibHttp__XmlMessageBodyTypes::XmlBody& body, OCTETSTRING& data) { loggers::get_instance().log_msg(">>> xml_codec::encode: ", (const Base_Type&)msg); loggers::get_instance().log_msg(">>> xml_codec::encode: ", (const Base_Type&)body); if (body.raw().is_present() && body.raw().is_bound()) { const CHARSTRING& v = static_cast<const CHARSTRING&>(*body.raw().get_opt_value()); data = char2oct(v); } else { TTCN_EncDec::clear_error(); TTCN_EncDec::set_error_behavior(TTCN_EncDec::ET_ALL, TTCN_EncDec::EB_DEFAULT); TTCN_Buffer encoding_buffer; if (msg.ischosen(LibHttp__XmlMessageBodyTypes::XmlBody::ALT_pull__request)) { const LibHttp__XmlMessageBodyTypes::XmlBodyMsg& msg = body.msg(); if (msg.ischosen(LibHttp__XmlMessageBodyTypes::XmlBodyMsg::ALT_pull__request)) { const http__www__cise__eu__servicemodel__v1__message::PullRequest& pull_request = msg.pull__request(); loggers::get_instance().log_msg("xml_codec::encode: Process PullRequest: ", (const Base_Type&)pull_request); pull_request.encode(http__www__cise__eu__servicemodel__v1__message::PullRequest_descr_, encoding_buffer, TTCN_EncDec::CT_XER, XER_EXTENDED); } else if (msg.ischosen(LibHttp__XmlMessageBodyTypes::XmlBody::ALT_pull__response)) { } else if (msg.ischosen(LibHttp__XmlMessageBodyTypes::XmlBodyMsg::ALT_pull__response)) { const http__www__cise__eu__servicemodel__v1__message::PullResponse& pull_response = msg.pull__response(); loggers::get_instance().log_msg("xml_codec::encode: Process PullResponse: ", (const Base_Type&)pull_response); pull_response.encode(http__www__cise__eu__servicemodel__v1__message::PullResponse_descr_, encoding_buffer, TTCN_EncDec::CT_XER, XER_EXTENDED); } else if (msg.ischosen(LibHttp__XmlMessageBodyTypes::XmlBody::ALT_raw)) { } else if (msg.ischosen(LibHttp__XmlMessageBodyTypes::XmlBodyMsg::ALT_raw)) { data = char2oct(msg.raw()); loggers::get_instance().log_msg("xml_codec::encode: Process Raw: ", data); return 0; Loading Loading @@ -59,6 +64,7 @@ int xml_codec::encode(const LibHttp__XmlMessageBodyTypes::XmlBody& msg, OCTETSTR // Add header CHARSTRING h("<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"no\" ?>\n"); data = char2oct(h) + data; } loggers::get_instance().log_msg("xml_codec::encode: After encoding: ", data); Loading @@ -66,7 +72,7 @@ int xml_codec::encode(const LibHttp__XmlMessageBodyTypes::XmlBody& msg, OCTETSTR return 0; } int xml_codec::decode (const OCTETSTRING& p_data, LibHttp__XmlMessageBodyTypes::XmlBody& msg, params* p_params) int xml_codec::decode (const OCTETSTRING& p_data, LibHttp__XmlMessageBodyTypes::XmlBody& body, params* p_params) { loggers::get_instance().log_msg(">>> xml_codec::decode: p_data=", p_data); Loading @@ -84,6 +90,9 @@ int xml_codec::decode (const OCTETSTRING& p_data, LibHttp__XmlMessageBodyTypes:: loggers::get_instance().log("xml_codec::decode: it->second='%s'", it->second.c_str()); } loggers::get_instance().log_msg("body: ", body); LibHttp__XmlMessageBodyTypes::XmlBodyMsg& msg = body.msg(); body.raw() = OPTIONAL<CHARSTRING>(CHARSTRING(it->second.c_str())); TTCN_EncDec::set_error_behavior(TTCN_EncDec::ET_ALL, TTCN_EncDec::EB_DEFAULT); TTCN_EncDec::clear_error(); TTCN_Buffer decoding_buffer(OCTETSTRING(it->second.length(), (const unsigned char*)it->second.c_str())); Loading @@ -91,6 +100,7 @@ int xml_codec::decode (const OCTETSTRING& p_data, LibHttp__XmlMessageBodyTypes:: if ((it->second.find("<PullRequest") != std::string::npos) || (it->second.find(":PullRequest") != std::string::npos)) { http__www__cise__eu__servicemodel__v1__message::PullRequest pull_request; pull_request.decode(http__www__cise__eu__servicemodel__v1__message::PullRequest_descr_, decoding_buffer, TTCN_EncDec::CT_XER, XER_EXTENDED); loggers::get_instance().log_msg("2222222222222222222222222222222222222222222222222222: ", pull_request); msg.pull__request() = pull_request; } else if ((it->second.find("<PullResponse") != std::string::npos) || (it->second.find(":PullResponse") != std::string::npos)) { http__www__cise__eu__servicemodel__v1__message::PullResponse pull_response; Loading @@ -100,6 +110,7 @@ int xml_codec::decode (const OCTETSTRING& p_data, LibHttp__XmlMessageBodyTypes:: loggers::get_instance().warning("xml_codec::decode: Unsupported variant"); return -1; } loggers::get_instance().log("3333333333333333333333333333333333333333333333333333"); loggers::get_instance().log_msg("<<< xml_codec::decode: ", (const Base_Type&)msg); return 0; Loading
ccsrc/externals/cise_externals.cc +2 −1 Original line number Diff line number Diff line Loading @@ -76,7 +76,8 @@ namespace LibCise__Functions { loggers::get_instance().log(">>> fx__enc__PullRequest__1"); LibHttp__XmlMessageBodyTypes::XmlBody msg; msg.pull__request() = p; msg.msg().pull__request() = p; msg.raw().set_to_omit(); xml_codec c; OCTETSTRING os; int result = c.encode(msg, os); Loading