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

Review Pki Test System

parent 64aed2df
......@@ -5,7 +5,11 @@
<MakefileSettings>
<functiontestRuntime>true</functiontestRuntime>
<targetExecutable>bin/TSITS</targetExecutable>
<TTCN3preprocessorDefines>
<listItem>_NO_SOFTLINKS_</listItem>
</TTCN3preprocessorDefines>
<preprocessorDefines>
<listItem>_NO_SOFTLINKS_</listItem>
<listItem>_USE_MATH_DEFINES</listItem>
<listItem>ASN_DISABLE_OER_SUPPORT</listItem>
<listItem>OSTYPE=cygwin</listItem>
......@@ -44,6 +48,27 @@
</LocalBuildSettings>
</ProjectProperties>
<FolderProperties>
<FolderResource>
<FolderPath>ccsrc/Ports/LibIts_ports/DCC_ports</FolderPath>
<FolderProperties>
<CentralStorage>false</CentralStorage>
<ExcludeFromBuild>true</ExcludeFromBuild>
</FolderProperties>
</FolderResource>
<FolderResource>
<FolderPath>ccsrc/Ports/LibIts_ports/EVCSN_ports</FolderPath>
<FolderProperties>
<CentralStorage>false</CentralStorage>
<ExcludeFromBuild>true</ExcludeFromBuild>
</FolderProperties>
</FolderResource>
<FolderResource>
<FolderPath>ccsrc/Ports/LibIts_ports/V2G_ports</FolderPath>
<FolderProperties>
<CentralStorage>false</CentralStorage>
<ExcludeFromBuild>true</ExcludeFromBuild>
</FolderProperties>
</FolderResource>
<FolderResource>
<FolderPath>data</FolderPath>
<FolderProperties>
......@@ -51,13 +76,266 @@
<ExcludeFromBuild>true</ExcludeFromBuild>
</FolderProperties>
</FolderResource>
<FolderResource>
<FolderPath>javasrc</FolderPath>
<FolderProperties>
<CentralStorage>false</CentralStorage>
<ExcludeFromBuild>true</ExcludeFromBuild>
</FolderProperties>
</FolderResource>
<FolderResource>
<FolderPath>patches</FolderPath>
<FolderProperties>
<CentralStorage>false</CentralStorage>
<ExcludeFromBuild>true</ExcludeFromBuild>
</FolderProperties>
</FolderResource>
<FolderResource>
<FolderPath>requality</FolderPath>
<FolderProperties>
<CentralStorage>false</CentralStorage>
<ExcludeFromBuild>true</ExcludeFromBuild>
</FolderProperties>
</FolderResource>
<FolderResource>
<FolderPath>tools</FolderPath>
<FolderProperties>
<CentralStorage>false</CentralStorage>
<ExcludeFromBuild>true</ExcludeFromBuild>
</FolderProperties>
</FolderResource>
<FolderResource>
<FolderPath>tt3plugins</FolderPath>
<FolderProperties>
<CentralStorage>false</CentralStorage>
<ExcludeFromBuild>true</ExcludeFromBuild>
</FolderProperties>
</FolderResource>
<FolderResource>
<FolderPath>ttcn/AtsATSP</FolderPath>
<FolderProperties>
<CentralStorage>false</CentralStorage>
<ExcludeFromBuild>true</ExcludeFromBuild>
</FolderProperties>
</FolderResource>
<FolderResource>
<FolderPath>ttcn/AtsBTP</FolderPath>
<FolderProperties>
<CentralStorage>false</CentralStorage>
<ExcludeFromBuild>true</ExcludeFromBuild>
</FolderProperties>
</FolderResource>
<FolderResource>
<FolderPath>ttcn/AtsDCC</FolderPath>
<FolderProperties>
<CentralStorage>false</CentralStorage>
<ExcludeFromBuild>true</ExcludeFromBuild>
</FolderProperties>
</FolderResource>
<FolderResource>
<FolderPath>ttcn/AtsFNTP</FolderPath>
<FolderProperties>
<CentralStorage>false</CentralStorage>
<ExcludeFromBuild>true</ExcludeFromBuild>
</FolderProperties>
</FolderResource>
<FolderResource>
<FolderPath>ttcn/AtsFSAP</FolderPath>
<FolderProperties>
<CentralStorage>false</CentralStorage>
<ExcludeFromBuild>true</ExcludeFromBuild>
</FolderProperties>
</FolderResource>
<FolderResource>
<FolderPath>ttcn/AtsIICP</FolderPath>
<FolderProperties>
<CentralStorage>false</CentralStorage>
<ExcludeFromBuild>true</ExcludeFromBuild>
</FolderProperties>
</FolderResource>
<FolderResource>
<FolderPath>ttcn/AtsIPv6OverGeoNetworking</FolderPath>
<FolderProperties>
<CentralStorage>false</CentralStorage>
<ExcludeFromBuild>true</ExcludeFromBuild>
</FolderProperties>
</FolderResource>
<FolderResource>
<FolderPath>ttcn/AtsV2G</FolderPath>
<FolderProperties>
<CentralStorage>false</CentralStorage>
<ExcludeFromBuild>true</ExcludeFromBuild>
</FolderProperties>
</FolderResource>
<FolderResource>
<FolderPath>ttcn/LibIts/asn1/CALMfntp</FolderPath>
<FolderProperties>
<CentralStorage>false</CentralStorage>
<ExcludeFromBuild>true</ExcludeFromBuild>
</FolderProperties>
</FolderResource>
<FolderResource>
<FolderPath>ttcn/LibIts/asn1/CALMfsap</FolderPath>
<FolderProperties>
<CentralStorage>false</CentralStorage>
<ExcludeFromBuild>true</ExcludeFromBuild>
</FolderProperties>
</FolderResource>
<FolderResource>
<FolderPath>ttcn/LibIts/asn1/CALMiitsscu</FolderPath>
<FolderProperties>
<CentralStorage>false</CentralStorage>
<ExcludeFromBuild>true</ExcludeFromBuild>
</FolderProperties>
</FolderResource>
<FolderResource>
<FolderPath>ttcn/LibIts/asn1/CALMipv6</FolderPath>
<FolderProperties>
<CentralStorage>false</CentralStorage>
<ExcludeFromBuild>true</ExcludeFromBuild>
</FolderProperties>
</FolderResource>
<FolderResource>
<FolderPath>ttcn/LibIts/asn1/CALMllsap</FolderPath>
<FolderProperties>
<CentralStorage>false</CentralStorage>
<ExcludeFromBuild>true</ExcludeFromBuild>
</FolderProperties>
</FolderResource>
<FolderResource>
<FolderPath>ttcn/LibIts/asn1/CALMmanagement</FolderPath>
<FolderProperties>
<CentralStorage>false</CentralStorage>
<ExcludeFromBuild>true</ExcludeFromBuild>
</FolderProperties>
</FolderResource>
<FolderResource>
<FolderPath>ttcn/LibIts/asn1/CALMmsap</FolderPath>
<FolderProperties>
<CentralStorage>false</CentralStorage>
<ExcludeFromBuild>true</ExcludeFromBuild>
</FolderProperties>
</FolderResource>
<FolderResource>
<FolderPath>ttcn/LibIts/asn1/CITSapplMgmt</FolderPath>
<FolderProperties>
<CentralStorage>false</CentralStorage>
<ExcludeFromBuild>true</ExcludeFromBuild>
</FolderProperties>
</FolderResource>
<FolderResource>
<FolderPath>ttcn/LibIts/asn1/CITSapplReq</FolderPath>
<FolderProperties>
<CentralStorage>false</CentralStorage>
<ExcludeFromBuild>true</ExcludeFromBuild>
</FolderProperties>
</FolderResource>
<FolderResource>
<FolderPath>ttcn/LibIts/asn1/DSRCData</FolderPath>
<FolderProperties>
<CentralStorage>false</CentralStorage>
<ExcludeFromBuild>true</ExcludeFromBuild>
</FolderProperties>
</FolderResource>
<FolderResource>
<FolderPath>ttcn/LibIts/asn1/IS/ISO_TS_19091/original</FolderPath>
<FolderProperties>
<CentralStorage>false</CentralStorage>
<ExcludeFromBuild>true</ExcludeFromBuild>
</FolderProperties>
</FolderResource>
<FolderResource>
<FolderPath>ttcn/LibIts/asn1/ProtocolManagementInformation</FolderPath>
<FolderProperties>
<CentralStorage>false</CentralStorage>
<ExcludeFromBuild>true</ExcludeFromBuild>
</FolderProperties>
</FolderResource>
<FolderResource>
<FolderPath>ttcn/LibIts/asn1/TransportAddressMib</FolderPath>
<FolderProperties>
<CentralStorage>false</CentralStorage>
<ExcludeFromBuild>true</ExcludeFromBuild>
</FolderProperties>
</FolderResource>
<FolderResource>
<FolderPath>ttcn/LibIts/ttcn/CALM</FolderPath>
<FolderProperties>
<CentralStorage>false</CentralStorage>
<ExcludeFromBuild>true</ExcludeFromBuild>
</FolderProperties>
</FolderResource>
<FolderResource>
<FolderPath>ttcn/LibIts/ttcn/DCC</FolderPath>
<FolderProperties>
<CentralStorage>false</CentralStorage>
<ExcludeFromBuild>true</ExcludeFromBuild>
</FolderProperties>
</FolderResource>
<FolderResource>
<FolderPath>ttcn/LibIts/ttcn/V2G</FolderPath>
<FolderProperties>
<CentralStorage>false</CentralStorage>
<ExcludeFromBuild>true</ExcludeFromBuild>
</FolderProperties>
</FolderResource>
<FolderResource>
<FolderPath>ttcn/LibIts/xsd</FolderPath>
<FolderProperties>
<CentralStorage>false</CentralStorage>
<ExcludeFromBuild>true</ExcludeFromBuild>
</FolderProperties>
</FolderResource>
<FolderResource>
<FolderPath>unittests</FolderPath>
<FolderProperties>
<CentralStorage>false</CentralStorage>
<ExcludeFromBuild>true</ExcludeFromBuild>
</FolderProperties>
</FolderResource>
</FolderProperties>
<FileProperties>
<FileResource>
<FilePath>ccsrc/EncDec/LibItsEvcsn_Encdec.cc</FilePath>
<FileProperties>
<ExcludeFromBuild>true</ExcludeFromBuild>
</FileProperties>
</FileResource>
<FileResource>
<FilePath>ccsrc/Externals/LibItsDcc_externals.cc</FilePath>
<FileProperties>
<ExcludeFromBuild>true</ExcludeFromBuild>
</FileProperties>
</FileResource>
<FileResource>
<FilePath>ccsrc/Ports/LibIts_ports/Pki_ports/AdapterControlPort_Pki.partC</FilePath>
<FileProperties>
<ExcludeFromBuild>true</ExcludeFromBuild>
</FileProperties>
</FileResource>
<FileResource>
<FilePath>ccsrc/Ports/LibIts_ports/Pki_ports/AdapterControlPort_Pki.partH</FilePath>
<FileProperties>
<ExcludeFromBuild>true</ExcludeFromBuild>
</FileProperties>
</FileResource>
<FileResource>
<FilePath>data/gencerts.cfg</FilePath>
<FileProperties>
<ExcludeFromBuild>true</ExcludeFromBuild>
</FileProperties>
</FileResource>
<FileResource>
<FilePath>ttcn/LibIts/asn1/Security/TS102921/EtsiTs102941MessagesCA.asn</FilePath>
<FileProperties>
<ExcludeFromBuild>true</ExcludeFromBuild>
</FileProperties>
</FileResource>
<FileResource>
<FilePath>ttcn/LibIts/asn1/Security/TS102921/EtsiTs102941MessagesItss_OptionalPrivacy.asn</FilePath>
<FileProperties>
<ExcludeFromBuild>true</ExcludeFromBuild>
</FileProperties>
</FileResource>
</FileProperties>
</TITAN_Designer_Properties>
\ No newline at end of file
......@@ -9,6 +9,7 @@
#include "IVIM_ports/AdapterControlPort_IVIM.partC"
#include "MapemSpatem_ports/AdapterControlPort_MapemSpatem.partC"
#include "SremSsem_ports/AdapterControlPort_SremSsem.partC"
//#include "Pki_ports/AdapterControlPort_Pki.partC"
//#include "V2G_ports/AdapterControlPort_V2G.partC"
#else //_NO_SOFTLINKS_
......@@ -19,6 +20,7 @@
#include "AdapterControlPort_MapemSpatem.partC"
#include "AdapterControlPort_SremSsem.partC"
#include "AdapterControlPort_GN.partC"
//#include "AdapterControlPort_Pki.partC"
/*
#include "AdapterControlPort_IVIM.partC"
#include "AdapterControlPort_MapemSpatem.partC"
......
......@@ -9,6 +9,7 @@
#include "CAM_ports/AdapterControlPort_CAM.partH"
#include "DENM_ports/AdapterControlPort_DENM.partH"
#include "GN_ports/AdapterControlPort_GN.partH"
//#include "Pki_ports/AdapterControlPort_Pki.partH"
#include "IVIM_ports/AdapterControlPort_IVIM.partH"
#include "MapemSpatem_ports/AdapterControlPort_MapemSpatem.partH"
#include "SremSsem_ports/AdapterControlPort_SremSsem.partH"
......@@ -22,6 +23,7 @@
#include "AdapterControlPort_MapemSpatem.partH"
#include "AdapterControlPort_SremSsem.partH"
#include "AdapterControlPort_GN.partH"
//#include "AdapterControlPort_Pki.partH"
/*
#include "AdapterControlPort_IVIM.partH"
#include "AdapterControlPort_MapemSpatem.partH"
......
#include <TTCN3.hh>
#include "loggers.hh"
#include "registration.hh"
#include "http_layer.hh"
//=============================================================================
namespace LibItsPki__TestSystem {
AdapterControlPort::AdapterControlPort(const char *par_port_name)
: AdapterControlPort_BASE(par_port_name), _params()
{
loggers::get_instance().log("AdapterControlPort::AdapterControlPort");
}
AdapterControlPort::~AdapterControlPort()
{
}
void AdapterControlPort::set_parameter(const char * parameter_name, const char * parameter_value)
{
loggers::get_instance().log("AdapterControlPort::set_parameter: %s=%s", parameter_name, parameter_value);
}
/*void AdapterControlPort::Handle_Fd_Event(int fd, boolean is_readable,
boolean is_writable, boolean is_error) {}*/
void AdapterControlPort::Handle_Fd_Event_Error(int /*fd*/)
{
}
void AdapterControlPort::Handle_Fd_Event_Writable(int /*fd*/)
{
}
void AdapterControlPort::Handle_Fd_Event_Readable(int /*fd*/)
{
}
/*void AdapterControlPort::Handle_Timeout(double time_since_last_call) {}*/
void AdapterControlPort::user_map(const char * system_port)
{
loggers::get_instance().log(">>> AdapterControlPort::user_map: %s", system_port);
}
void AdapterControlPort::user_unmap(const char * system_port)
{
loggers::get_instance().log(">>> AdapterControlPort::user_unmap: %s", system_port);
}
void AdapterControlPort::user_start()
{
}
void AdapterControlPort::user_stop()
{
}
void AdapterControlPort::outgoing_send(const LibItsPki__TypesAndValues::AcGnPrimitive& send_par)
{
loggers::get_instance().log_msg(">>> AdapterControlPort::outgoing_send: ", send_par);
}
void AdapterControlPort::outgoing_send(const LibItsCommon__TypesAndValues::AcSecPrimitive& send_par)
{
loggers::get_instance().log_msg(">>> AdapterControlPort::outgoing_send: ", send_par);
// Register this object for AdapterControlPort
http_layer* p = registration<http_layer>::get_instance().get_item(std::string("HTTP"));
if (p != NULL) {
loggers::get_instance().log("AdapterControlPort::outgoing_send: Got HTTP layer %p", p);
LibItsCommon__TypesAndValues::AdapterControlResults response;
response.acSecResponse() = BOOLEAN(true);
if (send_par.ischosen(LibItsCommon__TypesAndValues::AcSecPrimitive::ALT_acEnableSecurity)) {
loggers::get_instance().log("AdapterControlPort::outgoing_send: Enable secured mode");
std::string str(static_cast<const char*>(send_par.acEnableSecurity().certificateId()));
if (p->enable_secured_mode(str, send_par.acEnableSecurity().enforceSecurity()) == -1) {
response.acSecResponse() = BOOLEAN(false);
}
} else if (send_par.ischosen(LibItsCommon__TypesAndValues::AcSecPrimitive::ALT_acDisableSecurity)) {
loggers::get_instance().log("AdapterControlPort::outgoing_send: Disable secured mode");
if (p->disable_secured_mode() == -1) {
response.acSecResponse() = BOOLEAN(false);
}
} else {
response.acSecResponse() = BOOLEAN(false);
}
// Send response
loggers::get_instance().log_msg("AdapterControlPort::outgoing_send: Send response: ", response);
incoming_message(response);
} else {
loggers::get_instance().error("AdapterControlPort::outgoing_send: %s not registered", "geoNetworkingPort");
}
}
} /* end of namespace */
//=============================================================================
#include "LibItsPki_TestSystem.hh"
#include "params.hh"
namespace LibItsPki__TestSystem {
class AdapterControlPort : public AdapterControlPort_BASE {
params _params;
public:
AdapterControlPort(const char *par_port_name = NULL);
~AdapterControlPort();
void set_parameter(const char *parameter_name,
const char *parameter_value);
private:
/* void Handle_Fd_Event(int fd, boolean is_readable,
boolean is_writable, boolean is_error); */
void Handle_Fd_Event_Error(int fd);
void Handle_Fd_Event_Writable(int fd);
void Handle_Fd_Event_Readable(int fd);
/* void Handle_Timeout(double time_since_last_call); */
protected:
void user_map(const char *system_port);
void user_unmap(const char *system_port);
void user_start();
void user_stop();
void outgoing_send(const LibItsPki__TypesAndValues::AcGnPrimitive& send_par);
void outgoing_send(const LibItsCommon__TypesAndValues::AcSecPrimitive& send_par);
};
} /* end of namespace */
......@@ -68,11 +68,35 @@ void PkiPort::user_stop()
}
void PkiPort::outgoing_send(const LibItsPki__TestSystem::PkiReq& /*send_par*/)
void PkiPort::outgoing_send(const EtsiTs102941TypesEnrolment::InnerEcRequest& send_par)
{
}
void PkiPort::outgoing_send(const EtsiTs102941TypesEnrolment::InnerEcResponse& send_par)
{
}
void PkiPort::receiveMsg (const EtsiTs102941TypesEnrolment::InnerEcRequest& p_ind, const params& p_params) {
loggers::get_instance().log_msg(">>> PkiPort::receive_msg: ", p_ind);
// Sanity check
if (!p_ind.is_bound()) {
return;
}
incoming_message(p_ind);
}
void PkiPort::receiveMsg (const EtsiTs102941TypesEnrolment::InnerEcResponse& p_ind, const params& p_params) {
loggers::get_instance().log_msg(">>> PkiPort::receive_msg: ", p_ind);
// Sanity check
if (!p_ind.is_bound()) {
return;
}
incoming_message(p_ind);
}
} /* end of namespace */
......@@ -19,8 +19,9 @@ public:
PkiPort(const char *par_port_name = NULL);
~PkiPort();
void set_parameter(const char *parameter_name,
const char *parameter_value);
void set_parameter(const char *parameter_name, const char *parameter_value);
void receiveMsg (const EtsiTs102941TypesEnrolment::InnerEcRequest& p_ind, const params& p_params);
void receiveMsg (const EtsiTs102941TypesEnrolment::InnerEcResponse& p_ind, const params& p_params);
private:
/* void Handle_Fd_Event(int fd, boolean is_readable,
......@@ -36,7 +37,8 @@ protected:
void user_start();
void user_stop();
void outgoing_send(const LibItsPki__TestSystem::PkiReq& send_par);
void outgoing_send(const EtsiTs102941TypesEnrolment::InnerEcRequest& send_par);
void outgoing_send(const EtsiTs102941TypesEnrolment::InnerEcResponse& send_par);
};
} /* end of namespace */
......
#include "pki_layer_factory.hh"
#include "codec_stack_builder.hh"
#include "loggers.hh"
#include "converter.hh"
using namespace std; // Required for isnan()
#include "LibItsPki_TestSystem.hh"
pki_layer::pki_layer(const std::string & p_type, const std::string & param) : t_layer<LibItsPki__TestSystem::HttpPort>(p_type), _params(), _etsi_ts102941_types_enrolment_inner_request(), _etsi_ts102941_types_enrolment_inner_request(), _codec()
{
loggers::get_instance().log(">>> pki_layer::pki_layer: %s, %s", to_string().c_str(), param.c_str());
// Setup parameters
params::convert(_params, param);
// Sanity checks
params::const_iterator it = _params.find(params::certificate);
if (it == _params.cend()) {
_params[params::certificate] = "CERT_TS_A_EA";
}
it = _params.find(params::peer_certificate);
if (it == _params.cend()) {
_params[params::certificate] = "CERT_IUT_A_EA";
}
_params[params::its_aid] = "0";
_params[params::payload_type] = "";
_params[params::encrypted_mode] = "1";
}
void pki_layer::sendMsg(const EtsiTs102941TypesEnrolment::InnerEcRequest& p_inner_ec_request, params& p_param) {
loggers::get_instance().log_msg(">>> pki_layer::sendMsg: ", p_pki_message);
OCTETSTRING data;
_etsi_ts102941_types_enrolment_inner_request.encode(p_pki_message, data);
// Add security
OCTETSTRING secured_data;
if (secured_payload(data, secured_data) == 0) {
send_data(data, _params);
}
}
void pki_layer::sendMsg(const EtsiTs102941TypesEnrolment::InnerEcResponse& p_inner_ec_request, params& p_param) {
loggers::get_instance().log_msg(">>> pki_layer::sendMsg: ", p_pki_message);
OCTETSTRING data;
_etsi_ts102941_types_enrolment_inner_response.encode(p_pki_message, data);
// Add security
OCTETSTRING secured_data;
if (secured_payload(data, secured_data) == 0) {
send_data(data, _params);
}
}
void pki_layer::send_data(OCTETSTRING& data, params& params) {
loggers::get_instance().log_msg(">>> pki_layer::send_data: ", data);
send_to_all_layers(data, params);
}
void pki_layer::receive_data(OCTETSTRING& data, params& params)
{
loggers::get_instance().log_msg(">>> pki_layer::receive_data: ", data);
// Decode HTTP message
LibItsPki__TypesAndValues::HttpMessage pki_message;
if (_codec.decode(data, pki_message) == -1) {
loggers::get_instance().warning("pki_layer::receive_data: Failed to decode data");
return;
}
// Pass it to the ports