if (domainDir == null) {
domainDir = getSystemProperty(
SystemPropertyConstants.DOMAINS_ROOT_PROPERTY);
}
if (domainDir == null) {
throw new CommandValidationException(
strings.get("InvalidDomainPath", domainDir));
}
/*
* The only required value is the domain_name operand, which might have
* been prompted for before we get here.
*
* If --user wasn't specified as a program option, we treat it as a
* required option and prompt for it if possible, unless --nopassword
* was specified in which case we default the user name.
*
* The next prompted-for value will be the admin password, if required.
*/
if (programOpts.getUser() == null && !noPassword) {
// prompt for it (if interactive)
Console cons = System.console();
if (cons != null && programOpts.isInteractive()) {
cons.printf("%s", strings.get("AdminUserRequiredPrompt",
SystemPropertyConstants.DEFAULT_ADMIN_USER));
String val = cons.readLine();
if (ok(val)) {
programOpts.setUser(val);
if (adminPassword == null) {
adminPassword = getAdminPassword();
}
}
}
else {
//logger.info(strings.get("AdminUserRequired"));
throw new CommandValidationException(
strings.get("AdminUserRequired"));
}
}
if (programOpts.getUser() != null) {
try {
FileRealmHelper.validateUserName(programOpts.getUser());
}
catch (IllegalArgumentException ise) {
throw new CommandValidationException(
strings.get("InvalidUserName", programOpts.getUser()));
}
}
}