[SNMP4J] Question about the change in v1.10 "Added MPv3(USM usm) constructor "

Sjoerd van Doorn sjoerdvandoorn at yahoo.com
Tue Jun 16 18:31:54 CEST 2009


Hello Frank (and other readers that might know the answer ;-),
I tried to use the new functionality within the v1.10 to avoid using my own overloaded class as listed before. however i run into a problem I cannot figure out.It would be nice if you could help.below you find two methods, where the first is not working (using the new constructor) and reports 1403 errors. The second method is working correct. From my point of view, the functionality however should be interchangable, but I must be missing something.
Trace of error scenario:2009-06-16 18:28:38.859 CEST DEBUG [Timer-0   ]     Snmp4jAgent SNMP GET command (OID=<removed>.1.1.0)2009-06-16 18:28:43.859 CEST DEBUG [Timer-0   ]     Snmp4jAgent executed GET command (oid=<removed>.1.1.0), response=null2009-06-16 18:28:43.859 CEST ERROR [Timer-0   ]     Snmp4jAgent SNMP GetCommand :: response==null2009-06-16 18:28:43.859 CEST ERROR [Timer-0   ] ediationTableV1 result==null2009-06-16 18:28:43.875 CEST DEBUG [Timer-0   ]     Snmp4jAgent SNMP GET command (OID=<removed>.2.1.0)2009-06-16 18:28:43.875 CEST DEBUG [Timer-0   ] ediationTableV2 Error getting new index: Message processing model 3 returned error: 14032009-06-16 18:28:43.875 CEST DEBUG [Timer-0   ]     Snmp4jAgent SNMP GET command (OID=<removed>.3.1.0)2009-06-16 18:28:43.875 CEST DEBUG [Timer-0   ] iationTablePCV2 Error getting new index: Message processing model 3 returned error: 1403
Methods:
    /**     * Initializes the SNMP4J object.     * (non working method)     * @return     * @throws IOException     */    protected Snmp initSnmpAndSecurity( ) throws IOException    	{    	// create the snmp instance    	Snmp snmp = new Snmp();    	snmp.addTransportMapping(new DefaultUdpTransportMapping());    	    	OctetString localEngineID = new OctetString(MPv3.createLocalEngineID());    	    	// create the USM security model    	USM usm = new USM(SecurityProtocols.getInstance(), localEngineID, 0);        	// create the user for the USM    	UsmUser user = new UsmUser(_securityName,                                   _authProtocol,                                   _authPassphrase,                                   _privProtocol,                                   _privPassphrase                                
  );    	//add the user to the usm    	usm.addUser(_securityName, user);
    	// to make sure a different security model is used for each SNMP instance,     	// this is the way to initialize. Otherwise there might be strange behaviours    	// in the case the remote engine id is not unique     	MessageDispatcher disp = snmp.getMessageDispatcher();    	disp.addMessageProcessingModel(new MPv1());    	disp.addMessageProcessingModel(new MPv2c());    	disp.addMessageProcessingModel(new MPv3(usm));    	    	    	snmp.listen();    	    	return snmp;    	}    /**     * Create the SNMP object.     * (working method)     * @return     * @throws IOException     */    protected Snmp initSnmpAndSecurity2( ) throws IOException	{        // create the snmp instance        Snmp snmp = new Snmp(new DefaultUdpTransportMapping());                OctetString localEngineID = new OctetString(MPv3.createLocalEngineID());                // create the USM
 security model        USM usm = new USM(SecurityProtocols.getInstance(), localEngineID, 0);                // create the user for the USM        UsmUser user = new UsmUser(_securityName,                                   _authProtocol,                                   _authPassphrase,                                   _privProtocol,                                   _privPassphrase);                //add the user to the usm        usm.addUser(_securityName, user);
        // create own version of the SecurityModels to avoid multithreading issues        MultiThreadedSecurityModels mtm = new MultiThreadedSecurityModels();        // add the usm as the security model        mtm.addSecurityModel(usm);                    // add the newly create SecurityModels to the MPv3 (overwrite the default)        MessageProcessingModel mpm = snmp.getMessageProcessingModel(MPv3.ID);        if ( mpm instanceof MPv3 )            ((MPv3)mpm).setSecurityModels(mtm);        else            throw new RuntimeException("Received different MessageProcessing model than requested, Should never happen!");        snmp.listen();        return snmp;	}
Thanks again and best regards,
Sjoerd


      


More information about the SNMP4J mailing list