beautypg.com

Utility.java sample code – HP Integrity NonStop H-Series User Manual

Page 107

background image

ncb.setName(new String(username));
} else if (current instanceof PasswordCallback) {
PasswordCallback pcb = (PasswordCallback) current;
logger.trace("\n\t\tpcb.setPassword() = " + new String(password));
pcb.setPassword(password);
} else if (current instanceof RealmCallback) {
RealmCallback rcb = (RealmCallback) current;
logger.trace("\n\t\trcb.getDefaulttest() = " + rcb.getDefaultText());
rcb.setText(securityRealmName);
} else {
throw new UnsupportedCallbackException(current);
}
}
}
};
return ModelControllerClient.Factory.create(host, port, callbackHandler);
}

String host = "localhost";
int port = 9999;
String userid = "admin";
String password = null;
String RealmName = "ManagementRealm";

protected ModelControllerClient client = null;
protected Logger logger = null;

}

Utility.java sample code

/*Copyright 2013 Hewlett-Packard Development Company, L.P. */
package com.hp.nsk.nsasj.client;

import java.lang.Exception;
import java.util.Properties;
import java.io.FileInputStream;

public class Utility {

private static Properties props = new Properties();
private static boolean loaded = false;

public static Properties getClientProperties(String propFile) throws Exception {
if (loaded) {
return props;
}

try {
if (propFile !=null) {
FileInputStream fis = new FileInputStream(propFile);
props.load(fis);
loaded = true;
fis.close();
}
} catch (Exception e) {
e.printStackTrace();
System.out.println("Error could not load property file. Exiting ...");
System.exit(1);
}
return props;
}
}

Sample program code 107

This manual is related to the following products: