forwardConnecting using Custom Logon Message   Table of ContentResetting Message Sequence Numbersforward
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. Depending on the result of the logon verification check, the decision that can be made whether to Accept the FIX connection or reject and close the connection. This is typically performed at the logon stage.

In order to achieve this, you should subscribe to the inbound session messages and add the required check logic. If the check fails and the FIX connection needs to be rejected (closed), then an exception can be thrown from the inbound session message listener.

In the following example, the password authentication check is demonstrated.

using FIXForge.NET.FIX;
using FIXForge.NET.FIX.FIX44;

class SessionListener
    public void OnInboundSessionMsg(Object sender, InboundSessionMsgEventArgs e)
        Message message = e.Msg;

        if (message.Type.Equals(MsgType.Logon))
            if (message.Get(Tags.Password) != "ExpectedPassword")
                throw new Exception("Password is incorrect");

            // ..
Imports FIXForge.NET.FIX
Imports FIXForge.NET.FIX.FIX43

Sub OnInboundSessionMsg(ByVal sender As [Object], ByVal e As InboundSessionMsgEventArgs)

    Dim message As Message = e.Msg

    If message.Type.Equals(MsgType.Logon) Then
        If Not "ExpectedPassword".Equals(message.Get(Tags.Password)) Then
            Throw New Exception("Password is incorrect")
        End If
    End If

End Sub 'OnInboundSessionMsg