You need to learn more about USM and VACM. I recommend "SNMP, SNMPv2, SNMPv3 
and RMON 1 and 2" by William Stallings.

Implementing the CommandResponder is not the usual way to do this.
You need to read the SNMP4J How-To document in the AgentPro download.
It explains how to implement your ManagedObjects to interact with the rest of 
SNMP4J and SNMP4J-Agent.
I wish that precious document was mentioned on the snmp4j.org site.

The sample code to populate the USM and VACM mibs programmatically is in the 
TestAgent.java file in the SNMP4J-Agent source code.
Notice the TestAgent is an older way of organizing your agent. Also take a look 
at AgentConfigManager.java as another option.
When I first learned about this, I had my users configured correctly but the 
VACM view was missing and therefore nothing came back.


From: Ivan Mladenović [mailto:[email protected]]
Sent: Monday, January 18, 2010 9:49 AM
To: Pellerin, Clement
Subject: Re: [SNMP4J] Question about SNMPv3 configuration

Hi, thank you for answer.
But, I don't understand. Sorry, I don't have experience with SNMP.

I will try to explain my problem.

I have my own MIB file, like this:

IMPORTS
        mib-2
            FROM RFC1213-MIB;

myObjectId OBJECT IDENTIFIER ::= {private 1} -- 1.3.6.1.4.1

myObject OBJECT-TYPE
        SYNTAX Counter
        ACCESS read-write
        STATUS mandatory
        ::= {myObjectId 1}

I have my implementation of CommandResponder interface.
I'm trying to use MIB browser to get value for this object id.
My implementation of CommandResponder will catch GET request operation in 
processPdu() method.

But I don't now how to send response to the MIB browser. I don't have any 
errors in my response, and there is no errors in response, but 
response.getResponse() is null.
>From some MIB browsers I get "PrivProtocol or PrivPassword may be wrong" or 
>something like "SNMPv3 parameters are not right".
I want to use SNMPv3 for this.

Could you give link to some code examples or could you give me some peace of 
code about adding user to a user group?



2010/1/15 <[email protected]<mailto:[email protected]>>
Did you add that user to a userGroup and assign a VACM view to that userGroup?
Take a look at org.snmp4j.agent.test.TestAgent
Also make sure your client talks SNMPv3 and not SNMPv1 by default.

-----Original Message-----
From: [email protected]<mailto:[email protected]> 
[mailto:[email protected]<mailto:[email protected]>] On 
Behalf Of Ivan Mladenovic
Sent: Friday, January 15, 2010 4:06 AM
To: [email protected]<mailto:[email protected]>
Subject: [SNMP4J] Question about SNMPv3 configuration

Hi, I'm using snmp4j to

My configuration file for SNMPv3 is:

     snmp.user.name<http://snmp.user.name>=userName
  snmp.auth.passphrase=m5_encrypted_passphrase
  snmp.privacy.passphrase=des_encrypted_passphrase
  snmp.auth.protocol=MD5
  snmp.privacy.protocol=DES
  snmp.security.level=3 # Security level: AUTH_PRIV
  snmp.security.model=3 # SecurityModel.SECURITY_MODEL_USM

I have class that implements CommandResponder. In consturctor:

     transport = new DefaultUdpTransportMapping(new
UdpAddress("localhost/161"));
   snmp = new Snmp(transport);
   snmp.addCommandResponder(this);

   // Security protocol.
   SecurityProtocols securityProtocols = SecurityProtocols.getInstance();
   securityProtocols.addAuthenticationProtocol(new AuthMD5());

       byte[] localEngineID = MPv3.createLocalEngineID();
   USM usm = new USM(securityProtocols, new OctetString(localEngineID), 0);
   SecurityModels.getInstance().addSecurityModel(usm);
   snmp.setLocalEngine(localEngineID, 0, 0);
   UsmUser usmUser = new UsmUser(userName, authProtocol, authPassphrase,
privacyProtocol, privacyPassphrase);

   usm.addUser(snmpConfiguration.getUserName(), usmUser);

   // Listen for requests.
   transport.listen();

This class implements processPDU method:

    // Get object identifier.
   Vector<VariableBinding> variableBindings =
event.getPDU().getVariableBindings();
   VariableBinding variableBinding = variableBindings.get(0);
   OID oid = variableBinding.getOid();

   Variable variable = new Counter32(someLongValue);
   variableBinding.setVariable(variable);

   PDU pdu = event.getPDU();
   pdu.clear();
   pdu.setErrorStatus(0);
   pdu.add(variableBinding);

   event.setPDU(pdu);
   event.setProcessed(true);

   try {
       byte[] engineID = MPv3.createLocalEngineID();

       UserTarget target = new UserTarget();
       target.setAddress(event.getPeerAddress());
       target.setRetries(retriesCount);
       target.setTimeout(timeout);
       target.setVersion(SnmpConstants.version3);
       target.setSecurityName(userName);
       target.setSecurityLevel(SecurityLevel.AUTH_PRIV);
       target.setSecurityModel(SecurityModel.SECURITY_MODEL_USM);
       target.setAuthoritativeEngineID(engineID);

       ResponseEvent responseEvent = snmp.send(event.getPDU(), target);
   } catch (IOException e) {
       e.printStackTrace();
   }

Method processPDU catch GET request event, and response does not contains
errors, but MIB browser always get timeout exception.

Do I have some errors in configuration?
Could you, please, give me some example?
_______________________________________________
SNMP4J mailing list
[email protected]<mailto:[email protected]>
http://lists.agentpp.org/mailman/listinfo/snmp4j

_______________________________________________
SNMP4J mailing list
[email protected]
http://lists.agentpp.org/mailman/listinfo/snmp4j

Reply via email to