/*
* CDDL HEADER START
*
* The contents of this file are subject to the terms of the
* Common Development and Distribution License, Version 1.0 only
* (the "License"). You may not use this file except in compliance
* with the License.
*
* You can obtain a copy of the license at
* See the License for the specific language governing permissions
* and limitations under the License.
*
* When distributing Covered Code, include this CDDL HEADER in each
* file and include the License file at
* trunk/opends/resource/legal-notices/OpenDS.LICENSE. If applicable,
* add the following below this CDDL HEADER, with the fields enclosed
* by brackets "[]" replaced with your own identifying information:
* Portions Copyright [yyyy] [name of copyright owner]
*
* CDDL HEADER END
*
*
* Copyright 2008-2010 Sun Microsystems, Inc.
* Portions copyright 2011-2013 ForgeRock AS.
*/
/**
* Class used to parse the arguments of the setup command-line and to check
* that there are not conflicting arguments (nor missing arguments in no prompt
* mode).
* Note that this class does not perform checks involving network (like if
* a given port is free) nor the validity of the certificate information
* provided.
*/
{
InstallDSArgumentParser.class.getName());
/**
* The default constructor for this class.
* @param mainClassName the class name of the main class for the command-line
* that is being used.
*/
{
}
/**
* Initializes the arguments without parsing them.
* @throws ArgumentException if there was an error creating or adding the
* arguments. If this occurs is likely to be a bug.
*/
{
testOnlyArg = new BooleanArgument(
testOnlyArg.setHidden(true);
cliArg = new BooleanArgument(
if (SetupUtils.isWindows())
{
}
else
{
}
progNameArg = new StringArgument(
progNameArg.setHidden(true);
noPromptArg = new BooleanArgument(
quietArg = new BooleanArgument(
OPTION_LONG_PROP_FILE_PATH, false,
baseDNArg = new StringArgument(
OPTION_LONG_BASEDN, false, true, true,
addBaseEntryArg = new BooleanArgument(
importLDIFArg = new StringArgument(
OPTION_LONG_LDIF_FILE, false,
true, true, INFO_LDIFFILE_PLACEHOLDER.get(),
sampleDataArg = new IntegerArgument(
true, 0, false, 0,
if (defaultLdapPort == -1)
{
defaultLdapPort = 389;
}
ldapPortArg = new IntegerArgument(
"ldapPort", false, false,
"ldapPort", true, 1, true, 65535,
if (defaultAdminPort == -1)
{
}
"adminConnectorPort", false, false,
"adminConnectorPort", true, 1, true, 65535,
jmxPortArg = new IntegerArgument(
true, INFO_JMXPORT_PLACEHOLDER.get(),
1, true, 65535,
skipPortCheckArg = new BooleanArgument(
OPTION_LONG_ROOT_USER_DN, false, false,
true, INFO_ROOT_USER_DN_PLACEHOLDER.get(),
"cn=Directory Manager",
"rootUserPassword",
false, false, true,
"rootUserPassword",
"rootUserPasswordFile".toLowerCase(),
"rootUserPasswordFile", false, false,
null, "rootUserPasswordFile",
"enableWindowsService",
if (SetupUtils.isWindows())
{
}
doNotStartArg = new BooleanArgument(
enableStartTLSArg = new BooleanArgument(
"enableStartTLS",
if (defaultSecurePort == -1)
{
defaultSecurePort = 636;
}
ldapsPortArg = new IntegerArgument(
"ldapsPort", false, false,
"ldapsPort", true, 1, true, 65535,
"generateSelfSignedCertificate".toLowerCase(),
null, "generateSelfSignedCertificate",
"generateSelfSignedCertificate");
null, "usePkcs11Keystore",
null, "useJavaKeystore", false, false,
null, "useJCEKS", false, false,
null, "usePkcs12keyStore", false, false,
OPTION_LONG_KEYSTORE_PWD, false, false, true,
certNicknameArg = new StringArgument(
false, false, true, INFO_TIMEOUT_PLACEHOLDER.get(),
true, 1, true, 65535,
connectTimeoutArg.setHidden(true);
showUsageArg = new BooleanArgument(
}
/**
* Returns whether the command was launched in CLI mode or not.
* @return <CODE>true</CODE> if the command was launched to use CLI mode and
* <CODE>false</CODE> otherwise.
*/
public boolean isCli()
{
}
/**
* {@inheritDoc}
*/
@Override()
{
try
{
super.parseArguments(args);
}
catch (ArgumentException ae)
{
}
if (!isUsageArgumentPresent() && !isVersionArgumentPresent())
{
{
throw new ArgumentException(message);
}
}
}
/**
* Returns the directory manager password provided by the user. This method
* should be called after a call to parseArguments.
* @return the directory manager password provided by the user.
*/
{
{
}
else if (directoryManagerPwdFileArg.isPresent())
{
}
return pwd;
}
/**
* Returns the key store password provided by the user. This method should be
* called after a call to parseArguments.
* @return the key store password provided by the user.
*/
{
if (keyStorePasswordArg.isPresent())
{
}
else if (keyStorePasswordFileArg.isPresent())
{
}
return pwd;
}
/**
* Checks that there are no conflicts with the directory manager passwords.
* If we are in no prompt mode, check that the password was provided.
* @param errorMessages the list of messages to which we add the error
* messages describing the problems encountered during the execution of the
* checking.
*/
{
if (directoryManagerPwdStringArg.isPresent() &&
{
}
{
}
}
/**
* Checks that there are no conflicts with the provided ports (like if the
* user provided the same port for different protocols).
* @param errorMessages the list of messages to which we add the error
* messages describing the problems encountered during the execution of the
* checking.
*/
{
/**
* Check that the provided ports do not match.
*/
try
{
{
}
else
{
}
if (jmxPortArg.isPresent())
{
{
}
else
{
}
}
if (ldapsPortArg.isPresent())
{
{
}
else
{
}
}
}
catch (ArgumentException ae)
{
}
}
/**
* Checks that there are no conflicts with the import data arguments.
* @param errorMessages the list of messages to which we add the error
* messages describing the problems encountered during the execution of the
* checking.
*/
{
// Make sure that the user didn't provide conflicting arguments.
if (addBaseEntryArg.isPresent())
{
if (importLDIFArg.isPresent())
{
}
else if (sampleDataArg.isPresent())
{
}
}
{
}
{
}
{
}
{
}
{
}
{
{
{
}
}
}
}
/**
* Checks that there are no conflicts with the security arguments.
* If we are in no prompt mode, check that all the information required has
* been provided (but not if this information is valid: we do not try to
* open the keystores or to check that the LDAPS port is in use).
* @param errorMessages the list of messages to which we add the error
* messages describing the problems encountered during the execution of the
* checking.
*/
{
int certificateType = 0;
{
}
if (useJavaKeyStoreArg.isPresent())
{
}
if (useJCEKSArg.isPresent())
{
}
if (usePkcs11Arg.isPresent())
{
}
if (usePkcs12Arg.isPresent())
{
}
if (certificateType > 1)
{
}
(certificateType == 0))
{
}
if (certificateType == 1)
{
{
// Check that we have only a password.
if (keyStorePasswordArg.isPresent() &&
{
}
// Check that we have one password in no prompt mode.
{
}
}
{
}
}
}
/**
* Returns the timeout to be used to connect in milliseconds. The method
* must be called after parsing the arguments.
* @return the timeout to be used to connect in milliseconds. Returns
* {@code 0} if there is no timeout.
* @throws IllegalStateException if the method is called before
* parsing the arguments.
*/
{
try
{
return connectTimeoutArg.getIntValue();
}
catch (ArgumentException ae)
{
}
}
}