Java Dynamic Management Kit 5.0 Tutorial

Proxy Creation in SNMPv3 Master Agents

In the SNMPv3 master agent example, proxy registration is identical to standard MIB registration. The proxies are created as shown in the following example.

Example 21–3 Proxy Creation in the MasterAgentV3 Example


		 // First we need to create a peer to the distant SNMPv3 sub 
	    // agent
	    final SnmpUsmPeer peer = 
		 new SnmpUsmPeer(snmpAdaptor.getEngine(),
	    host, Integer.parseInt(port));

	    // Forward the requests.
	    final SnmpUsmParameters p = 
		new SnmpUsmParameters(snmpAdaptor.getEngine(), 
	    final SnmpUsmProxy proxy = 
		 new SnmpUsmProxy(snmpAdaptor.getEngine(),
				 peer, "");

	    // A SnmpUsmProxy is also an MBean. Register it in the 
	    // MBeanServer.
	    proxyObjName= new ObjectName("snmp:class=SnmpUsmProxy");
	    server.registerMBean(proxy, proxyObjName);


To instantiate and register the proxy, the MasterAgentV3 example first of all creates a peer to the subagent using new SnmpUsmPeer(), and creates SNMPv3 security parameters p using the SnmpUsmParameters() method. These new security parameters are then passed to the peer using peer.setParams, thus translating all requests that come through the peer into SNMPv3 requests.

Finally, MasterAgent creates the proxy, passing it the following information: