} else { usm = new USM( SecurityProtocols.getInstance(), new OctetString( MPv3.createLocalEngineID() ), 0 ); usm.addUser( new OctetString( userName ), uu ); if ( log.isDebug() ) { logDebug( "Valid Usm" );
this.snmp.getUSM().addUser(new OctetString(username), new UsmUser(new OctetString(username), SNMPUtils.getAuth(authProtocol), aPwd, SNMPUtils.getPriv(privProtocol), pPwd));
/** * Adds an USM user to the internal user name table. * @param userName * a user name. * @param user * the {@code UsmUser} to add. */ public void addUser(OctetString userName, UsmUser user) { addUser(userName, new OctetString(), user); }
/** * Adds an USM user to the internal user name table. * * @param userName * a user name. * @param user * the {@code UsmUser} to add. */ public void addUser(OctetString userName, UsmUser user) { addUser(userName, new OctetString(), user); }
/** * Adds an USM user to the internal user name table. * @param userName * a user name. * @param user * the <code>UsmUser</code> to add. */ public void addUser(OctetString userName, UsmUser user) { addUser(userName, new OctetString(), user); }
/** * Adds an USM user to the internal user name table. * The user's security name is used as userName. * * @param user * the {@code UsmUser} to add. * * @since 2.0 */ public void addUser(UsmUser user) { addUser(user.getSecurityName(), new OctetString(), user); }
/** * Adds an USM user to the internal user name table. * The user's security name is used as userName. * @param user * the {@code UsmUser} to add. * @since 2.0 */ public void addUser(UsmUser user) { addUser(user.getSecurityName(), new OctetString(), user); }
private void addUsmUser(Snmp snmp) { snmp.getUSM().addUser(securityName, new UsmUser(securityName, authProtocol, authPassphrase, privProtocol, privPassphrase)); }
private void addUsmUser(Snmp snmp) { snmp.getUSM().addUser(securityName, new UsmUser(securityName, authProtocol, authPassphrase, privProtocol, privPassphrase)); }
private void addUsmUser(Snmp snmp) { snmp.getUSM().addUser(securityName, new UsmUser(securityName, authProtocol, authPassphrase, privProtocol, privPassphrase)); }
Snmp snmp = new Snmp(new DefaultUdpTransportMapping()); USM usm = new USM(SecurityProtocols.getInstance(), localEngineID, engineBootCount); usm.addUser(securityName, new UsmUser(securityName, authProtocol, authPassphrase, privProtocol, privPassphrase)); MessageProcessingModel oldModel = snmp.getMessageDispatcher().getMessageProcessingModel(MessageProcessingModel.MPv3); if (oldModel != null) { snmp.getMessageDispatcher().removeMessageProcessingModel(oldModel); } snmp.getMessageDispatcher().addMessageProcessingModel(new MPv3(usm));
/** * Adds all the necessary initial users to the USM. * * @param usm the USM instance used by this agent. */ @Override protected void addUsmUser(USM usm) { if (securityName == null || securityName.equals("")) { logger.info("No security name."); return; } UsmUser user = new UsmUser( new OctetString(securityName), AUTHENTICATION_PROTOCOL, new OctetString(AUTHENTICATION_PASSWORD), PRIVACY_PROTOCOL, new OctetString(PRIVACY_PASSWORD) ); usm.addUser(user.getSecurityName(), null, user); }
snmp.getUSM().addUser(new OctetString(ver3Username), new UsmUser(new OctetString(ver3Username), null, null, null, null)); snmp.getUSM().addUser(new OctetString(ver3Username), new UsmUser(new OctetString(ver3Username), authenticationProtocolOID, new OctetString(ver3AuthPasscode), null, null)); snmp.getUSM().addUser(new OctetString(ver3Username), new UsmUser(new OctetString(ver3Username), authenticationProtocolOID, new OctetString(ver3AuthPasscode), privacyProtocolOID, new OctetString(privacyProtocolPassShare)));
/** {@inheritDoc} */ @Override protected void doInit() { USM usm = new USM(SecurityProtocols.getInstance(), new OctetString(MPv3.createLocalEngineID()), 0); SecurityModels.getInstance().addSecurityModel(usm); OID authenticationProtocolOID = null; if ("MD5".equals(this.authenticationProtocol)) { authenticationProtocolOID = AuthMD5.ID; } else if ("SHA".equals(authenticationProtocol)) { authenticationProtocolOID = AuthSHA.ID; } OID privacyProtocolOID = null; if ("DES".equals(privacyProtocol)) { privacyProtocolOID = PrivDES.ID; } else if ("3DES".equals(privacyProtocol)) { privacyProtocolOID = Priv3DES.ID; } if (ver3mode == SecurityLevel.NOAUTH_NOPRIV) { snmp.getUSM().addUser(new OctetString(ver3Username), new UsmUser(new OctetString(ver3Username), null, null, null, null)); } else if (ver3mode == SecurityLevel.AUTH_NOPRIV) { snmp.getUSM().addUser(new OctetString(ver3Username), new UsmUser(new OctetString(ver3Username), authenticationProtocolOID, new OctetString(ver3AuthPasscode), null, null)); } else { snmp.getUSM().addUser(new OctetString(ver3Username), new UsmUser(new OctetString(ver3Username), authenticationProtocolOID, new OctetString(ver3AuthPasscode), privacyProtocolOID, new OctetString(privacyProtocolPassShare))); } }
/** {@inheritDoc} */ @Override protected void addUsmUser(USM usm) { UsmUser user = new UsmUser(new OctetString("SHADES"), AuthSHA.ID, new OctetString("SHADESAuthPassword"), PrivDES.ID, new OctetString("SHADESPrivPassword")); usm.addUser(user.getSecurityName(), usm.getLocalEngineID(), user); user = new UsmUser(new OctetString("TEST"), AuthSHA.ID, new OctetString("maplesyrup"), PrivDES.ID, new OctetString("maplesyrup")); usm.addUser(user.getSecurityName(), usm.getLocalEngineID(), user); user = new UsmUser(new OctetString("opennmsUser"), AuthMD5.ID, new OctetString("0p3nNMSv3"), PrivDES.ID, new OctetString("0p3nNMSv3")); usm.addUser(user.getSecurityName(), usm.getLocalEngineID(), user); user = new UsmUser(new OctetString("SHA"), AuthSHA.ID, new OctetString("SHAAuthPassword"), null, null); usm.addUser(user.getSecurityName(), usm.getLocalEngineID(), user); }
/** {@inheritDoc} */ @Override protected void addUsmUser(USM usm) { UsmUser user = new UsmUser(new OctetString("SHADES"), AuthSHA.ID, new OctetString("SHADESAuthPassword"), PrivDES.ID, new OctetString("SHADESPrivPassword")); usm.addUser(user.getSecurityName(), usm.getLocalEngineID(), user); user = new UsmUser(new OctetString("TEST"), AuthSHA.ID, new OctetString("maplesyrup"), PrivDES.ID, new OctetString("maplesyrup")); usm.addUser(user.getSecurityName(), usm.getLocalEngineID(), user); user = new UsmUser(new OctetString("opennmsUser"), AuthMD5.ID, new OctetString("0p3nNMSv3"), PrivDES.ID, new OctetString("0p3nNMSv3")); usm.addUser(user.getSecurityName(), usm.getLocalEngineID(), user); user = new UsmUser(new OctetString("SHA"), AuthSHA.ID, new OctetString("SHAAuthPassword"), null, null); usm.addUser(user.getSecurityName(), usm.getLocalEngineID(), user); }
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()); } }
public Snmp createSnmpSession() throws IOException { TransportMapping transport = new DefaultUdpTransportMapping(); Snmp session = new Snmp(transport); if (isSnmpV3()) { // Make a new USM USM usm = new USM(SecurityProtocols.getInstance(), new OctetString(MPv3.createLocalEngineID()), 0); // Add the specified user to the USM usm.addUser( getSecurityName(), new UsmUser( getSecurityName(), getAuthProtocol(), getAuthPassPhrase(), getPrivProtocol(), getPrivPassPhrase() ) ); // Remove the old SNMPv3 MessageProcessingModel. If you don't do this, you'll end up with // two SNMPv3 MessageProcessingModel instances in the dispatcher and connections will fail. MessageProcessingModel oldModel = session.getMessageDispatcher().getMessageProcessingModel(MessageProcessingModel.MPv3); if (oldModel != null) { session.getMessageDispatcher().removeMessageProcessingModel(oldModel); } // Add a new SNMPv3 MessageProcessingModel with the newly-created USM session.getMessageDispatcher().addMessageProcessingModel(new MPv3(usm)); } return session; }
public Snmp createSnmpSession() throws IOException { final TransportMapping<?> transport = new DefaultUdpTransportMapping(); final MessageDispatcher disp = new MessageDispatcherImpl(); final Snmp session; // Here we create the SNMP session, while only adding the message processing // models we need for the specific agent if (!isSnmpV3()) { disp.addMessageProcessingModel(new MPv1()); disp.addMessageProcessingModel(new MPv2c()); session = new Snmp(disp, transport); } else { // Make a new USM final USM usm = new USM(SecurityProtocols.getInstance(), new OctetString(MPv3.createLocalEngineID()), 0); // Add the specified user to the USM usm.addUser( getSecurityName(), new UsmUser( getSecurityName(), getAuthProtocol(), getAuthPassPhrase(), getPrivProtocol(), getPrivPassPhrase() ) ); disp.addMessageProcessingModel(new MPv3(usm)); session = new Snmp(disp, transport); } return session; }
public Snmp createSnmpSession() throws IOException { final TransportMapping<?> transport = new DefaultUdpTransportMapping(); final MessageDispatcher disp = new MessageDispatcherImpl(); final Snmp session; // Here we create the SNMP session, while only adding the message processing // models we need for the specific agent if (!isSnmpV3()) { disp.addMessageProcessingModel(new MPv1()); disp.addMessageProcessingModel(new MPv2c()); session = new Snmp(disp, transport); } else { // Make a new USM final USM usm = new USM(SecurityProtocols.getInstance(), new OctetString(MPv3.createLocalEngineID()), 0); // Add the specified user to the USM usm.addUser( getSecurityName(), new UsmUser( getSecurityName(), getAuthProtocol(), getAuthPassPhrase(), getPrivProtocol(), getPrivPassPhrase() ) ); disp.addMessageProcessingModel(new MPv3(usm)); session = new Snmp(disp, transport); } return session; }