Skip to content
Snippets Groups Projects
Commit c41153fb authored by Marco De Marco's avatar Marco De Marco
Browse files

Remote endpoint added to protocol manager

parent 7cd4071a
Branches
Tags
No related merge requests found
......@@ -26,7 +26,7 @@ PlainSession::~PlainSession()
DEBUG_STREAM << "PlainSession::~PlainSession()" << endl;
INFO_STREAM << "PlainSession::~PlainSession() Disconnection from "
<< remoteEndpoint << endl;
<< m_remoteEndpoint << endl;
boost::system::error_code errorCode;
......@@ -65,11 +65,13 @@ void PlainSession::start()
{
DEBUG_STREAM << "PlainSession::start()" << endl;
remoteEndpoint = boost::lexical_cast<std::string>(
m_remoteEndpoint = boost::lexical_cast<std::string>(
m_plainSocket.remote_endpoint());
INFO_STREAM << "PlainSession::start() Connection from "
<< remoteEndpoint << endl;
<< m_remoteEndpoint << endl;
m_protocolManager_sp->setRemoteEndpoint(m_remoteEndpoint);
startReadRequestHeader();
}
......@@ -102,7 +104,7 @@ void PlainSession::startReadRequestBody(boost::uint32_t bodySize)
#ifdef VERBOSE_DEBUG
INFO_STREAM << "PlainSession::startReadRequestBody() "
<< remoteEndpoint << " >>>> " << bodySize << " BYTE" << endl;
<< m_remoteEndpoint << " >>>> " << bodySize << " BYTE" << endl;
#endif
boost::asio::async_read(m_plainSocket, mutableBuffer,
......@@ -136,7 +138,7 @@ void PlainSession::startWriteResponse()
#ifdef VERBOSE_DEBUG
INFO_STREAM << "PlainSession::startWriteResponse() "
<< remoteEndpoint << " <<<< " << bodySize << " byte" << endl;
<< m_remoteEndpoint << " <<<< " << bodySize << " byte" << endl;
#endif
boost::asio::async_write(m_plainSocket, boost::asio::buffer(writeBuff),
......@@ -146,12 +148,12 @@ void PlainSession::startWriteResponse()
catch(std::runtime_error& ec)
{
ERROR_STREAM << "SSLSession::startWriteResponse() "
<< ec.what() << " from " << remoteEndpoint << endl;
<< ec.what() << " from " << m_remoteEndpoint << endl;
}
catch(...)
{
ERROR_STREAM << "SSLSession::startWriteResponse() unknown error from "
<< remoteEndpoint << endl;
<< m_remoteEndpoint << endl;
}
}
......
......@@ -37,6 +37,16 @@ ProtocolManager::SP ProtocolManager::create(Tango::DeviceImpl* deviceImpl_p,
return d_sp;
}
//==============================================================================
// ProtocolManager::ProtocolManager()
//==============================================================================
void ProtocolManager::setRemoteEndpoint(std::string remoteEndpoint)
{
DEBUG_STREAM << "ProtocolManager::setRemoteEndpoint()" << endl;
m_remoteEndpoint = remoteEndpoint;
}
//==============================================================================
// ProtocolManager::prepareResponse()
//==============================================================================
......@@ -97,7 +107,7 @@ ResponseSP ProtocolManager::prepareAuthroisation(RequestSP request_sp)
if(m_configuration_sp->isUserAuthorized(username, password))
{
INFO_STREAM << "ProtocolManager::prepareAuthroisation() "
<< "Authorization accepted" << endl;
<< "Authorization accepted from " << m_remoteEndpoint << endl;
m_isAuthorised = true;
......@@ -107,7 +117,7 @@ ResponseSP ProtocolManager::prepareAuthroisation(RequestSP request_sp)
else
{
WARN_STREAM << "ProtocolManager::prepareAuthroisation() "
<< "Invalid username or password" << endl;
<< "Invalid username or password from " << m_remoteEndpoint << endl;
m_isAuthorised = false;
......@@ -118,7 +128,7 @@ ResponseSP ProtocolManager::prepareAuthroisation(RequestSP request_sp)
else
{
WARN_STREAM << "ProtocolManager::prepareAuthroisation() "
<< "Already authorized" << endl;
<< "Already authorized from " << m_remoteEndpoint << endl;
auth_resp->set_state(Response::Authorization::REJECTED);
auth_resp->set_status("Already authorized");
......@@ -167,6 +177,9 @@ ResponseSP ProtocolManager::prepareValidation(RequestSP request_sp)
for(it=columns.begin(); it!=columns.end(); ++it)
validateColumn(*it, informationList);
INFO_STREAM << "ProtocolManager::prepareValidation() "
<< "Validation accepted from " << m_remoteEndpoint << endl;
m_isValidated = true;
validationRes->set_state(Response::Validation::ACCEPTED);
......@@ -181,7 +194,7 @@ ResponseSP ProtocolManager::prepareValidation(RequestSP request_sp)
else
{
WARN_STREAM << "ProtocolManager::prepareValidation() "
<< "Already validated" << endl;
<< "Already validated from " << m_remoteEndpoint << endl;
validationRes->set_state(Response::Validation::REJECTED);
validationRes->set_status("Already validated");
......@@ -190,7 +203,7 @@ ResponseSP ProtocolManager::prepareValidation(RequestSP request_sp)
else
{
WARN_STREAM << "ProtocolManager::prepareValidation() "
<< "Not authorised" << endl;
<< "Not authorised from " << m_remoteEndpoint << endl;
validationRes->set_state(Response::Validation::REJECTED);
validationRes->set_status("Not authorised");
......
......@@ -48,6 +48,11 @@ public:
static ProtocolManager::SP create(Tango::DeviceImpl*, Configuration::SP,
DBManager::SP);
//------------------------------------------------------------------------------
// [Public] Remote endpoint setter method
//------------------------------------------------------------------------------
void setRemoteEndpoint(std::string);
//------------------------------------------------------------------------------
// [Public] Request response management method
//------------------------------------------------------------------------------
......@@ -87,6 +92,9 @@ protected:
//Table structure is validated
bool m_isValidated;
//Address and port of remote endpoint
std::string m_remoteEndpoint;
};
} //End of namespace
......
......@@ -29,9 +29,9 @@ SSLServer::SSLServer(Tango::DeviceImpl* deviceImpl_p,
std::string privateKey = m_configuration_sp->getPrivateKeyFile();
std::string dHTempFile = m_configuration_sp->getDHTempFile();
INFO_STREAM << "CERTIFICATE FILE: " << certificateFile << endl;
INFO_STREAM << "PRIVATE KEY FILE: " << privateKey << endl;
INFO_STREAM << "DH TEMPORARY FILE: " << dHTempFile << endl;
INFO_STREAM << "SSLServer::SSLServer() Certificate " << certificateFile << endl;
INFO_STREAM << "SSLServer::SSLServer() Private key " << privateKey << endl;
INFO_STREAM << "SSLServer::SSLServer() DH Temporary " << dHTempFile << endl;
//@todo: check error_code use in load file methods
m_context_sp->use_certificate_chain_file(certificateFile);
......
......@@ -27,7 +27,7 @@ SSLSession::~SSLSession()
DEBUG_STREAM << "SSLSession::~SSLSession()" << endl;
INFO_STREAM << "SSLSession::~SSLSession() Disconnection from "
<< remoteEndpoint << endl;
<< m_remoteEndpoint << endl;
boost::system::error_code errorCode;
......@@ -70,10 +70,13 @@ void SSLSession::start()
{
DEBUG_STREAM << "SSLSession::start()" << endl;
remoteEndpoint = boost::lexical_cast<std::string>(
m_remoteEndpoint = boost::lexical_cast<std::string>(
m_sslSocket.lowest_layer().remote_endpoint());
INFO_STREAM << "SSLSession::start() Connection from " << remoteEndpoint << endl;
INFO_STREAM << "SSLSession::start() Connection from "
<< m_remoteEndpoint << endl;
m_protocolManager_sp->setRemoteEndpoint(m_remoteEndpoint);
startHandShake();
}
......@@ -104,7 +107,7 @@ void SSLSession::handleHandShake(const boost::system::error_code& errorCode)
else
{
ERROR_STREAM << "SSLSession::handleHandShake() error "
<< errorCode.message() << " from " << remoteEndpoint << endl;
<< errorCode.message() << " from " << m_remoteEndpoint << endl;
}
}
......@@ -136,7 +139,7 @@ void SSLSession::startReadRequestBody(boost::uint32_t bodySize)
#ifdef VERBOSE_DEBUG
INFO_STREAM << "SSLSession::startReadRequestBody() "
<< remoteEndpoint << " >>>> " << bodySize << " byte" << endl;
<< m_remoteEndpoint << " >>>> " << bodySize << " byte" << endl;
#endif
boost::asio::async_read(m_sslSocket, mutableBuffer,
......@@ -171,7 +174,7 @@ void SSLSession::startWriteResponse()
#ifdef VERBOSE_DEBUG
INFO_STREAM << "SSLSession::startWriteResponse() "
<< remoteEndpoint << " <<<< " << bodySize << " byte" << endl;
<< m_remoteEndpoint << " <<<< " << bodySize << " byte" << endl;
#endif
boost::asio::async_write(m_sslSocket, boost::asio::buffer(writeBuff),
......@@ -181,12 +184,12 @@ void SSLSession::startWriteResponse()
catch(std::runtime_error& ec)
{
ERROR_STREAM << "SSLSession::startWriteResponse() "
<< ec.what() << " from " << remoteEndpoint << endl;
<< ec.what() << " from " << m_remoteEndpoint << endl;
}
catch(...)
{
ERROR_STREAM << "SSLSession::startWriteResponse() unknown error from "
<< remoteEndpoint << endl;
<< m_remoteEndpoint << endl;
}
}
......
......@@ -41,12 +41,12 @@ void Session::handleReadRequestHeader(const boost::system::error_code& errorCode
else if(errorCode == boost::asio::error::eof)
{
DEBUG_STREAM << "Session::handleReadRequestBody() end of file from "
<< remoteEndpoint << endl;
<< m_remoteEndpoint << endl;
}
else
{
ERROR_STREAM << "Session::handleReadRequestHeader() "
<< errorCode.message() << " from " << remoteEndpoint << endl;
<< errorCode.message() << " from " << m_remoteEndpoint << endl;
}
}
......@@ -64,12 +64,12 @@ void Session::handleReadRequestBody(const boost::system::error_code& errorCode)
else if(errorCode == boost::asio::error::eof)
{
DEBUG_STREAM << "Session::handleReadRequestBody() end of file from"
<< remoteEndpoint << endl;
<< m_remoteEndpoint << endl;
}
else
{
ERROR_STREAM << "Session::handleReadRequestBody() "
<< errorCode.message() << " from " << remoteEndpoint << endl;
<< errorCode.message() << " from " << m_remoteEndpoint << endl;
}
}
......@@ -87,12 +87,12 @@ void Session::handleWriteResponse(const boost::system::error_code& errorCode)
else if(errorCode == boost::asio::error::eof)
{
DEBUG_STREAM << "Session::handleWriteResponse() end of file from "
<< remoteEndpoint << endl;
<< m_remoteEndpoint << endl;
}
else
{
ERROR_STREAM << "Session::handleWriteResponse() "
<< errorCode.message() << " from " << remoteEndpoint << endl;
<< errorCode.message() << " from " << m_remoteEndpoint << endl;
}
}
......
......@@ -91,7 +91,7 @@ protected:
std::vector<boost::uint8_t> m_readBuff;
//Address and port of remote endpoint
std::string remoteEndpoint;
std::string m_remoteEndpoint;
};
} //End of namespace
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please to comment