use of com.ibm.as400.access.SecureAS400 in project nagios-for-i by IBM.
the class CheckIBMiStatus method main.
public static void main(String[] args) {
int retValue = Constants.UNKNOWN;
try {
ParseArgs(args);
socket = new Socket(Constants.SERVER, Constants.PORT);
socket.setReuseAddress(true);
socket.setSoLinger(true, 0);
ObjectOutputStream oos = new ObjectOutputStream(socket.getOutputStream());
oos.writeObject(argsMap);
socket.shutdownOutput();
InputStream is = socket.getInputStream();
BufferedReader br = new BufferedReader(new InputStreamReader(is));
String result = null;
if ((result = br.readLine()) != null) {
String message;
while ((message = br.readLine()) != null) {
System.out.println(message);
}
retValue = Integer.parseInt(result);
}
} catch (IOException e) {
try {
String metric = argsMap.get("-M");
String system = argsMap.get("-H");
Action action = ActionFactory.get(metric);
StringBuffer response = new StringBuffer();
if (!HostConfigInfo.load()) {
System.err.println("load file Nagios.host.java.config.ser error");
System.exit(retValue);
}
if ("HMC".equalsIgnoreCase(metric)) {
retValue = action.execute(null, argsMap, response);
} else {
String user = HostConfigInfo.getUserID(system);
String pass = HostConfigInfo.getPassword(system);
if (user == null || pass == null) {
System.err.println("Host user profile not set");
System.exit(retValue);
}
String password = Base64Coder.decodeString(pass);
argsMap.put("-U", user);
argsMap.put("-P", password);
AS400 as400 = null;
String ssl = argsMap.get("-SSL");
if (ssl != null && ssl.equalsIgnoreCase("Y")) {
as400 = new SecureAS400(system, user, password);
} else {
as400 = new AS400(system, user, password);
}
as400.setGuiAvailable(false);
as400.validateSignon();
retValue = action.execute(as400, argsMap, response);
}
System.out.println(response);
} catch (Exception e1) {
retValue = Constants.UNKNOWN;
e1.printStackTrace();
}
} finally {
try {
if (socket != null) {
socket.close();
}
} catch (IOException e) {
e.printStackTrace();
}
}
System.exit(retValue);
}
use of com.ibm.as400.access.SecureAS400 in project openicf by Evolveum.
the class OS400Connector method init.
/**
* Callback method to receive the {@link Configuration}.
*
* @see Connector#init(org.identityconnectors.framework.spi.Configuration)
*/
public void init(Configuration configuration1) {
this.configuration = (OS400Configuration) configuration1;
if (as400 == null) {
try {
final StringBuilder clear = new StringBuilder();
GuardedString.Accessor accessor = new GuardedString.Accessor() {
public void access(char[] clearChars) {
clear.append(clearChars);
}
};
configuration.getPassword().access(accessor);
if (configuration.isSsl()) {
as400 = new SecureAS400(configuration.getHost(), configuration.getRemoteUser(), clear.toString());
} else {
as400 = new AS400(configuration.getHost(), configuration.getRemoteUser(), clear.toString());
}
clear.setLength(0);
if (as400 == null) {
throw new ConnectorException("Connection Exception");
}
if (!as400.validateSignon()) {
throw new ConnectorSecurityException("Login Error");
}
try {
as400.setGuiAvailable(false);
fetchPasswordLevel();
} catch (Exception e) {
}
} catch (AS400SecurityException e) {
throw new ConnectorSecurityException(e);
} catch (IOException e) {
throw new ConnectorIOException(e);
}
}
}
Aggregations