[SNMP4J] reg: USM and MPV3

Brice Fines bfines at sermepa.es
Wed Apr 21 10:12:03 CEST 2010


Hi,

I had a similar problem, I was getting a "Unknown security name" from USM.
I checked that the user was added correctly, and it was, but after doing 
some debugging I noticed I was using a different USM.
My error was I was doing initialization twice in my application with 
different USM (one with a UsmUser, the other one without a UsmUser). In 
one place, I was calling:

final USM usm = new USM(SecurityProtocols.getInstance(),
                                new 
OctetString(MPv3.createLocalEngineID()), 0);
SecurityModels.getInstance().addSecurityModel(usm);
snmp.getUSM().addUser(new OctetString(securityName),new UsmUser(new 
OctetString(securityName),...));

and a bit later:

final USM usm = new USM(SecurityProtocols.getInstance(),
                                new 
OctetString(MPv3.createLocalEngineID()), 0);
SecurityModels.getInstance().addSecurityModel(usm);

Since SecurityModels is a singleton, I was losing the USM with the 
configured user, that's why I was getting "Unknown security name" when 
checking security against the other (the one without UsmUser).

I solved it by doing a single init call to 
SecurityModels.getInstance().addSecurityModel(usm) for the whole 
application.

Regards




More information about the SNMP4J mailing list