Package org.snmp4j.smi

Examples of org.snmp4j.smi.OctetString


   * @param communityMIB the SnmpCommunityMIB holding coexistence
   *   configuration for community based security models.
   */
  protected void addCommunities(SnmpCommunityMIB communityMIB) {
    Variable[] com2sec = new Variable[] {
        new OctetString("public"),              // community name
        new OctetString("cpublic"),              // security name
        getAgent().getContextEngineID(),        // local engine ID
        new OctetString(),              // default context name
        new OctetString(),                      // transport tag
        new Integer32(StorageType.nonVolatile), // storage type
        new Integer32(RowStatus.active)         // row status
    };
    MOTableRow row =
        communityMIB.getSnmpCommunityEntry().createRow(
          new OctetString("public2public").toSubIndex(true), com2sec);
    communityMIB.getSnmpCommunityEntry().addRow(row);
  }
View Full Code Here


   * @param vacm
   *    the VacmMIB holding the agent's view configuration.
   */
  protected void addViews(VacmMIB vacm) {
    vacm.addGroup(SecurityModel.SECURITY_MODEL_SNMPv1,
                  new OctetString("cpublic"),
                  new OctetString("v1v2group"),
                  StorageType.nonVolatile);
    vacm.addGroup(SecurityModel.SECURITY_MODEL_SNMPv2c,
                  new OctetString("cpublic"),
                  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.addGroup(SecurityModel.SECURITY_MODEL_USM,
                  new OctetString("v3notify"),
                  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.NOAUTH_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);

    vacm.addViewTreeFamily(new OctetString("restrictedReadView"),
                           new OID("1.3.6.1.2"),
                           new OctetString(), VacmMIB.vacmViewIncluded,
                           StorageType.nonVolatile);
    vacm.addViewTreeFamily(new OctetString("restrictedWriteView"),
                           new OID("1.3.6.1.2.1"),
                           new OctetString(),
                           VacmMIB.vacmViewIncluded,
                           StorageType.nonVolatile);
    vacm.addViewTreeFamily(new OctetString("restrictedNotifyView"),
                           new OID("1.3.6.1.2"),
                           new OctetString(), VacmMIB.vacmViewIncluded,
                           StorageType.nonVolatile);
    vacm.addViewTreeFamily(new OctetString("restrictedNotifyView"),
                           new OID("1.3.6.1.6.3.1"),
                           new OctetString(), VacmMIB.vacmViewIncluded,
                           StorageType.nonVolatile);

    vacm.addViewTreeFamily(new OctetString("testReadView"),
                           new OID("1.3.6.1.2"),
                           new OctetString(), VacmMIB.vacmViewIncluded,
                           StorageType.nonVolatile);
    vacm.addViewTreeFamily(new OctetString("testReadView"),
                           new OID("1.3.6.1.2.1.1"),
                           new OctetString(), VacmMIB.vacmViewExcluded,
                           StorageType.nonVolatile);
    vacm.addViewTreeFamily(new OctetString("testWriteView"),
                           new OID("1.3.6.1.2.1"),
                           new OctetString(),
                           VacmMIB.vacmViewIncluded,
                           StorageType.nonVolatile);
    vacm.addViewTreeFamily(new OctetString("testNotifyView"),
                           new OID("1.3.6.1.2"),
                           new OctetString(), VacmMIB.vacmViewIncluded,
                           StorageType.nonVolatile);

  }
View Full Code Here

      ObjectInputStream ois = new ObjectInputStream(fis);
      List l = (List) ois.readObject();
      ois.close();
      logger.info("Snapshot file '"+snapshot+
                  "' contains "+l.size()+" objects.");
      OctetString ctx = new OctetString();
      SortedMap roots = new TreeMap();
      OID last = null;
      for (Iterator it = l.iterator(); it.hasNext(); ) {
        VariableBinding vb = (VariableBinding) it.next();
        if (last != null) {
View Full Code Here

                            snapshot);
      testAgent1.address = address;
      testAgent1.init();
      testAgent1.loadConfig(ImportModes.REPLACE_CREATE);
      testAgent1.addShutdownHook();
      testAgent1.getServer().addContext(new OctetString("public"));
      testAgent1.finishInit();
      testAgent1.run();
      testAgent1.sendColdStartNotification();
      while (true) {
        try {
View Full Code Here

   * @since 1.1
   */
  public static final boolean isContextMatching(MOScope a, MOScope b) {
    if ((a instanceof MOContextScope) &&
        (b instanceof MOContextScope)) {
      OctetString ca = ((MOContextScope)a).getContext();
      OctetString cb = ((MOContextScope)b).getContext();
      if ((ca != null) && (!ca.equals(cb))) {
        return false;
      }
    }
    return true;
View Full Code Here

        Entry entry = (Entry) it.next();
        MOScope scope = (MOScope) entry.getKey();
        ManagedObject value = (ManagedObject) entry.getValue();
        if ((value instanceof SerializableManagedObject) &&
            (!((SerializableManagedObject) value).isVolatile())) {
          OctetString context = null;
          if (scope instanceof MOContextScope) {
            context = ((MOContextScope) scope).getContext();
          }
          LinkedHashMap objects = (LinkedHashMap) serializableMO.get(context);
          if (objects == null) {
View Full Code Here

    else {
      MOScope s1 = (MOScope) o1;
      MOScope s2 = (MOScope) o2;
      if ((s1 instanceof MOContextScope) &&
          (s2 instanceof MOContextScope)) {
        OctetString c1 = ((MOContextScope) s1).getContext();
        OctetString c2 = ((MOContextScope) s2).getContext();
        if ((c1 != null) && (c2 != null)) {
          result = c1.compareTo(c2);
        }
      }
      if (result == 0) {
View Full Code Here

  }

  private static int compareScopeAndQuery(MOScope scope, MOQuery query) {
    int result = 0;
    if (scope instanceof MOContextScope) {
      OctetString c1 = ((MOContextScope)scope).getContext();
      OctetString c2 = query.getScope().getContext();
      if ((c1 != null) && (c2 != null)) {
        result = c1.compareTo(c2);
      }
    }
    if (result != 0) {
View Full Code Here

   *    if it is.
   */
  public static int validateDisplayString(Variable displayString,
                                          ValueConstraint sizeContraints) {
    if (displayString instanceof OctetString) {
      OctetString os = (OctetString)displayString;
      int status = sizeContraints.validate(displayString);
      if (status != PDU.noError) {
        return status;
      }
      for (int i=0; i<os.length(); i++) {
        if (os.get(i) < 0) {
          return SnmpConstants.SNMP_ERROR_WRONG_VALUE;
        }
        if (os.get(i) == '\r') {
          if (i+1 == os.length()) {
            return SnmpConstants.SNMP_ERROR_WRONG_VALUE;
          }
          else if ((os.get(i+1) != 0) && (os.get(i+1) != '\n')) {
            return SnmpConstants.SNMP_ERROR_WRONG_VALUE;
          }
        }
      }
      return SnmpConstants.SNMP_ERROR_SUCCESS;
View Full Code Here

  public static int isValidTagValue(Variable newValue) {
    if (!(newValue instanceof OctetString)) {
      return SnmpConstants.SNMP_ERROR_WRONG_TYPE;
    }
    int status = SnmpConstants.SNMP_ERROR_SUCCESS;
    OctetString os = (OctetString)newValue;
    if (os.length() > 255) {
      status = SnmpConstants.SNMP_ERROR_WRONG_LENGTH;
    }
    else {
      for (int i = 0; i < os.length(); i++) {
        if (isDelimiter(os.get(i))) {
          status = SnmpConstants.SNMP_ERROR_BAD_VALUE;
          break;
        }
      }
    }
View Full Code Here

TOP

Related Classes of org.snmp4j.smi.OctetString

Copyright © 2018 www.massapicom. 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.