Examples of OctetString


Examples of org.snmp4j.smi.OctetString

  }

  protected void addViews(VacmMIB vacm)
  {
       vacm.addGroup(SecurityModel.SECURITY_MODEL_SNMPv1,
                    new OctetString("public"),
                    new OctetString("v1v2group"),
                    StorageType.nonVolatile);
      vacm.addGroup(SecurityModel.SECURITY_MODEL_SNMPv2c,
                    new OctetString("public"),
                    new OctetString("v1v2group"),
                    StorageType.nonVolatile);
      vacm.addGroup(SecurityModel.SECURITY_MODEL_USM,
                    new OctetString("SHADES"),
                    new OctetString("v3group"),
                    StorageType.nonVolatile);
      vacm.addGroup(SecurityModel.SECURITY_MODEL_USM,
                    new OctetString("TEST"),
                    new OctetString("v3test"),
                    StorageType.nonVolatile);
      vacm.addGroup(SecurityModel.SECURITY_MODEL_USM,
                    new OctetString("SHA"),
                    new OctetString("v3restricted"),
                    StorageType.nonVolatile);

      vacm.addAccess(new OctetString("v1v2group"), new OctetString(),
                     SecurityModel.SECURITY_MODEL_ANY,
                     SecurityLevel.NOAUTH_NOPRIV,
                     MutableVACM.VACM_MATCH_EXACT,
                     new OctetString("fullReadView"),
                     new OctetString("fullWriteView"),
                     new OctetString("fullNotifyView"),
                     StorageType.nonVolatile);
      vacm.addAccess(new OctetString("v3group"), new OctetString(),
                     SecurityModel.SECURITY_MODEL_USM,
                     SecurityLevel.AUTH_PRIV,
                     MutableVACM.VACM_MATCH_EXACT,
                     new OctetString("fullReadView"),
                     new OctetString("fullWriteView"),
                     new OctetString("fullNotifyView"),
                     StorageType.nonVolatile);
      vacm.addAccess(new OctetString("v3restricted"), new OctetString(),
                     SecurityModel.SECURITY_MODEL_USM,
                     SecurityLevel.AUTH_NOPRIV,
                     MutableVACM.VACM_MATCH_EXACT,
                     new OctetString("restrictedReadView"),
                     new OctetString("restrictedWriteView"),
                     new OctetString("restrictedNotifyView"),
                     StorageType.nonVolatile);
      vacm.addAccess(new OctetString("v3test"), new OctetString(),
                     SecurityModel.SECURITY_MODEL_USM,
                     SecurityLevel.AUTH_PRIV,
                     MutableVACM.VACM_MATCH_EXACT,
                     new OctetString("testReadView"),
                     new OctetString("testWriteView"),
                     new OctetString("testNotifyView"),
                     StorageType.nonVolatile);

      vacm.addViewTreeFamily(new OctetString("fullReadView"), new OID("1.3"),
                             new OctetString(), VacmMIB.vacmViewIncluded,
                             StorageType.nonVolatile);
      vacm.addViewTreeFamily(new OctetString("fullWriteView"), new OID("1.3"),
                             new OctetString(), VacmMIB.vacmViewIncluded,
                             StorageType.nonVolatile);
      vacm.addViewTreeFamily(new OctetString("fullNotifyView"), new OID("1.3"),
                             new OctetString(), VacmMIB.vacmViewIncluded,
                             StorageType.nonVolatile);
  }
View Full Code Here

Examples of org.snmp4j.smi.OctetString

              for (int i=oldReceivers.length;i-->0;)
              {
                  if (oldReceivers[i]!=null)
                  {
                    String key = "notification" + oldReceivers[i].getHost();
                      snmpTargetMIB.removeTargetAddress(new OctetString(key));
                  }
              }
          }
         
          if (_trapReceivers!=null)
View Full Code Here

