Refine search
CommunityTarget target = new CommunityTarget(); PDUv1 pdu1 = new PDUv1(); transMap.listen(); target.setCommunity( new OctetString( community ) ); target.setVersion( SnmpConstants.version1 ); target.setAddress( udpAddress ); if ( target.getAddress().isValid() ) { if ( log.isDebug() ) { logDebug( "Valid IP address" ); throw new KettleException( "Invalid IP address" ); target.setRetries( retry ); target.setTimeout( timeOut ); pdu1.setSpecificTrap( PDUv1.ENTERPRISE_SPECIFIC ); pdu1.setEnterprise( new OID( Oid ) ); pdu1.add( new VariableBinding( new OID( Oid ), new OctetString( messageString ) ) );
final String authProtocol = context.getProperty(SNMP_AUTH_PROTOCOL).getValue(); final String privProtocol = context.getProperty(SNMP_PRIV_PROTOCOL).getValue(); OctetString aPwd = authPassword != null ? new OctetString(authPassword) : null; OctetString pPwd = privPassword != null ? new OctetString(privPassword) : null; this.snmp.getUSM().addUser(new OctetString(username), new UsmUser(new OctetString(username), SNMPUtils.getAuth(authProtocol), aPwd, SNMPUtils.getPriv(privProtocol), pPwd)); result = new CommunityTarget(); String community = context.getProperty(SNMP_COMMUNITY).getValue(); if(community != null) { ((CommunityTarget) result).setCommunity(new OctetString(community));
public SnmpHelper(String address, String community) { _target = new CommunityTarget(); _target.setCommunity(new OctetString(community)); _target.setVersion(SnmpConstants.version2c); _target.setAddress(new UdpAddress(address)); try { _snmp = new Snmp(new DefaultUdpTransportMapping()); } catch (IOException e) { _snmp = null; throw new CloudRuntimeException(" Error in crearting snmp object, " + e.getMessage()); } }
private Target makeSnmpTarget(HttpServletRequest request) throws UnknownHostException { String hostname = request.getParameter("host"); String community = request.getParameter("discoverSnmpCommunity"); if(community == null) { community = "public"; } int port = jrds.Util.parseStringNumber(request.getParameter("discoverSnmpPort"), 161); IpAddress addr = new UdpAddress(InetAddress.getByName(hostname), port); Target hosttarget = new CommunityTarget(addr, new OctetString(community)); hosttarget.setVersion(SnmpConstants.version2c); return hosttarget; }
private Target createTarget(OctetString userInfo) { if ((userInfo == null) || (userInfo.length() == 0)) { return defaultTarget; CommunityTarget target = new CommunityTarget(); target.setCommunity(userInfo); target.setVersion(version); target.setSecurityModel(securityModel); target.setTimeout(timeout); target.setRetries(retries); return target;
private Target createTarget(Profile profile) { Target target; if (profile.version == SnmpConstants.version2c) { target = new CommunityTarget(); ((CommunityTarget) target).setCommunity(profile.community); } else { target = new UserTarget(); ((UserTarget) target).setAuthoritativeEngineID(profile.engineId.getValue()); target.setSecurityName(profile.username); target.setSecurityLevel(profile.securityLevel); } target.setVersion(profile.version); return target; }
Target t; if ("1".equals(version)) { t = new CommunityTarget(); t.setVersion(SnmpConstants.version1); ((CommunityTarget) t).setCommunity(community); } else if ("2c".equals(version)) { t = new CommunityTarget(); t.setVersion(SnmpConstants.version2c); ((CommunityTarget) t).setCommunity(community); } else if (((securityModel != null) && (securityModel == SecurityModel.SECURITY_MODEL_TSM)) || ((securityModel == null) && (getTlsProperties(settings).size() > 1))) { String sn = (String) ArgumentParser.getValue(settings, oSecurityName, 0); CertifiedTarget ct = new CertifiedTarget(new OctetString(sn)); ct.setSecurityModel(SecurityModel.SECURITY_MODEL_TSM); setSecurityLevelOnTarget(settings, ct); ArgumentParser.getValue(settings, oAuthoritativeEngineID, 0); if (ae != null) { ut.setAuthoritativeEngineID(createOctetString(ae, null).getValue());
public Target createTarget () { switch ( this.connectionInformation.getVersion () ) { case V1: if ( this.connectionInformation.getCommunity () != null ) { final CommunityTarget target = new CommunityTarget ( this.address, new OctetString ( this.connectionInformation.getCommunity () ) ); target.setRetries ( this.connectionInformation.getRetries () ); target.setVersion ( SnmpConstants.version1 ); target.setTimeout ( this.connectionInformation.getTimeout () ); return target; } break; case V2C: if ( this.connectionInformation.getCommunity () != null ) { final CommunityTarget target = new CommunityTarget ( this.address, new OctetString ( this.connectionInformation.getCommunity () ) ); target.setRetries ( this.connectionInformation.getRetries () ); target.setVersion ( SnmpConstants.version2c ); target.setTimeout ( this.connectionInformation.getTimeout () ); return target; } break; case V3: return null; } return null; }
public PDU getPDUFromRequest(byte[] bytes) throws IOException { OctetString octetString = new OctetString(bytes); ByteBuffer buff = ByteBuffer.wrap(octetString.getValue()); version.decodeBER(wholeMsg); OctetString securityName = new OctetString(); securityName.decodeBER(wholeMsg); CommunityTarget target = new CommunityTarget(); target.setVersion(SnmpConstants.version2c);
private Target getTarget(String communityString) { if(version == V1 || version == V2C) { Address address = GenericAddress.parse("udp:" + ip + "/" + port); CommunityTarget target = new CommunityTarget(address, new OctetString(communityString)); target.setVersion(version); return target; } throw new RuntimeException("Snmpv3 is not supported"); } }
switch (mpModel.getValue()) { case MessageProcessingModel.MPv1: { t = new CommunityTarget(address, community); PDUv1 trap = new PDUv1(); pdu = trap; t = new CommunityTarget(address, community); pdu = new PDU(); break; ? PDU.V1TRAP : PDU.TRAP); try { OctetString localEngineID = new OctetString(); OctetString contextEngineID = new OctetString(); if (pdu instanceof ScopedPDU) { localEngineID.setValue(targetMIB.getLocalEngineID()); contextEngineID = ((ScopedPDU)pdu).getContextEngineID();
private Target createCommunityTarget() { CommunityTarget target = new CommunityTarget(); target.setCommunity(getReadCommunity()); return target; }
OctetString addrParams = (OctetString) getValue(idxSnmpTargetAddrParams); OID paramsIndex = addrParams.toSubIndex(true); MOTableRow paramsRow = snmpTargetParamsEntryModel.getRow(paramsIndex); if (paramsRow == null) { (OctetString) paramsRow.getValue(idxSnmpTargetParamsSecurityName), contextEngineID.getValue(), paramsRow.getValue(idxSnmpTargetParamsSecurityLevel). toInt()); t = new CommunityTarget(addr, community);
/** * Creates a fully specified communtity target. * @param address * the transport <code>Address</code> of the target. * @param community * the community to be used for the target. */ public CommunityTarget(Address address, OctetString community) { super(address); setVersion(SnmpConstants.version1); setCommunity(community); }
UdpAddress targetAddress = new UdpAddress("127.0.0.1/1985"); CommunityTarget target = new CommunityTarget(); //...Whatever target.setAddress(targetAddress);
/** * Default constructor. */ public CommunityTarget() { setVersion(SnmpConstants.version1); setSecurityLevel(SecurityLevel.NOAUTH_NOPRIV); setSecurityModel(SecurityModel.SECURITY_MODEL_SNMPv1); }
import org.snmp4j.*; import org.snmp4j.event.*; ... CommunityTarget target = new CommunityTarget(); target.setCommunity(new OctetString("public")); target.setAddress(targetAddress); target.setVersion(SnmpConstants.version2c); PDU request = new PDU(); request.setType(PDU.V2TRAP); request.setGenericTrap(PDUv2.COLDSTART); Snmp snmp = new Snmp(new DefaultUdpTransportMapping()); snmp.listen(); snmp.sendPDU(request, target, null, listener);
/** * Default constructor. */ public CommunityTarget() { setVersion(SnmpConstants.version1); }
public static void main(String[] args) throws Exception { // Create PDU PDU trap = new PDU(); trap.setType(PDU.TRAP); OID oid = new OID("1.2.3.4.5"); trap.add(new VariableBinding(SnmpConstants.snmpTrapOID, oid)); trap.add(new VariableBinding(SnmpConstants.sysUpTime, new TimeTicks(5000))); // put your uptime here trap.add(new VariableBinding(SnmpConstants.sysDescr, new OctetString("System Description"))); //Add Payload Variable var = new OctetString("some string"); trap.add(new VariableBinding(oid, var)); // Specify receiver Address targetaddress = new UdpAddress("10.101.21.32/162"); CommunityTarget target = new CommunityTarget(); target.setCommunity(new OctetString("public")); target.setVersion(SnmpConstants.version2c); target.setAddress(targetaddress); // Send Snmp snmp = new Snmp(new DefaultUdpTransportMapping()); snmp.send(trap, target, null, null); }
CommunityTarget target = new CommunityTarget(); target.setCommunity(new OctetString("public")); new OctetString("MD5DES"), new UsmUser(new OctetString("saikrishna"), AuthMD5.ID, new OctetString("saikrishnapassword"), PrivDES.ID, new OctetString("PasswordUser")));