java - Can't get SNMP authentication work correctly with snmp4j -


i writing snmp v3 trap/informs sender using snmp4j authentication, i'm surprised informs correctly acknowledged if there's authentication failure. developed trap receiver using snmp4j me debugging.

i've noticed several unexpected scenarios:

1st scenario: sending inform auth / nopriv, unknown username or wrong password => the inform not acknowledged, there's no response, sender has wait timeout. on receiver side however, authenticationfailureevent fired, have expected snmp4j responds sender error. overridden method processpdu not called. guess may depends on receiver implementations, or there standard behaviour this?

2nd scenario: sending inform existing username no password (with noauth / nopriv), whereas it's configured password on receiver => inform acknowledged response, without error, , trap receiver doesn't fire authenticationfailureevent should. expect receiver rejects request if it's unauthenticated. did forget initialize something? can't imagine there's such security hole in snmp4j.

the code use initializing receiver: (i don't show here overridden methods processpdu , authenticationfailure)

embeddedsnmpreceiver(final int port, final optional<usmuser> user) throws ioexception {     final messagedispatcherimpl dispatcher = new messagedispatcherimpl();     dispatcher.addauthenticationfailurelistener(this);     final udpaddress listenaddress = new udpaddress("localhost/" + port);     final transportmapping transport = new defaultudptransportmapping(listenaddress);     securityprotocols.getinstance().adddefaultprotocols();     final usm usm = new usm(securityprotocols.getinstance(), new octetstring("receiver"), 0);     snmp = new snmp(dispatcher, transport);      snmp.getmessagedispatcher().addmessageprocessingmodel(new mpv1());     snmp.getmessagedispatcher().addmessageprocessingmodel(new mpv2c());     snmp.getmessagedispatcher().addmessageprocessingmodel(new mpv3(usm));     securitymodels.getinstance().addsecuritymodel(usm);     if (user.ispresent()) {         snmp.getusm().adduser(user.get().getsecurityname(), user.get());     }      snmp.addcommandresponder(this);     snmp.listen(); }  public static void main(string[] args) {     // debug     try {         final octetstring octusername = new octetstring("zaza");         final oid userauthoid = authsha.id;         final octetstring octuserpassphrase = new octetstring("12345678");         final usmuser user = new usmuser(octusername, userauthoid, octuserpassphrase, null, null);         final embeddedsnmpreceiver server = new embeddedsnmpreceiver(1099, optional.of(user));         thread.sleep(500000);         server.stop();     } catch (exception e) {         e.printstacktrace();     } } 

ps: clarify, start receiver in separate process sender avoid issues snmp4j stateful nature / singletons...

you might read rfc 3414 section 4 see if in fact hit desired behaviors of discovery process.

1st should not acknowledged , follows v1 , v2c convention.

2nd expected if reply message report.


Comments

Popular posts from this blog

Magento/PHP - Get phones on all members in a customer group -

php - .htaccess mod_rewrite for dynamic url which has domain names -

Website Login Issue developed in magento -