OnixS C++ FIX Engine  3.24.0
API Documentation
Logon Password Authentication

While Accepting an incoming FIX connection, additional authentication checks may be required. The typical checks are Logon username/password and source IP address.

The required authentification logic could be added to the OnixS::FIX::ISessionListener::onInboundSessionMsg(..) method. If the authentication fails and the FIX connection needs to be rejected (closed) then the std::runtime_error exception (or the derived one) should be thrown.

For example:

bool doAuthentication(const Message& message, string& reason)
{
// ...
}
void Listener::onInboundSessionMsg (Message& message, Session* sn)
{
if ( message.type() == OnixS::FIX::FIX50_SP2::Values::MsgType::Logon )
{
std::string reason;
// Do user authentication here
if (! doAuthentication(fixMsg,reason))
{
throw std::runtime_error(reason);
}
}
}

If the std::runtime_error exception is thrown and OnixS::FIX::EngineSettings::sendLogoutOnException(..) or OnixS::FIX::Session::sendLogoutOnException(..) is set to true then the Logout FIX message will be sent before closing the FIX connection. Otherwise the connection will be closed immediately.