Package org.snmp4j

Examples of org.snmp4j.UserTarget


      target.setVersion(SnmpConstants.version2c);
    }
    return target;
  }
  private Target getUserTarget (Address address, int timeout, String securityLevel, String securityName, String securityEngine) {
    UserTarget target = new UserTarget();
    if (securityLevel.equals("authPriv")) {
      target.setSecurityLevel(SecurityLevel.AUTH_PRIV);
    }
    else if (securityLevel.equals("authNoPriv")) {
      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);
    target.setAddress(address);
    target.setRetries(0);
    target.setTimeout(timeout/2);
    return target;
  }
View Full Code Here


        return snmp;
    }

    private Target createTarget() {
        if (version == SnmpConstants.version3) {
            UserTarget target = new UserTarget();
            if (authPassphrase != null) {
                if (privPassphrase != null) {
                    target.setSecurityLevel(SecurityLevel.AUTH_PRIV);
                } else {
                    target.setSecurityLevel(SecurityLevel.AUTH_NOPRIV);
                }
            } else {
                target.setSecurityLevel(SecurityLevel.NOAUTH_NOPRIV);
            }

            target.setSecurityName(securityName);
            return target;
        } else {
            CommunityTarget target = new CommunityTarget();
            target.setCommunity(community);
            return target;
        }
    }
View Full Code Here

      t = new CommunityTarget();
      t.setVersion(SnmpConstants.version2c);
      ((CommunityTarget)t).setCommunity(community);
    }
    else {
      UserTarget ut = new UserTarget();
      t = ut;
      String ae = (String)
          ArgumentParser.getValue(settings, oAuthoritativeEngineID, 0);
      if (ae != null) {
        ut.setAuthoritativeEngineID(createOctetString(ae, null).getValue());
      }
      ut.setSecurityModel(USM.SECURITY_MODEL_USM);
      String sn = (String)
          ArgumentParser.getValue(settings, oSecurityName, 0);
      if (sn != null) {
        ut.setSecurityName(createOctetString(sn, null));
      }
      Integer secLevel =
          (Integer) ArgumentParser.getValue(settings, oSecLevel, 0);
      if (secLevel == null) {
        if (settings.containsKey(oPrivPassphrase)) {
          ut.setSecurityLevel(SecurityLevel.AUTH_PRIV);
        }
        else if (settings.containsKey(oAuthPassphrase)) {
          ut.setSecurityLevel(SecurityLevel.AUTH_NOPRIV);
        }
        else {
          ut.setSecurityLevel(SecurityLevel.NOAUTH_NOPRIV);
        }
      }
      else {
        ut.setSecurityLevel(secLevel.intValue());
      }
    }
    int retries = 0;
    Number r = (Number) ArgumentParser.getValue(settings, oRetries, 0);
    if (r != null) {
View Full Code Here

  /** @see org.chiefly.sunlamp.AbstractSNMP#createVersionSpecificTarget() */
  @Override
  protected Target createVersionSpecificTarget() {

    final UserTarget target = new UserTarget();
    target.setVersion(SnmpConstants.version3);
    target.setSecurityLevel(this.determineSecurityLevel());
    target.setSecurityModel(SecurityModel.SECURITY_MODEL_USM);
    target.setSecurityName(this.user.getSecurityName());
    return target;
  }
View Full Code Here

TOP

Related Classes of org.snmp4j.UserTarget

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.