[SNMP4J] Can SNMPv3 user credentials be passed to a new SNMP session?

Clamann, Alex aclamann at axxcelera.com
Wed Oct 10 14:55:02 CEST 2007


I am trying to pass SNMPv3 user credentials from one instance of an
org.snmp4j.Snmp to another instance. Can this be done?
 
I have an SNMP manager that retrieves a list of IP addresses, I would
like to be able to launch a new manager with the same credentials as the
first manager, but with a new target and its own org.snmp4j.Snmp object.
 
My attempts at this process seem to have disrupted the credentials of
the original Snmp object. SNMP requests by the newly instantiated SNMP
manager time out and subsequent SNMP requests from the original manager
timeout as well.
 
Object with Snmp instance #1:
 
UsmUserEntry userEntry = snmp.getUSM().getUser( new
OctetString(snmp.getLocalEngineID()), ( (UserTarget) getTarget()
).getSecurityName() );
int securityLevel = ( (UserTarget) getTarget() ).getSecurityLevel();
 
 
Object with Snmp instance #2:
 
private void snmpV3ConnectionUpdate(UsmUserEntry user, int
securityLevel) {

        InetAddress host;
        String hostName = ipAddressTextField.getText();
        try {
            host = InetAddress.getByName( hostName );
        } catch (UnknownHostException ex) {
            log.warn(ex.getMessage());
            return;
        }
        UdpAddress address = new UdpAddress(host, 161);
        
        v3Target = new UserTarget();
        v3Target.setAddress(address);
        
        v3Target.setRetries(snmpRetries);
        v3Target.setTimeout(snmpTimeout);
        v3Target.setVersion(SnmpConstants.version3);
        
        snmp.getUSM().removeAllUsers();
        snmp.getUSM().addUser(user.getUserName(), (UsmUser)
user.getUsmUser().clone());
        
        v3Target.setSecurityName(user.getUserName());
        v3Target.setSecurityLevel(securityLevel);
}
 
Has anyone been able to pass v3 credentials from one SNMP object to
another?
 
Thanks,
-Alex



More information about the SNMP4J mailing list