/** * Gets the User Based Security Model (USM). This is a convenience method * that uses the {@link MPv3#getSecurityModel} method of the associated MPv3 * instance to get the USM. * * @return the <code>USM</code> instance associated with the MPv3 bound to this * <code>Snmp</code> instance, or <code>null</code> otherwise. */ public USM getUSM() { MPv3 mp = (MPv3) getMessageProcessingModel(MPv3.ID); if (mp != null) { return (USM) mp.getSecurityModel(SecurityModel.SECURITY_MODEL_USM); } return null; }
/** * Gets the User Based Security Model (USM). This is a convenience method * that uses the {@link MPv3#getSecurityModel} method of the associated MPv3 * instance to get the USM. * @return * the <code>USM</code> instance associated with the MPv3 bound to this * <code>Snmp</code> instance, or <code>null</code> otherwise. */ public USM getUSM() { MPv3 mp = (MPv3) getMessageProcessingModel(MPv3.ID); if (mp != null) { return (USM)mp.getSecurityModel(SecurityModel.SECURITY_MODEL_USM); } return null; }
/** * Gets the User Based Security Model (USM). This is a convenience method * that uses the {@link MPv3#getSecurityModel} method of the associated MPv3 * instance to get the USM. * @return * the <code>USM</code> instance associated with the MPv3 bound to this * <code>Snmp</code> instance, or <code>null</code> otherwise. */ public USM getUSM() { MPv3 mp = (MPv3) getMessageProcessingModel(MPv3.ID); if (mp != null) { return (USM)mp.getSecurityModel(SecurityModel.SECURITY_MODEL_USM); } return null; }
/** * 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); }
/** * 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); }
/** * 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); } }
private void discoverContextEngineID() { MessageProcessingModel mp = messageDispatcher.getMessageProcessingModel(target.getVersion()); if ((mp instanceof MPv3) && (target instanceof SecureTarget)) { MPv3 mpv3 = (MPv3) mp; SecureTarget st = (SecureTarget) target; SecurityModel sm = mpv3.getSecurityModel(st.getSecurityModel()); if ((sm != null) && (!sm.supportsEngineIdDiscovery())) { // Perform context engine ID discovery according to RFC 5343 if (logger.isInfoEnabled()) { logger.info("Performing RFC 5343 contextEngineID discovery on " + target); } ScopedPDU discoverPDU = new ScopedPDU(); discoverPDU.setContextEngineID(MPv3.LOCAL_ENGINE_ID); discoverPDU.add(new VariableBinding(SnmpConstants.snmpEngineID)); insertFirstPDU(discoverPDU); } } }
private void discoverContextEngineID() { MessageProcessingModel mp = messageDispatcher.getMessageProcessingModel(target.getVersion()); if ((mp instanceof MPv3) && (target instanceof SecureTarget)) { MPv3 mpv3 = (MPv3)mp; SecureTarget st = (SecureTarget)target; SecurityModel sm = mpv3.getSecurityModel(st.getSecurityModel()); if ((sm != null) && (!sm.supportsEngineIdDiscovery())) { // Perform context engine ID discovery according to RFC 5343 if (logger.isInfoEnabled()) { logger.info("Performing RFC 5343 contextEngineID discovery on "+target); } ScopedPDU discoverPDU = new ScopedPDU(); discoverPDU.setContextEngineID(MPv3.LOCAL_ENGINE_ID); discoverPDU.add(new VariableBinding(SnmpConstants.snmpEngineID)); insertFirstPDU(discoverPDU); } } }
snmpFrameworkMIB = new SnmpFrameworkMIB((USM) mpv3.getSecurityModel(SecurityModel.SECURITY_MODEL_USM), dispatcher.getTransportMappings()); usmMIB = new UsmMIB(usm, SecurityProtocols.getInstance());
snmpFrameworkMIB = new SnmpFrameworkMIB((USM) mpv3.getSecurityModel(SecurityModel.SECURITY_MODEL_USM), dispatcher.getTransportMappings()); usmMIB = new UsmMIB(usm, SecurityProtocols.getInstance());