Examples of org.snmp4j.smi.OctetString

  protected void createMO(MOFactory moFactory)
  {
    MOAccess readOnly = moFactory.createAccess(MOAccessImpl.ACCESSIBLE_FOR_READ_ONLY);
    _scalars.add(moFactory.createScalar(OID_MESSAGES_RECEIVED, readOnly, new Counter32()));
    _scalars.add(moFactory.createScalar(OID_MESSAGES_SENT, readOnly, new Counter32()));
    _scalars.add(moFactory.createScalar(OID_SIP_VERSION, readOnly, new OctetString()));
  }
View Full Code Here

Examples of org.snmp4j.smi.OctetString

    {
      int event = Integer.parseInt(notification.getType());
      switch (event)
      {
      case Events.START:
         _agent.getNotificationOriginator().notify(new OctetString(), SnmpConstants.coldStart,
                       new VariableBinding[0]);
        break;
      case Events.DEPLOY_FAIL:
 
        break;
      case Events.CALLS_THRESHOLD_READCHED:
         _agent.getNotificationOriginator().notify(new OctetString(), OID_THRESHOLD_SESSIONS,
                        new VariableBinding[0]);
        break;
      default:
        break;
      }
View Full Code Here

Examples of org.snmp4j.smi.OctetString

                return "0.0";
              }
              OID rowPointer = new OID(JvmManagementMib.oidJvmThreadInstanceEntry);
              rowPointer.append(JvmManagementMib.colJvmThreadInstId);
              String index = Long.toHexString(result.longValue());
              OctetString os = new OctetString();
              os.fromHexString(index);
              rowPointer.append(os.toSubIndex(true));
              return rowPointer.toString();
            }
          }},
          new String[] { "ThreadId" },
          new JMXIndexSupport() {
        public ObjectName mapToRowMBean(Object rowIdentifier) {
          return null;
        }

        public Object getRowIdentifier(Object nativeRowId, int nativeIndex) {
          return nativeRowId;
        }

        public OID mapToIndex(Object rowIdentifier) {
          Long l = (Long)rowIdentifier;
          return OctetString.fromHexString(Long.toHexString(l)).toSubIndex(true);
        }

        public Object mapToRowIdentifier(OID rowIndex) {
          if (rowIndex == null) {
            return null;
          }
          OctetString os = new OctetString();
          os.fromSubIndex(rowIndex, true);
          String hexString = os.toHexString();
          return new Long(Long.parseLong(hexString, 16));
        }
      }));

      ObjectName onameJvmClasses =
View Full Code Here

Examples of org.snmp4j.smi.OctetString

    return OctetString.fromString(buf.toString(), 2).toByteArray();
  }

  public Object transformToNative(Object transformedValue,
                                  Object oldNativeValue, ObjectName objectName) {
    OctetString os = new OctetString((byte[])transformedValue);
    String s = os.toString(2);
    int pos = s.indexOf("1");
    if (pos < 0) {
      return null;
    }
    pos -= offset;
View Full Code Here

Examples of org.snmp4j.smi.OctetString

    return OctetString.fromString(buf.toString(), 2).toByteArray();
  }

  public Object transformToNative(Object transformedValue,
                                  Object oldNativeValue, ObjectName objectName) {
    OctetString os = new OctetString((byte[])transformedValue);
    String s = os.toString(2);
    if (s.length() <= offset) {
      return false;
    }
    return (s.charAt(offset) == '1');
  }
View Full Code Here

