use of org.forgerock.openam.license.LicenseRejectedException in project OpenAM by OpenRock.
the class OpenAMUpgrade method execute.
/**
* Main method of the class which evaluates supplied arguments,
* the supplied config file and sends off necessary requests
*
* @param args Program arguments
*/
public void execute(String[] args) {
//most likely
int configArg = 1;
if (args.length < 2) {
System.out.println(rb.getString("usage"));
System.exit(-1);
}
for (int i = 0; i < args.length; i++) {
if ((i < args.length - 1) && ("--file".equals(args[i]) || "--f".equals(args[i]))) {
configArg = i + 1;
} else if (args[i].equals("--acceptLicense")) {
acceptLicense = true;
}
}
Properties config = new Properties();
FileInputStream fis = null;
try {
fis = new FileInputStream(args[configArg]);
config.load(fis);
} catch (IOException ex) {
System.out.println(rb.getString("errorConfig"));
System.exit(-1);
} finally {
if (fis != null) {
try {
fis.close();
} catch (IOException ex) {
System.out.println(rb.getString("errorConfig"));
System.exit(-1);
}
}
}
String openAmURL = configure(config);
try {
licensePresenter.presentLicenses(acceptLicense);
} catch (LicenseRejectedException e) {
System.out.println(licensePresenter.getNotice());
System.exit(-1);
}
StatusChecker sc = new StatusChecker(openAmURL, URI_LOCATION);
Thread readProgressThread = new Thread(sc);
readProgressThread.start();
boolean success = getRequestToServer(readProgressThread, openAmURL);
if (success) {
System.exit(0);
} else {
System.exit(-1);
}
}
use of org.forgerock.openam.license.LicenseRejectedException in project OpenAM by OpenRock.
the class Main method main.
public static void main(String[] args) {
ResourceBundle bundle = ResourceBundle.getBundle(System.getProperty(SETUP_PROPERTIES_FILE, DEFAULT_PROPERTIES_FILE));
if ((System.getProperty(PRINT_HELP) != null) && System.getProperty(PRINT_HELP).equals(YES)) {
SetupUtils.printUsage(bundle);
System.exit(0);
}
if (System.getProperty(CHECK_VERSION) != null) {
if (System.getProperty(CHECK_VERSION).equals(YES)) {
System.exit(VersionCheck.isValid());
}
}
boolean acceptLicense = false;
for (String arg : args) {
if (arg.equals(ACCEPT_LICENSE)) {
acceptLicense = true;
break;
}
}
try {
LICENSE_PRESENTER.presentLicenses(acceptLicense);
} catch (LicenseRejectedException e) {
System.out.println(bundle.getString("message.error.license"));
System.exit(0);
}
boolean loadConfig = (System.getProperty(CONFIG_LOAD) != null) && System.getProperty(CONFIG_LOAD).equals(YES);
String currentOS = SetupUtils.determineOS();
Properties configProp = null;
String debugPath = null;
String logPath = null;
if (loadConfig) {
String configPath = System.getProperty(AMCONFIG_PATH);
debugPath = System.getProperty(DEBUG_PATH);
logPath = System.getProperty(LOG_PATH);
String currentDir = System.getProperty("user.dir");
try {
if ((configPath == null) || (configPath.length() == 0)) {
configPath = SetupUtils.getUserInput(bundle.getString(currentOS + QUESTION), System.getProperty("user.home") + File.separator + "openam");
if (!(new File(configPath).isAbsolute())) {
System.out.println(bundle.getString("message.error.dir.absolute"));
System.exit(1);
}
if ((debugPath == null) || (debugPath.length() == 0)) {
debugPath = SetupUtils.getUserInput(bundle.getString(currentOS + ".debug.dir"), currentDir + File.separator + "debug");
}
if (!(new File(debugPath).isAbsolute())) {
System.out.println(bundle.getString("message.error.dir.absolute"));
System.exit(1);
}
if (!isWriteable(debugPath)) {
System.out.println(bundle.getString("message.error.debug.dir.not.writable"));
System.exit(1);
}
if ((logPath == null) || (logPath.length() == 0)) {
logPath = SetupUtils.getUserInput(bundle.getString(currentOS + ".log.dir"), currentDir + File.separator + "log");
}
if (!(new File(logPath).isAbsolute())) {
System.out.println(bundle.getString("message.error.dir.absolute"));
System.exit(1);
}
if (!isWriteable(logPath)) {
System.out.println(bundle.getString("message.error.log.dir.not.writable"));
System.exit(1);
}
} else {
String toolsHome = new File(".").getCanonicalPath();
toolsHome = toolsHome.replaceAll("\\\\", "/");
if ((debugPath == null) || (debugPath.length() == 0)) {
debugPath = toolsHome + "/debug";
}
if ((logPath == null) || (logPath.length() == 0)) {
logPath = toolsHome + "/log";
}
}
configProp = Bootstrap.load(configPath, false);
if (configProp == null) {
System.out.println(bundle.getString("message.error.dir"));
System.exit(1);
}
File path = new File(debugPath);
boolean created = path.exists() || path.mkdirs();
if (!created) {
System.out.println(bundle.getString("message.error.debug.dir.not.writable"));
System.exit(1);
}
path = new File(logPath);
created = path.exists() || path.mkdirs();
if (!created) {
System.out.println(bundle.getString("message.error.log.dir.not.writable"));
System.exit(1);
}
if (!configPath.endsWith(FILE_SEPARATOR)) {
configPath = configPath + FILE_SEPARATOR;
}
configProp.setProperty(USER_INPUT, configPath.substring(0, configPath.length() - 1));
configProp.setProperty("LogDir", logPath);
configProp.setProperty("DebugDir", debugPath);
configProp.setProperty(CURRENT_PLATFORM, currentOS);
} catch (Exception ex) {
System.out.println(ex.getMessage());
System.exit(1);
}
} else {
configProp = new Properties();
}
SetupUtils.evaluateBundleValues(bundle, configProp);
try {
SetupUtils.copyAndFilterScripts(bundle, configProp);
if (loadConfig) {
Object[] p = { debugPath };
System.out.println(MessageFormat.format(bundle.getString("message.info.debug.dir"), p));
p[0] = logPath;
System.out.println(MessageFormat.format(bundle.getString("message.info.log.dir"), p));
System.out.println(bundle.getString("message.info.version.tools") + " " + bundle.getString(TOOLS_VERSION));
System.out.println(bundle.getString("message.info.version.am") + " " + SystemProperties.get("com.iplanet.am.version"));
}
} catch (IOException ex) {
System.out.println(bundle.getString("message.error.copy"));
System.exit(1);
}
System.exit(0);
}
use of org.forgerock.openam.license.LicenseRejectedException in project OpenAM by OpenRock.
the class OpenSSOConfigurator method execute.
/**
* Runs the configurator
*
* @param args Program arguments
*/
public void execute(String[] args) {
//most likely
int configArg = 1;
if (args.length < 2) {
System.out.println(rb.getString("usage"));
System.exit(-1);
}
for (int i = 0; i < args.length; i++) {
if ((i < args.length - 1) && ("--file".equals(args[i]) || "--f".equals(args[i]))) {
configArg = i + 1;
} else if (args[i].equals("--acceptLicense")) {
acceptLicense = true;
}
}
Properties config = new Properties();
FileInputStream fis = null;
try {
fis = new FileInputStream(args[configArg]);
config.load(fis);
} catch (IOException ex) {
System.out.println(rb.getString("errorConfig"));
System.exit(-1);
} finally {
if (fis != null) {
try {
fis.close();
} catch (IOException ex) {
System.out.println(rb.getString("errorConfig"));
System.exit(-1);
}
}
}
String openAmURL = configure(config);
try {
licensePresenter.presentLicenses(acceptLicense);
} catch (LicenseRejectedException e) {
System.out.println(licensePresenter.getNotice());
System.exit(-1);
}
// User must have accepted all license terms now, so ensure parameter is added to request
if (postBodySB.length() > 0) {
postBodySB.append("&");
}
postBodySB.append(ACCEPT_LICENSES_PARAM).append("=").append("true");
StatusChecker sc = new StatusChecker(openAmURL, STATUS_LOCATION);
Thread readProgressThread = new Thread(sc);
readProgressThread.start();
boolean success = postRequestToServer(readProgressThread, openAmURL);
if (success) {
System.exit(0);
} else {
System.exit(-1);
}
}
Aggregations