java - SnmpV3 Trap Receiver with Authentication/Privacy - dynamically obtain engineID from agents -


i trying develop snmpv3 trap receiver using webnms adventnet api. if use authentication , privacy options (md5 + des), need know engineid of agent sends traps in order decrypt trap content. how can obtain engineid dynamically (without hardcoding in application)? i saw it's possible perform discovery of engineid

but work need provide port used agent when sends traps (and agent real network element uses random source ports).

the following code working, hard-coded engineid. there different way decrypt traps without hardcoding engineid?

public class dragosapp2 implements snmpclient{     public static void main(string[] args) throws snmpexception {         snmpapi api = new snmpapi();         snmpengineentry snmpentry = new snmpengineentry("10.10.66.79");         snmpenginetable enginetable = api.getsnmpengine();         enginetable.addentry(snmpentry);         snmpsession session = new snmpsession(api);         session.addsnmpclient(new dragosapp2());         udpprotocoloptions ses_opt = new udpprotocoloptions();         ses_opt.setlocalport(162);         session.setprotocoloptions(ses_opt);         session.open();         byte[] engineid = gethexvalue("0x80001f888026f9036957333c81");  // how can replace part??          usmuserentry user = new usmuserentry(new string("dragos3").getbytes(), engineid);         user.setauthprotocol(usmuserentry.md5_auth);         user.setprivprotocol(usmuserentry.cbc_des);          byte[] authkey = usmutils.password_to_key(usmuserentry.md5_auth,                                                  new string("12345678").getbytes(),                                                 new string("12345678").getbytes().length,                                                 engineid);          byte[] privkey = usmutils.password_to_key(usmuserentry.md5_auth,                             new string("12345678").getbytes(),                             new string("12345678").getbytes().length,                             engineid,                             usmuserentry.cbc_des);          user.setauthpassword(new string("12345678").getbytes());         user.setprivpassword(new string("12345678").getbytes());         user.setauthkey(authkey);         user.setprivkey(privkey);         user.setsecuritylevel((byte)3);         user.setengineentry(snmpentry);         usmusertable uut = (usmusertable)api.getsecurityprovider().gettable(3);         uut.addentry(user);     }    } 


Comments

Popular posts from this blog

magento2 - Magento 2 admin grid add filter to collection -

Android volley - avoid multiple requests of the same kind to the server? -

Combining PHP Registration and Login into one class with multiple functions in one PHP file -