Author: pnguyen
Date: 2010-03-25 16:03:40 -0700 (Thu, 25 Mar 2010)
New Revision: 14424
URL: http://svn.hyperic.org/?view=rev&root=Hyperic+HQ&revision=14424
Modified:
trunk/src/org/hyperic/snmp/SNMPClient.java
trunk/src/org/hyperic/snmp/SNMPSession_v3.java
Log:
[HHQ-3674] Improve error handling for invalid SNMPv3 addresses
Modified: trunk/src/org/hyperic/snmp/SNMPClient.java
===================================================================
--- trunk/src/org/hyperic/snmp/SNMPClient.java 2010-03-25 17:37:52 UTC (rev 14423)
+++ trunk/src/org/hyperic/snmp/SNMPClient.java 2010-03-25 23:03:40 UTC (rev 14424)
@@ -251,10 +251,10 @@
default:
- throw new SNMPException("unsupported SNMP version");
+ throw new SNMPException("Unsupported SNMP version: " + snmpVersion);
}
} catch (SNMPException e) {
- String msg = "Failed to initialize snmp session";
+ String msg = "Failed to initialize SNMP session: " + e.getMessage();
throw new SNMPException(msg, e);
}
Modified: trunk/src/org/hyperic/snmp/SNMPSession_v3.java
===================================================================
--- trunk/src/org/hyperic/snmp/SNMPSession_v3.java 2010-03-25 17:37:52 UTC (rev 14423)
+++ trunk/src/org/hyperic/snmp/SNMPSession_v3.java 2010-03-25 23:03:40 UTC (rev 14424)
@@ -154,15 +154,21 @@
initSession(host, port, transport);
- UsmUser usmUser = new UsmUser(securityName,
- authProtocol, authPassphrase,
- privProtocol, privPassphrase);
+ // Need this check for unidirectional agents
+ if (this.target.getAddress() == null) {
+ throw new SNMPException("Invalid SNMP address "
+ + transport + ":" + host + "/" + port);
+ }
// Need to add user by engineID.
byte[] engineID = this.session.discoverAuthoritativeEngineID(
this.target.getAddress(),
this.target.getTimeout());
+ UsmUser usmUser = new UsmUser(securityName,
+ authProtocol, authPassphrase,
+ privProtocol, privPassphrase);
+
USM usm = this.session.getUSM();
// Need to call addUser each time, even if user name exists,
|