snmp4j - configure access

33 views Asked by At

I'm trying to configure an agent (snmpv3) built with agenpro for snmp4j 3.7.7 and snmp4j-agent 3.6.5.

Currently my main is like this:

[...]
 private static void defaultMain(String args[]) {
        ArgumentParser parser = new ArgumentParser(DEFAULT_CL_PARAMETERS, DEFAULT_CL_COMMANDS);
        Map<String, List<Object>> commandLineParameters = null;
        try {
            commandLineParameters = parser.parse(args);
            Agent agent = new Agent(commandLineParameters);
            // Add all available security protocols (e.g. SHA,MD5,DES,AES,3DES,..)
            SecurityProtocols.getInstance().addDefaultProtocols();

            // configure system group:
            // Set system description:
            agent.agent.getSysDescr().setValue("DDS- BaseMIB".getBytes());
            // Set system OID (= OID of the AGENT-CAPABILITIES statement describing
            // the implemented MIB objects of this agent:
            // sampleAgent.agent.getSysOID().setValue("1.3.1.6.1.4.1....");
            // Set the system services
            // sampleAgent.agent.getSysServices().setValue(72);+



            agent.run();
            // Fire a sample named trap generated by AgenPro:
            // agent.modules.getIfMib().fireLinkDownIf10001(agent.server,
            //   agent.agent.getNotificationOriginator(), null, null);




                // building a user - authenticated
            UsmUser user = new UsmUser(new OctetString("utente"), AuthSHA.ID, new OctetString("authpw"), PrivAES128.ID, new OctetString("privpw"));
            
            agent.agent.getUsm().addUser(user);


            user = new UsmUser(new OctetString("unsecureUser"), null, null, null, null);
            agent.agent.getUsm().addUser(user);

            
            VacmMIB vacmMIB = agent.agent.getVacmMIB();

        // building a new group
            vacmMIB.addGroup(SecurityModel.SECURITY_MODEL_USM,new OctetString("other"),new OctetString("gruppo"), StorageType.readOnly );

            // giving the available views for the specific group
            vacmMIB.addAccess(new OctetString("gruppo"),new OctetString("other"), SecurityModel.SECURITY_MODEL_USM,SecurityLevel.NOAUTH_NOPRIV,VacmMIB.vacmPrefixMatch,new OctetString("readView"),new OctetString("writeView"),new OctetString("notifyView"),StorageType.nonVolatile);


           //creating the actual views
            vacmMIB.addViewTreeFamily(new OctetString("readView"), new OID("1.3.6.1.4.1.433.500"), new OctetString("0xFFFFFFFF"),VacmMIB.vacmViewIncluded,StorageType.permanent );
            vacmMIB.addViewTreeFamily(new OctetString("writeView"), new OID("1.3.6.1.4.1.433.500"), new OctetString("0xFFFFFFFF"),VacmMIB.vacmViewIncluded,StorageType.permanent );
            vacmMIB.addViewTreeFamily(new OctetString("notifyView"), new OID("1.3.6.1.4.1.433.500"), new OctetString("0xFFFFFFFF"),VacmMIB.vacmViewIncluded,StorageType.permanent );

        } catch (ParseException ex) {
            System.err.println(ex.getMessage());
        }
    }

 public static void main(String[] args) {
        // |:AgenPro|=main
        defaultMain(args);
        // |AgenPro:|
    }

Now if I try to do a "get" from an outside mib browser (from both unsecureUser or utente) the log I got is this:

Dispatching message canceled due to security issue: statusInfo=noError, status=-1406,tmStateReference=TransportStateReference[transport=org.snmp4j.transport.DefaultUdpTransportMapping@6c3708b3, address=0.0.0.0/16100, securityName=null, requestedSecurityLevel=undefined, transportSecurityLevel=undefined, sameSecurity=false, sessionID=java.net.DatagramSocket@51bdcc0a, target=null]

and the manager goes timeout

0

There are 0 answers