private SnmpV3AdaptorServer getSnmpAdaptor(
SNMPConnectionHandlerCfg configuration) {
Validator.ensureNotNull(configuration);
SnmpV3AdaptorServer adaptor = null;
try {
// Set the USM security file
String usmConfigPath = configuration.getSecurityAgentFile();
File file = StaticUtils.getFileForPath(usmConfigPath);
if ((!file.isFile()) || (!file.exists())) {
return null;
}
System.setProperty("jdmk.security.file", file.getAbsolutePath());
// Create the Security Parameters for the engine
SnmpEngineParameters engineParameters = new SnmpEngineParameters();
// Set V3 Security parameters
engineParameters.activateEncryption();
// Create the UACL controller
UserAcl uacls = (UserAcl) new SNMPUserAcl(configuration);
engineParameters.setUserAcl(uacls);
// V1/V2 Security parameters
InetAddressAcl acls =
(InetAddressAcl) new SNMPInetAddressAcl(configuration);
adaptor = new SnmpV3AdaptorServer(engineParameters, null, acls,
configuration.getListenPort(), null);
// Enable the community to context translation for V1/V2 to V3
adaptor.enableCommunityStringAtContext();
return adaptor;
} catch (Exception ex) {
TRACER.debugError("Could not instanciate the SNMP Adaptor");
return null;