use of com.ibm.as400.access.SocketProperties in project nagios-for-i by IBM.
the class HostConfig method Insert.
private static boolean Insert(String hostAddr, String userID, String password, String type) {
try {
if (type.equalsIgnoreCase("host")) {
AS400 as400 = new AS400(hostAddr, userID, password);
SocketProperties socketProps = new SocketProperties();
// set timeout to 15 seconds
socketProps.setLoginTimeout(15000);
as400.setSocketProperties(socketProps);
as400.setGuiAvailable(false);
try {
as400.validateSignon();
} catch (Exception e) {
System.out.println(e.toString());
return false;
}
}
if (load()) {
if (type.equalsIgnoreCase("host")) {
hosts.put(hostAddr, new UserInfo(userID, Base64Coder.encodeString(password)));
} else if (type.equalsIgnoreCase("sst")) {
sst.put(hostAddr, new UserInfo(userID, Base64Coder.encodeString(password)));
} else if (type.equalsIgnoreCase("hmc")) {
hmc.put(hostAddr, new UserInfo(userID, Base64Coder.encodeString(password)));
}
if (save()) {
refreshProfile();
return true;
}
}
} catch (Exception e) {
e.printStackTrace();
System.out.println(e.toString());
for (StackTraceElement ele : e.getStackTrace()) {
System.out.println(ele);
}
}
return false;
}
Aggregations