use of org.snmp4j.security.SecurityProtocols in project ovirt-engine by oVirt.
the class Snmp method createSnmp3.
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());
}
}
Aggregations