}
String host = args[0];
int port = Integer.parseInt(args[1]);
logger.info("connect to host(" + host + ":" + port + ")");
NameCallback ncb = new NameCallback("user:");
PasswordCallback pwcb = new PasswordCallback("password:", false);
Callback[] callbacks = {ncb, pwcb};
MyCallbackHandler cb = new MyCallbackHandler();
usePW = true;
cb.handle(callbacks);
String username = ncb.getName();
String userpw = pwcb.getPassword().toString();
if (useKS) {
PasswordCallback kspw = new PasswordCallback("keystore password:", true);
Callback[] kcallbacks = {kspw};
cb.handle(kcallbacks);
File caTop = new File(caTopPath);
File keyStore = new File(keystorePath);
JGDIProxy.setupSSL(host, port, caTop, keyStore, kspw.getPassword());
kspw.clearPassword();
kspw = null;
}
Object credentials = new String[]{username, userpw};
JGDIProxy jgdiProxy = JGDIFactory.newJMXInstance(host, port, credentials);