diff --git a/src/PlainSession.cpp b/src/PlainSession.cpp index 9c9a6624782db2368c3fcbb9ec6fae9f66f87f33..44755d59350af2bb1b7d27316260a3f124b26105 100644 --- a/src/PlainSession.cpp +++ b/src/PlainSession.cpp @@ -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; } } diff --git a/src/ProtocolManager.cpp b/src/ProtocolManager.cpp index 19dbb6a29e65240856d717bf2480a83dd43d08a6..76c8d20daa73ba4aea930b72b3b109d3c6c1091a 100644 --- a/src/ProtocolManager.cpp +++ b/src/ProtocolManager.cpp @@ -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"); diff --git a/src/ProtocolManager.h b/src/ProtocolManager.h index 9b713651f4958b0fb3646479f717a5d3cafd4848..66e53fddd2d48753fa6652a7f50e08b217073136 100644 --- a/src/ProtocolManager.h +++ b/src/ProtocolManager.h @@ -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 diff --git a/src/SSLServer.cpp b/src/SSLServer.cpp index c04ca9bf977528599b54480e6adf269e8cfa5ead..77b2fd277879e4613e500a80906fffbf64d20e02 100644 --- a/src/SSLServer.cpp +++ b/src/SSLServer.cpp @@ -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); diff --git a/src/SSLSession.cpp b/src/SSLSession.cpp index cb0394d2f29158a74252b336dd205092d1ead790..d361d8e925aa627a2f6981a2448c76157a3aeb76 100644 --- a/src/SSLSession.cpp +++ b/src/SSLSession.cpp @@ -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; } } diff --git a/src/Session.cpp b/src/Session.cpp index 8fa49c54aa534929b7e72e4fb4754849221a6b10..b05a1abdd9df4429a18d0713f7f6ce49d695e2aa 100644 --- a/src/Session.cpp +++ b/src/Session.cpp @@ -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; } } diff --git a/src/Session.h b/src/Session.h index a99332095dd374785dac756f7a4000fc8f4287b1..08e33c2b16843d450c3ef6c511439ac329a53817 100644 --- a/src/Session.h +++ b/src/Session.h @@ -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