Search in sources :

Example 1 with SocketProperties

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;
}
Also used : AS400(com.ibm.as400.access.AS400) UserInfo(com.ibm.nagios.config.util.UserInfo) SocketProperties(com.ibm.as400.access.SocketProperties) IOException(java.io.IOException)

Aggregations

AS400 (com.ibm.as400.access.AS400)1 SocketProperties (com.ibm.as400.access.SocketProperties)1 UserInfo (com.ibm.nagios.config.util.UserInfo)1 IOException (java.io.IOException)1