[SNMP4J] SNMPv3 with encryption doesn't work
InternetX - Christian Bleicher
christian.bleicher at internetx.de
Mon Jun 18 09:48:19 CEST 2007
Hello list,
i have the following problem. If I use snmpv3 without encryption all works
fine. Also if I use the get command with encryption it works fine.
But if I try to set a snmp variable to something else, there is no result.
Here's my source:
public String setV3(OID oid,Variable variable) throws IOException,
NoResponseException {
TransportMapping transport = new
DefaultUdpTransportMapping();
Snmp snmp = new Snmp(transport);
USM usm = new USM(
SecurityProtocols.getInstance(),
new
OctetString(MPv3.createLocalEngineID()),
0
);
SecurityModels.getInstance().addSecurityModel(usm);
snmp.getUSM().addUser(new OctetString(snmpV3User),
new UsmUser(new OctetString(snmpV3User),
AuthMD5.ID,
new OctetString(snmpAuthPassphrase),
PrivDES.ID,
new OctetString(snmpPrivPassphrase)));
transport.listen();
CommandResponder trapPrinter = new
CommandResponder() {
public synchronized void
processPdu(CommandResponderEvent e) {
PDU command = e.getPDU();
if (command != null) {
}
}
};
snmp.addCommandResponder(trapPrinter);
// setting up target
target.setRetries(retries);
target.setTimeout(timeout);
target.setVersion(version);
((UserTarget)target).setSecurityLevel(SecurityLevel.AUTH_PRIV);
((UserTarget)target).setSecurityName(new
OctetString(getSnmpV3User()));
//Create var Binding
VariableBinding vb = new VariableBinding(oid);
vb.setVariable(variable);
// creating PDU
PDU pdu = new ScopedPDU();
pdu.add(vb);
pdu.setType(PDU.SET);
System.out.println(pdu);
ResponseEvent response = snmp.set(pdu,target);
System.out.println(response.getUserObject());
if(response == null){
throw new NoResponseException();
}
return response.getRequest().toString();
}
NOTE: If I don't use encryption I set the SecurityLevel to NOAUTH_NOPRIV
I have checked the encryption pass phrases and searched for a possibility to
solve the problem. But I couldn't find anything. I hope you can help me.
With friendly regards
Christian
More information about the SNMP4J
mailing list