No subject


Thu May 4 07:32:04 CEST 2017


I userstand that the agent uses SHA authentication, but I am unsure if
I need to specify the ContextEngineID of AuthoritiveEngineID when I
create and send the PDU.

--Aidan

====Adding USM user===
 OctetString localEngineID = new OctetString(MPv3.createLocalEngineID());
 USM usm = new USM(SecurityProtocols.getInstance(),
                            new OctetString(localEngineID), 0);

 // add user to the USM
 UsmUser user = new UsmUser(
                                            new OctetString("UserName"),
                            AuthSHA.ID,
                            new OctetString("password")
                           null, null
                           );

SecurityModels.getInstance().addSecurityModel(usm);
snmp.getUSM().addUser(user.getSecurityName(), user);
====

===Send GET===
Address targetAddress = GenericAddress.parse("udp:172.16.100.246/161");

UsmUserEntry userEntry = snmp.getUSM().getUserTable().getUser(new
OctetString("UserName"));

UserTarget target = new UserTarget();
target.setSecurityLevel(SecurityLevel.AUTH_NOPRIV);
target.setSecurityName(userEntry.getUsmUser().getSecurityName());
target.setVersion(SnmpConstants.version3);
target.setAddress(targetAddress);
target.setRetries(1);
target.setTimeout(5000);

ScopedPDU pdu = new ScopedPDU();
pdu.add(new VariableBinding(new OID("1.3.6.1.2.1.1.3")));
pdu.setType(PDU.GETNEXT);

ResponseEvent e = snmp.send(pdu, target);
if (e != null)
{
 ScopedPDU pduR = (ScopedPDU)e.getResponse();
}


=============



More information about the SNMP4J mailing list