I found what looks like a bug in the dispatchMessage method of the MessageDispatcherImpl class.
The switch statement around line 300 where the AuthenticationFailureEvent is fired is missing the break statement. The default case is always triggered which always shows the log message even when the event is fired.
I’m not sure if this is the intended functionality. It made me thing I had major errors in my application for weeks until I realized where the log was being written.
First, it seems that you are using modified code and not the original sources of SNMP4J 3.9.1.
Second, the log message is correct and the switch statement as well, because when the else block is reached in the code snippet below, then the message is not dispatched!
if (status == SnmpConstants.SNMP_ERROR_SUCCESS) {
// dispatch it
...
} else {
switch (status) {
case SnmpConstants.SNMP_MP_UNSUPPORTED_SECURITY_MODEL:
case SnmpConstants.SNMPv3_USM_AUTHENTICATION_FAILURE:
case SnmpConstants.SNMPv3_USM_UNSUPPORTED_SECURITY_LEVEL:
case SnmpConstants.SNMPv3_USM_UNKNOWN_SECURITY_NAME:
case SnmpConstants.SNMPv3_USM_AUTHENTICATION_ERROR:
case SnmpConstants.SNMPv3_USM_NOT_IN_TIME_WINDOW:
case SnmpConstants.SNMPv3_USM_UNSUPPORTED_AUTHPROTOCOL:
case SnmpConstants.SNMPv3_USM_UNKNOWN_ENGINEID:
case SnmpConstants.SNMP_MP_WRONG_USER_NAME:
case SnmpConstants.SNMPv3_TSM_INADEQUATE_SECURITY_LEVELS:
case SnmpConstants.SNMP_MP_USM_ERROR: {
@SuppressWarnings("unchecked")
AuthenticationFailureEvent<A> event =
new AuthenticationFailureEvent<>(this, incomingAddress,
(TransportMapping<? super A>) sourceTransport, status, wholeMessage);
fireAuthenticationFailure(event);
break;
}
}
if (logger.isInfoEnabled()) {
logger.info("Dispatching message canceled due to security issue: statusInfo="
+ statusInfo + ", status=" + status + ",tmStateReference="+tmStateReference);
}
}