Examples of org.snmp4j.smi.OctetString

      /* Assigned Later */
      boolean send_separate_queries = false;
      final HashMap<String,String> oids  = new HashMap<String,String>();
      Target target;
      HashMap<String, ArrayList<oid_data>> oid_hashmap = new HashMap<String, ArrayList<oid_data>>();
      OctetString localEngineID = new OctetString(MPv3.createLocalEngineID());

      if (port == null) {
        port = "161";
      }
      if (version == null) {
        version = "2c";
      }
      if (community == null) {
        community = "public";
      }
      if ((separate_queries != null) && ((separate_queries.equals("on")) || separate_queries.equals("true"))) {
        send_separate_queries = true;
      }

      Address targetAddress = GenericAddress.parse("udp:"+host+"/"+port);

      for (Map.Entry<String, String> entry : config.entrySet())
      {
        String type = entry.getKey();
        if (type.length() > 4) {
          if (type.substring(0, 3).equals("oid")) {
            String type_string;
            String metric_type;
            oid_data data = new oid_data();
            data.name = type.substring(4);
            data.oid = entry.getValue();
            type_string = "type_" + data.name;
            data.metric_type = config.get(type_string);
            oids.put(data.name, data.oid);
            if (oid_hashmap.containsKey(data.oid.substring(1))) {
              ArrayList<oid_data> list = oid_hashmap.remove(data.oid.substring(1));
              list.add(data);
              oid_hashmap.put(data.oid.substring(1), list);
            }
            else {
              ArrayList<oid_data> list = new ArrayList<oid_data>();
              list.add(data);
              oid_hashmap.put(data.oid.substring(1), list);
            }
          }
        }
      }

      UdpAddress udpAddr = new UdpAddress(UdpAddress.ANY_IPADDRESS, 0);
      Snmp snmp = new Snmp(new DefaultUdpTransportMapping(udpAddr));
      /* the snmp connection is open... add a seprate try/catch so we can make sure we close it */
      try {
        if ((version.equals("1")) || (version.equals("2c"))) {
          target = getCommunityTarget(targetAddress, Integer.parseInt(timeout), community, version);
        }
        else {
            OID auth = null;
            OID priv = null;

            if (auth_protocol != null) {
              if (auth_protocol.equals("MD5")) {
                auth = AuthMD5.ID;
              }
              else if (auth_protocol.equals("SHA")) {
                auth = AuthSHA.ID;
              }
            }

            if (privacy_protocol != null) {
              if (privacy_protocol.equals("AES128")) {
                priv = PrivAES128.ID;
              }
              else if (privacy_protocol.equals("AES192")) {
                priv = PrivAES192.ID;
              }
              else if (privacy_protocol.equals("AES256")) {
                priv = PrivAES256.ID;
              }
              else if (privacy_protocol.equals("DES")) {
                priv = PrivDES.ID;
              }
            }

            SecurityProtocols sec = SecurityProtocols.getInstance();
            ((MPv3)snmp.getMessageProcessingModel(MPv3.ID)).setLocalEngineID(localEngineID.getValue());
            USM usm = new USM(sec, localEngineID, 0);
            SecurityModels.getInstance().addSecurityModel(usm);
            UsmUser user = new UsmUser(new OctetString(security_name),
                                           auth,
                                           new OctetString(auth_passphrase),
                                           priv,
                                           new OctetString(privacy_passphrase));
            snmp.getUSM().addUser(user);
            SecurityModels.getInstance().addSecurityModel(new TSM(localEngineID, false));
            target = getUserTarget(targetAddress, Integer.parseInt(timeout), security_level, security_name, security_engine);
        }
        snmp.listen();
View Full Code Here

Examples of org.snmp4j.smi.OctetString

    }
    return null;
  }
  private Target getCommunityTarget (Address address, int timeout, String community, String version) {
    CommunityTarget target = new CommunityTarget();
    target.setCommunity(new OctetString(community));
    target.setAddress(address);
    target.setRetries(0);
    target.setTimeout(timeout/2);
    if (version.equals("1")) {
      target.setVersion(SnmpConstants.version1);
View Full Code Here

Examples of org.snmp4j.smi.OctetString

      target.setSecurityLevel(SecurityLevel.AUTH_NOPRIV);
    }
    else {
      target.setSecurityLevel(SecurityLevel.NOAUTH_NOPRIV);
    }
    target.setSecurityName(new OctetString(securityName));
    if (securityEngine != null) {
      target.setAuthoritativeEngineID(OctetString.fromHexStringPairs(securityEngine).getValue());
    }

    target.setVersion(SnmpConstants.version3);
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.