/** Saves the login information to the login store. Usually this is the file
* ".asadminpass" in user's home directory.
*/
private void saveLogin(final int port, final String user, final String password, final String dn)
{
final CLILogger logger = CLILogger.getInstance();
try {
//by definition, the host name will default to "localhost" and entry is overwritten
final LoginInfoStore store = LoginInfoStoreFactory.getStore(null);
final LoginInfo login = new LoginInfo("localhost", port, user, password);
if (store.exists(login.getHost(), login.getPort())) {
//just let the user know that the user has chosen to overwrite the login information. This is non-interactive, on purpose
final Object[] params = new Object[] {login.getHost(), ""+login.getPort()};
final String msg = getLocalizedString("OverwriteLoginMsgCreateDomain", params);
logger.printMessage(msg);
}
store.store(login, true);
final Object[] params = new String[] {user, dn, store.getName()};
final String msg = getLocalizedString("LoginInfoStoredCreateDomain", params);
logger.printMessage(msg);
}
catch(final Exception e) {
final Object[] params = new String[] {user, dn};
final String msg = getLocalizedString("LoginInfoNotStoredCreateDomain", params);
logger.printWarning(msg);
if (logger.isDebug())
logger.printExceptionStackTrace(e);
}
}