/** * Creates a MPv3 with a supplied local engine ID. * @param localEngineID * the local engine ID. Its length must be greater or equal than 5 and less or equal than 32. */ public MPv3(byte[] localEngineID) { this(localEngineID, null); setLocalEngineID(localEngineID); }
/** * Creates a MPv3 with a supplied local engine ID. * @param localEngineID * the local engine ID. Its length must be >= 5 and <= 32. */ public MPv3(byte[] localEngineID) { this(localEngineID, null); setLocalEngineID(localEngineID); }
/** * Creates a MPv3 with a supplied local engine ID. * @param localEngineID * the local engine ID. Its length must be greater or equal than 5 and less or equal than 32. */ public MPv3(byte[] localEngineID) { this(localEngineID, null); setLocalEngineID(localEngineID); }
setLocalEngineID(localEngineID);
/** * Sets the local engine ID for the SNMP entity represented by this * <code>Snmp</code> instance. This is a convenience method that sets * the local engine ID in the associated <code>MPv3</code> and * <code>USM</code>. * @param engineID * a byte array containing the local engine ID. The length and content * has to comply with the constraints defined in the SNMP-FRAMEWORK-MIB. * @param engineBoots * the number of boots of this SNMP engine (zero based). * @param engineTime * the number of seconds since the value of engineBoots last changed. * @see MPv3 * @see USM */ public void setLocalEngine(byte[] engineID, int engineBoots, int engineTime) { MPv3 mpv3 = getMPv3(); mpv3.setLocalEngineID(engineID); USM usm = (USM) mpv3.getSecurityModel(SecurityModel.SECURITY_MODEL_USM); usm.setLocalEngine(new OctetString(engineID), engineBoots, engineTime); }
setLocalEngineID(localEngineID); SecurityModel usm = secModels.getSecurityModel(new Integer32(USM.SECURITY_MODEL_USM)); if (usm instanceof USM) {
setLocalEngineID(localEngineID); SecurityModel usm = secModels.getSecurityModel(new Integer32(USM.SECURITY_MODEL_USM)); if (usm instanceof USM) {
/** * Sets the local engine ID for the SNMP entity represented by this * <code>Snmp</code> instance. This is a convenience method that sets * the local engine ID in the associated <code>MPv3</code> and * <code>USM</code>. * * @param engineID * a byte array containing the local engine ID. The length and content * has to comply with the constraints defined in the SNMP-FRAMEWORK-MIB. * @param engineBoots * the number of boots of this SNMP engine (zero based). * @param engineTime * the number of seconds since the value of engineBoots last changed. * * @see MPv3 * @see USM */ @Override public void setLocalEngine(byte[] engineID, int engineBoots, int engineTime) { MPv3 mpv3 = getMPv3(); mpv3.setLocalEngineID(engineID); mpv3.setCurrentMsgID(MPv3.randomMsgID(engineBoots)); USM usm = (USM) mpv3.getSecurityModel(SecurityModel.SECURITY_MODEL_USM); if (usm != null) { usm.setLocalEngine(new OctetString(engineID), engineBoots, engineTime); } }
/** * Sets the local engine ID for the SNMP entity represented by this * <code>Snmp</code> instance. This is a convenience method that sets * the local engine ID in the associated <code>MPv3</code> and * <code>USM</code>. * @param engineID * a byte array containing the local engine ID. The length and content * has to comply with the constraints defined in the SNMP-FRAMEWORK-MIB. * @param engineBoots * the number of boots of this SNMP engine (zero based). * @param engineTime * the number of seconds since the value of engineBoots last changed. * @see MPv3 * @see USM */ public void setLocalEngine(byte[] engineID, int engineBoots, int engineTime) { MPv3 mpv3 = getMPv3(); mpv3.setLocalEngineID(engineID); mpv3.setCurrentMsgID(MPv3.randomMsgID(engineBoots)); USM usm = (USM) mpv3.getSecurityModel(SecurityModel.SECURITY_MODEL_USM); usm.setLocalEngine(new OctetString(engineID), engineBoots, engineTime); }
((MPv3) snmp.getMessageProcessingModel(MPv3.ID)).setLocalEngineID(new OctetString(MPv3.createLocalEngineID()).getValue());
MessageDispatcher dispatcher = messageDispatcherFactory.createMessageDispatcherMapping(); Snmp snmp = new Snmp(dispatcher, transport); ((MPv3) snmp.getMessageProcessingModel(MPv3.ID)).setLocalEngineID(new OctetString(MPv3.createLocalEngineID()).getValue());
private Snmp createSnmpSession() throws IOException { AbstractTransportMapping transport; if (address instanceof TcpAddress) { transport = new DefaultTcpTransportMapping(); } else { transport = new DefaultUdpTransportMapping(); } // Could save some CPU cycles: // transport.setAsyncMsgProcessingSupported(false); Snmp snmp = new Snmp(transport); ((MPv3)snmp.getMessageProcessingModel(MPv3.ID)). setLocalEngineID(localEngineID.getValue()); if (version == SnmpConstants.version3) { USM usm = new USM(SecurityProtocols.getInstance(), localEngineID, engineBootCount); SecurityModels.getInstance().addSecurityModel(usm); addUsmUser(snmp); } return snmp; }
private org.snmp4j.Snmp createSnmp3(Profile profile) { try { TransportMapping<?> transport = new DefaultUdpTransportMapping(); org.snmp4j.Snmp snmp = new org.snmp4j.Snmp(transport); SecurityProtocols securityProtocols = SecurityProtocols.getInstance(); securityProtocols.addDefaultProtocols(); securityProtocols.addAuthenticationProtocol(new AuthMD5()); securityProtocols.addAuthenticationProtocol(new AuthSHA()); securityProtocols.addPrivacyProtocol(new PrivAES128()); securityProtocols.addPrivacyProtocol(new PrivAES192()); securityProtocols.addPrivacyProtocol(new PrivAES256()); USM usm = new USM(securityProtocols, profile.engineId, 0); ((org.snmp4j.mp.MPv3) snmp.getMessageProcessingModel(org.snmp4j.mp.MPv3.ID)) .setLocalEngineID(profile.engineId.getValue()); ((org.snmp4j.mp.MPv3) snmp.getMessageProcessingModel(org.snmp4j.mp.MPv3.ID)) .getSecurityModels().addSecurityModel(usm); SecurityModels.getInstance().addSecurityModel( usm); transport.listen(); snmp.getUSM().addUser( profile.username, getUsmUser(profile)); return snmp; } catch (IOException e) { throw new NotificationServiceException("error creating version 3 snmp " + getClass().getName()); } }
private Snmp createSnmpSession() throws IOException { AbstractTransportMapping<? extends Address> transport; if (address instanceof TlsAddress) { transport = new TLSTM(); } else if (address instanceof TcpAddress) { transport = new DefaultTcpTransportMapping(); } else { transport = new DefaultUdpTransportMapping(); } // Could save some CPU cycles: // transport.setAsyncMsgProcessingSupported(false); Snmp snmp = new Snmp(transport); MPv3 mpv3 = (MPv3)snmp.getMessageProcessingModel(MPv3.ID); mpv3.setLocalEngineID(localEngineID.getValue()); mpv3.setCurrentMsgID(MPv3.randomMsgID(engineBootCount)); if (version == SnmpConstants.version3) { USM usm = new USM(SecurityProtocols.getInstance(), localEngineID, engineBootCount); SecurityModels.getInstance().addSecurityModel(usm); addUsmUser(snmp); SecurityModels.getInstance().addSecurityModel( new TSM(localEngineID, false)); } return snmp; }