}
}
}
UdpAddress udpAddr = new UdpAddress(UdpAddress.ANY_IPADDRESS, 0);
Snmp snmp = new Snmp(new DefaultUdpTransportMapping(udpAddr));
/* the snmp connection is open... add a seprate try/catch so we can make sure we close it */
try {
if ((version.equals("1")) || (version.equals("2c"))) {
target = getCommunityTarget(targetAddress, Integer.parseInt(timeout), community, version);
}
else {
OID auth = null;
OID priv = null;
if (auth_protocol != null) {
if (auth_protocol.equals("MD5")) {
auth = AuthMD5.ID;
}
else if (auth_protocol.equals("SHA")) {
auth = AuthSHA.ID;
}
}
if (privacy_protocol != null) {
if (privacy_protocol.equals("AES128")) {
priv = PrivAES128.ID;
}
else if (privacy_protocol.equals("AES192")) {
priv = PrivAES192.ID;
}
else if (privacy_protocol.equals("AES256")) {
priv = PrivAES256.ID;
}
else if (privacy_protocol.equals("DES")) {
priv = PrivDES.ID;
}
}
SecurityProtocols sec = SecurityProtocols.getInstance();
((MPv3)snmp.getMessageProcessingModel(MPv3.ID)).setLocalEngineID(localEngineID.getValue());
USM usm = new USM(sec, localEngineID, 0);
SecurityModels.getInstance().addSecurityModel(usm);
UsmUser user = new UsmUser(new OctetString(security_name),
auth,
new OctetString(auth_passphrase),
priv,
new OctetString(privacy_passphrase));
snmp.getUSM().addUser(user);
SecurityModels.getInstance().addSecurityModel(new TSM(localEngineID, false));
target = getUserTarget(targetAddress, Integer.parseInt(timeout), security_level, security_name, security_engine);
}
snmp.listen();
Iterator it = oids.entrySet().iterator();
Exception ret = null;
if (walk_base != null) {
ret = walkHard(snmp, target, context_engine, context_name, walk_base, rr);
}
if (send_separate_queries == true) {
ret = processIndividually(snmp, target, context_engine, context_name, it, oid_hashmap, rr);
}
else {
ret = processAll(snmp, target, context_engine, context_name, it, oid_hashmap, rr);
}
if (ret != null) {
throw(ret);
}
/* Go through remaining named values, return blank strings */
blankMissingValues(oid_hashmap, rr);
}
catch (Exception e) {
String error_msg = e.getMessage();
if (error_msg != null) {
rr.set("jezebel_status", error_msg);
}
}
snmp.close();
}
catch(Exception e){
String error_msg = e.getMessage();
if (error_msg != null) {
rr.set("jezebel_status", error_msg);