From 8feee36de8e6042f928439b06a03d50018423afe Mon Sep 17 00:00:00 2001
From: jvergara <jvergara@localhost>
Date: Fri, 17 Aug 2007 00:53:26 +0000
Subject: [PATCH] The following modifications have the following goals:
---
opends/resource/uninstall-gui | 37
opends/resource/bin/status-panel | 5
opends/src/guitools/org/opends/guitools/uninstaller/ui/LoginDialog.java | 3
opends/src/quicksetup/org/opends/quicksetup/UserDataException.java | 12
opends/src/quicksetup/org/opends/quicksetup/upgrader/ui/BuildListDownloadErrorPanel.java | 2
opends/resource/uninstall | 106 -
opends/src/messages/messages/utility.properties | 3
opends/src/quicksetup/org/opends/quicksetup/installer/Installer.java | 5
opends/resource/bin/status.bat | 2
opends/resource/uninstall-gui.bat | 90 +
opends/src/quicksetup/org/opends/quicksetup/CliApplicationHelper.java | 282 +++++
opends/src/quicksetup/org/opends/quicksetup/ui/QuickSetup.java | 8
opends/src/server/org/opends/server/util/args/ArgumentParser.java | 3
opends/src/guitools/org/opends/guitools/statuspanel/StatusPanelController.java | 6
opends/src/quicksetup/org/opends/quicksetup/Constants.java | 4
opends/src/server/org/opends/server/util/args/SubCommandArgumentParser.java | 53
opends/src/quicksetup/org/opends/quicksetup/ui/CertificateDialog.java | 87 +
opends/resource/bin/status | 5
opends/src/quicksetup/org/opends/quicksetup/ui/DirectoryManagerAuthenticationDialog.java | 3
opends/src/guitools/org/opends/guitools/uninstaller/UninstallUserData.java | 114 ++
opends/src/server/org/opends/server/admin/client/cli/SecureConnectionCliParser.java | 52
opends/src/guitools/org/opends/guitools/statuspanel/ConfigFromFile.java | 3
opends/src/guitools/org/opends/guitools/statuspanel/ConfigFromLDAP.java | 12
opends/src/guitools/org/opends/guitools/statuspanel/StatusCli.java | 513 --------
opends/src/guitools/org/opends/guitools/uninstaller/UninstallerArgumentParser.java | 402 +++++++
opends/src/messages/messages/quicksetup.properties | 55
opends/src/messages/messages/tools.properties | 5
opends/src/quicksetup/org/opends/quicksetup/installer/InstallLauncher.java | 3
opends/src/quicksetup/org/opends/quicksetup/Installation.java | 11
opends/src/quicksetup/org/opends/quicksetup/UserData.java | 23
opends/build.xml | 9
opends/src/ads/org/opends/admin/ads/ADSContext.java | 5
opends/src/guitools/org/opends/guitools/uninstaller/UninstallCliHelper.java | 784 +++++++++++++-
opends/src/guitools/org/opends/guitools/uninstaller/UninstallLauncher.java | 60
opends/src/quicksetup/org/opends/quicksetup/Launcher.java | 2
opends/src/quicksetup/org/opends/quicksetup/util/Utils.java | 30
opends/src/messages/src/org/opends/messages/MessageDescriptor.java | 2
opends/src/guitools/org/opends/guitools/uninstaller/Uninstaller.java | 104 +
opends/src/messages/messages/admin_tool.properties | 74 +
opends/src/guitools/org/opends/guitools/uninstaller/UninstallGuiLauncher.java | 179 +++
opends/src/quicksetup/org/opends/quicksetup/UserDataCertificateException.java | 3
opends/src/quicksetup/org/opends/quicksetup/Application.java | 23
42 files changed, 2,341 insertions(+), 843 deletions(-)
diff --git a/opends/build.xml b/opends/build.xml
index df073e0..362e8b9 100644
--- a/opends/build.xml
+++ b/opends/build.xml
@@ -864,13 +864,14 @@
<fileset file="${resource.dir}/README" />
</copy>
- <fixcrlf srcDir="${resource.dir}" destDir="${pdir}" includes="setup,uninstall,upgrade"
+ <fixcrlf srcDir="${resource.dir}" destDir="${pdir}" includes="setup,uninstall,uninstall-gui,upgrade"
eol="lf" />
- <fixcrlf srcDir="${resource.dir}" destDir="${pdir}" includes="setup.bat,uninstall.bat,upgrade.bat"
+ <fixcrlf srcDir="${resource.dir}" destDir="${pdir}" includes="setup.bat,uninstall.bat,uninstall-gui.bat,upgrade.bat"
eol="crlf" />
<chmod file="${pdir}/setup" perm="755" />
<chmod file="${pdir}/uninstall" perm="755" />
+ <chmod file="${pdir}/uninstall-gui" perm="755" />
<chmod file="${pdir}/upgrade" perm="755" />
<chmod perm="755">
<fileset dir="${pdir}/bin">
@@ -888,7 +889,7 @@
description="Package the Directory Server for distribution.">
<zip destfile="${package.dir}/${SHORT_NAME}-${VERSION_NUMBER_STRING}.zip">
<zipfileset dir="${package.dir}" includes="${SHORT_NAME}-${VERSION_NUMBER_STRING}/**/*"
- excludes="${SHORT_NAME}-${VERSION_NUMBER_STRING}/bin/*,${SHORT_NAME}-${VERSION_NUMBER_STRING}/lib/_client-script.sh,${SHORT_NAME}-${VERSION_NUMBER_STRING}/lib/_server-script.sh,${SHORT_NAME}-${VERSION_NUMBER_STRING}/setup,${SHORT_NAME}-${VERSION_NUMBER_STRING}/uninstall,${SHORT_NAME}-${VERSION_NUMBER_STRING}/upgrade"
+ excludes="${SHORT_NAME}-${VERSION_NUMBER_STRING}/bin/*,${SHORT_NAME}-${VERSION_NUMBER_STRING}/lib/_client-script.sh,${SHORT_NAME}-${VERSION_NUMBER_STRING}/lib/_server-script.sh,${SHORT_NAME}-${VERSION_NUMBER_STRING}/setup,${SHORT_NAME}-${VERSION_NUMBER_STRING}/uninstall,${SHORT_NAME}-${VERSION_NUMBER_STRING}/uninstall-gui,${SHORT_NAME}-${VERSION_NUMBER_STRING}/upgrade"
filemode="644" dirmode="755" />
<zipfileset dir="${package.dir}"
includes="${SHORT_NAME}-${VERSION_NUMBER_STRING}/lib/_client-script.sh,${SHORT_NAME}-${VERSION_NUMBER_STRING}/lib/_server-script.sh"
@@ -898,7 +899,7 @@
filemode="755" dirmode="755" />
<zipfileset dir="${package.dir}" includes="${SHORT_NAME}-${VERSION_NUMBER_STRING}/bin/README_WINDOWS.txt"
filemode="644" dirmode="755" />
- <zipfileset dir="${package.dir}" includes="${SHORT_NAME}-${VERSION_NUMBER_STRING}/setup,${SHORT_NAME}-${VERSION_NUMBER_STRING}/uninstall,${SHORT_NAME}-${VERSION_NUMBER_STRING}/upgrade"
+ <zipfileset dir="${package.dir}" includes="${SHORT_NAME}-${VERSION_NUMBER_STRING}/setup,${SHORT_NAME}-${VERSION_NUMBER_STRING}/uninstall,${SHORT_NAME}-${VERSION_NUMBER_STRING}/uninstall-gui,${SHORT_NAME}-${VERSION_NUMBER_STRING}/upgrade"
filemode="755" dirmode="755" />
</zip>
<property name="package.built" value="true"/>
diff --git a/opends/resource/bin/status b/opends/resource/bin/status
index 69f182f..5f2d450 100644
--- a/opends/resource/bin/status
+++ b/opends/resource/bin/status
@@ -30,5 +30,8 @@
OPENDS_INVOKE_CLASS="org.opends.guitools.statuspanel.StatusCli"
export OPENDS_INVOKE_CLASS
+SCRIPT_NAME_ARG="-Dorg.opends.server.scriptName=status"
+export SCRIPT_NAME_ARG
+
SCRIPT_DIR=`dirname "${0}"`
-"${SCRIPT_DIR}/../lib/_server-script.sh" "${@}"
+"${SCRIPT_DIR}/../lib/_client-script.sh" "${@}"
diff --git a/opends/resource/bin/status-panel b/opends/resource/bin/status-panel
index fe62e37..46b808b 100644
--- a/opends/resource/bin/status-panel
+++ b/opends/resource/bin/status-panel
@@ -30,5 +30,8 @@
OPENDS_INVOKE_CLASS="org.opends.guitools.statuspanel.StatusPanelLauncher"
export OPENDS_INVOKE_CLASS
+SCRIPT_NAME_ARG="-Dorg.opends.server.scriptName=status-panel"
+export SCRIPT_NAME_ARG
+
SCRIPT_DIR=`dirname "${0}"`
-"${SCRIPT_DIR}/../lib/_server-script.sh" "${@}"
+"${SCRIPT_DIR}/../lib/_client-script.sh" "${@}"
diff --git a/opends/resource/bin/status.bat b/opends/resource/bin/status.bat
index 1c95429..84df965 100644
--- a/opends/resource/bin/status.bat
+++ b/opends/resource/bin/status.bat
@@ -29,4 +29,4 @@
set OPENDS_INVOKE_CLASS="org.opends.guitools.statuspanel.StatusCli"
set SCRIPT_NAME_ARG="-Dorg.opends.server.scriptName=status"
-for %%i in (%~sf0) do call "%%~dPsi\..\lib\_server-script.bat" %*
+for %%i in (%~sf0) do call "%%~dPsi\..\lib\_client-script.bat" %*
diff --git a/opends/resource/uninstall b/opends/resource/uninstall
index 019df2e..c8f0744 100644
--- a/opends/resource/uninstall
+++ b/opends/resource/uninstall
@@ -26,104 +26,12 @@
# Portions Copyright 2006-2007 Sun Microsystems, Inc.
-# See if JAVA_HOME is set. If not, then see if there is a java executable in
-# the path and try to figure it out.
-if test -z "${JAVA_BIN}"
-then
- if test -z "${JAVA_HOME}"
- then
- if test -f "${INSTANCE_ROOT}/lib/set-java-home"
- then
- . "${INSTANCE_ROOT}/lib/set-java-home"
- JAVA_BIN="${JAVA_HOME}/bin/java"
- export JAVA_BIN
- else
- JAVA_BIN=`which java 2> /dev/null`
- if test ${?} -eq 0
- then
- export JAVA_BIN
- else
- echo "Please set JAVA_HOME to the root of a Java 5 (or later) installation."
- exit 1
- fi
- fi
- else
- JAVA_BIN="${JAVA_HOME}/bin/java"
- export JAVA_BIN
- fi
-fi
+# This script may be used to display the status panel.
+OPENDS_INVOKE_CLASS="org.opends.guitools.uninstaller.UninstallLauncher"
+export OPENDS_INVOKE_CLASS
+SCRIPT_NAME_ARG="-Dorg.opends.server.scriptName=uninstall"
+export SCRIPT_NAME_ARG
-# Explicitly set the PATH, LD_LIBRARY_PATH, LD_PRELOAD, and other important
-# system environment variables for security and compatibility reasons.
-PATH=/bin:/usr/bin
-LD_LIBRARY_PATH=
-LD_LIBRARY_PATH_32=
-LD_LIBRARY_PATH_64=
-LD_PRELOAD=
-LD_PRELOAD_32=
-LD_PRELOAD_64=
-export PATH LD_LIBRARY_PATH LD_LIBRARY_PATH_32 LD_LIBRARY_PATH_64 \
- LD_PRELOAD LD_PRELOAD_32 LD_PRELOAD_34
-
-
-# Capture the current working directory so that we can change to it later.
-# Then capture the location of this script and the Directory Server instance
-# root so that we can use them to create appropriate paths.
-WORKING_DIR=`pwd`
-
-cd `dirname "${0}"`
-SCRIPT_DIR=`pwd`
-
-INSTANCE_ROOT=${SCRIPT_DIR}
-export INSTANCE_ROOT
-
-cd "${WORKING_DIR}"
-
-
-# Configure the appropriate CLASSPATH to test.
-CLASSPATH=${INSTANCE_ROOT}/classes
-for JAR in ${INSTANCE_ROOT}/lib/*.jar
-do
- CLASSPATH=${CLASSPATH}:${JAR}
-done
-export CLASSPATH
-
-# Determine whether the detected Java environment is acceptable for use.
-if test -z "${JAVA_ARGS}"
-then
- "${JAVA_BIN}" -client org.opends.server.tools.InstallDS -t 2> /dev/null
- if test ${?} -eq 0
- then
- JAVA_ARGS="-client"
- else
- "${JAVA_BIN}" org.opends.server.tools.InstallDS -t 2> /dev/null
- if test ${?} -ne 0
- then
- echo "ERROR: The detected Java version could not be used. Please set "
- echo " JAVA_HOME to the root of a Java 5 (or later) installation."
- exit 1
- fi
- fi
-else
- "${JAVA_BIN}" ${JAVA_ARGS} org.opends.server.tools.InstallDS -t 2> /dev/null
- if test ${?} -ne 0
- then
- echo "ERROR: The detected Java version could not be used. Please set "
- echo " JAVA_HOME to the root of a Java 5 (or later) installation."
- exit 1
- fi
-fi
-
-
-# Launch the uninstall process.
-"${JAVA_BIN}" org.opends.guitools.uninstaller.UninstallLauncher "${@}"
-
-RETURN_CODE=$?
-if test ${RETURN_CODE} -eq 50
-then
- # Version info was on requested
- exit 0
-else
- exit ${RETURN_CODE}
-fi
+SCRIPT_DIR=`dirname "${0}"`
+"${SCRIPT_DIR}/lib/_client-script.sh" "${@}"
\ No newline at end of file
diff --git a/opends/resource/uninstall-gui b/opends/resource/uninstall-gui
new file mode 100644
index 0000000..2c08d55
--- /dev/null
+++ b/opends/resource/uninstall-gui
@@ -0,0 +1,37 @@
+#!/bin/sh
+#
+# 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
+# trunk/opends/resource/legal-notices/OpenDS.LICENSE
+# or https://OpenDS.dev.java.net/OpenDS.LICENSE.
+# 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
+#
+#
+# Portions Copyright 2006-2007 Sun Microsystems, Inc.
+
+
+# This script may be used to display the status panel.
+OPENDS_INVOKE_CLASS="org.opends.guitools.uninstaller.UninstallGuiLauncher"
+export OPENDS_INVOKE_CLASS
+
+SCRIPT_NAME_ARG="-Dorg.opends.server.scriptName=uninstall-gui"
+export SCRIPT_NAME_ARG
+
+SCRIPT_DIR=`dirname "${0}"`
+"${SCRIPT_DIR}/lib/_client-script.sh" "${@}"
\ No newline at end of file
diff --git a/opends/resource/uninstall-gui.bat b/opends/resource/uninstall-gui.bat
new file mode 100644
index 0000000..aa7dc29
--- /dev/null
+++ b/opends/resource/uninstall-gui.bat
@@ -0,0 +1,90 @@
+
+@echo off
+rem CDDL HEADER START
+rem
+rem The contents of this file are subject to the terms of the
+rem Common Development and Distribution License, Version 1.0 only
+rem (the "License"). You may not use this file except in compliance
+rem with the License.
+rem
+rem You can obtain a copy of the license at
+rem trunk/opends/resource/legal-notices/OpenDS.LICENSE
+rem or https://OpenDS.dev.java.net/OpenDS.LICENSE.
+rem See the License for the specific language governing permissions
+rem and limitations under the License.
+rem
+rem When distributing Covered Code, include this CDDL HEADER in each
+rem file and include the License file at
+rem trunk/opends/resource/legal-notices/OpenDS.LICENSE. If applicable,
+rem add the following below this CDDL HEADER, with the fields enclosed
+rem by brackets "[]" replaced with your own identifying information:
+rem Portions Copyright [yyyy] [name of copyright owner]
+rem
+rem CDDL HEADER END
+rem
+rem
+rem Portions Copyright 2007 Sun Microsystems, Inc.
+
+setlocal
+for %%i in (%~sf0) do set DIR_HOME=%%~dPsi.
+
+set INSTANCE_ROOT=%DIR_HOME%
+
+:checkJavaBin
+if "%JAVA_BIN%" == "" goto noJavaBin
+goto setClassPath
+
+:noJavaBin
+if "%JAVA_HOME%" == "" goto noJavaHome
+if not exist "%JAVA_HOME%\bin\java.exe" goto noJavaHome
+set JAVA_BIN=%JAVA_HOME%\bin\java.exe
+goto setClassPath
+
+:noJavaHome
+if not exist "%DIR_HOME%\lib\set-java-home.bat" goto noSetJavaHome
+call "%DIR_HOME%\lib\set-java-home.bat"
+set JAVA_BIN=%JAVA_HOME%\bin\java.exe
+goto setClassPath
+
+:noSetJavaHome
+echo Error: JAVA_HOME environment variable is not set.
+echo Please set it to a valid Java 5 (or later) installation.
+pause
+goto end
+
+:noValidJavaHome
+echo ERROR: The detected Java version could not be used. Please set
+echo JAVA_HOME to to a valid Java 5 (or later) installation.
+pause
+goto end
+
+:setClassPath
+FOR %%x in ("%DIR_HOME%\lib\*.jar") DO call "%DIR_HOME%\lib\setcp.bat" %%x
+set CLASSPATH=%DIR_HOME%\classes;%CLASSPATH%
+
+set PATH=%SystemRoot%
+
+rem Test that the provided JDK is 1.5 compatible.
+"%JAVA_BIN%" org.opends.server.tools.InstallDS -t > NUL 2>&1
+if not %errorlevel% == 0 goto noValidJavaHome
+
+if "%~1" == "" goto callLaunch
+goto callJava
+
+:callLaunch
+"%DIR_HOME%\lib\winlauncher.exe" launch "%JAVA_BIN%" %JAVA_ARGS% org.opends.guitools.uninstaller.UninstallLauncher
+goto end
+
+:callJava
+set SCRIPT_NAME_ARG="-Dorg.opends.server.scriptName=uninstall-gui"
+"%JAVA_BIN%" %JAVA_ARGS% org.opends.guitools.uninstaller.UninstallGuiLauncher %*
+
+rem return part
+if %errorlevel% == 50 goto version
+goto end
+
+:version
+rem version information was requested. Return code should be 0.
+exit /B 0
+
+:end
diff --git a/opends/src/ads/org/opends/admin/ads/ADSContext.java b/opends/src/ads/org/opends/admin/ads/ADSContext.java
index 53059c8..71660b6 100644
--- a/opends/src/ads/org/opends/admin/ads/ADSContext.java
+++ b/opends/src/ads/org/opends/admin/ads/ADSContext.java
@@ -191,6 +191,9 @@
}
};
+ /** Default global admin UID. */
+ public static final String GLOBAL_ADMIN_UID = "admin";
+
private static HashMap<String, ServerProperty> nameToServerProperty = null;
/**
@@ -1219,7 +1222,7 @@
oc.add("top");
oc.add("person");
attrs.put(oc);
- attrs.put("sn", "admin");
+ attrs.put("sn", GLOBAL_ADMIN_UID);
if (adminProperties.containsKey(AdministratorProperty.DESCRIPTION))
{
attrs.put("description", adminProperties
diff --git a/opends/src/guitools/org/opends/guitools/statuspanel/ConfigFromFile.java b/opends/src/guitools/org/opends/guitools/statuspanel/ConfigFromFile.java
index 41c4b3f..4399a16 100644
--- a/opends/src/guitools/org/opends/guitools/statuspanel/ConfigFromFile.java
+++ b/opends/src/guitools/org/opends/guitools/statuspanel/ConfigFromFile.java
@@ -113,8 +113,7 @@
LDIFReader reader = null;
try
{
- Installation installation =
- new Installation(Utils.getInstallPathFromClasspath());
+ Installation installation = Installation.getLocal();
LDIFImportConfig c = new LDIFImportConfig(
Utils.getPath(installation.getCurrentConfigurationFile()));
reader = new LDIFReader(c);
diff --git a/opends/src/guitools/org/opends/guitools/statuspanel/ConfigFromLDAP.java b/opends/src/guitools/org/opends/guitools/statuspanel/ConfigFromLDAP.java
index b7b86b3..50537d4 100644
--- a/opends/src/guitools/org/opends/guitools/statuspanel/ConfigFromLDAP.java
+++ b/opends/src/guitools/org/opends/guitools/statuspanel/ConfigFromLDAP.java
@@ -46,6 +46,7 @@
import org.opends.quicksetup.util.Utils;
import org.opends.messages.Message;
+import org.opends.messages.QuickSetupMessages;
import static org.opends.messages.AdminToolMessages.*;
/**
@@ -209,7 +210,16 @@
{
detail = ne.toString();
}
- errorMessage = INFO_ERROR_READING_CONFIG_LDAP.get(detail);
+ if (Utils.isCertificateException(ne))
+ {
+ errorMessage =
+ QuickSetupMessages.INFO_ERROR_READING_CONFIG_LDAP_CERTIFICATE.get(
+ detail);
+ }
+ else
+ {
+ errorMessage = INFO_ERROR_READING_CONFIG_LDAP.get(detail);
+ }
}
catch (Throwable t)
{
diff --git a/opends/src/guitools/org/opends/guitools/statuspanel/StatusCli.java b/opends/src/guitools/org/opends/guitools/statuspanel/StatusCli.java
index 6800c6a..12b2cee 100644
--- a/opends/src/guitools/org/opends/guitools/statuspanel/StatusCli.java
+++ b/opends/src/guitools/org/opends/guitools/statuspanel/StatusCli.java
@@ -27,52 +27,32 @@
package org.opends.guitools.statuspanel;
-import java.io.BufferedReader;
import java.io.File;
-import java.io.FileInputStream;
-import java.io.FileReader;
-import java.io.IOException;
-import java.security.KeyStore;
-import java.security.KeyStoreException;
-import java.security.NoSuchAlgorithmException;
-import java.security.cert.CertificateException;
-import java.util.ArrayList;
import java.util.HashSet;
import java.util.Iterator;
import java.util.Set;
import java.util.TreeSet;
-import java.util.logging.Level;
import java.util.logging.Logger;
-import javax.net.ssl.KeyManager;
import javax.swing.table.TableModel;
-import org.opends.admin.ads.util.ApplicationKeyManager;
-import org.opends.admin.ads.util.ApplicationTrustManager;
import org.opends.guitools.statuspanel.ui.DatabasesTableModel;
import org.opends.guitools.statuspanel.ui.ListenersTableModel;
import org.opends.quicksetup.Installation;
import org.opends.quicksetup.QuickSetupLog;
import static org.opends.quicksetup.util.Utils.*;
+import org.opends.server.admin.client.cli.DsFrameworkCliReturnCode;
+import org.opends.server.admin.client.cli.SecureConnectionCliParser;
import org.opends.server.core.DirectoryServer;
-
import org.opends.messages.Message;
import org.opends.messages.MessageBuilder;
import static org.opends.messages.ToolMessages.*;
-import static org.opends.server.tools.ToolConstants.*;
import static org.opends.messages.AdminToolMessages.*;
import static org.opends.messages.QuickSetupMessages.*;
-import org.opends.server.util.PasswordReader;
-import org.opends.server.util.SelectableCertificateKeyManager;
-import org.opends.server.util.ServerConstants;
import org.opends.server.util.args.ArgumentException;
-import org.opends.server.util.args.ArgumentParser;
-import org.opends.server.util.args.BooleanArgument;
-import org.opends.server.util.args.FileBasedArgument;
-import org.opends.server.util.args.StringArgument;
/**
* The class used to provide some CLI interface to display status.
@@ -81,74 +61,18 @@
* in the command line.
*
*/
-class StatusCli
+class StatusCli extends SecureConnectionCliParser
{
- private static String LINE_SEPARATOR = System.getProperty("line.separator");
-
private String[] args;
private boolean displayMustAuthenticateLegend;
private boolean displayMustStartLegend;
/**
- * The 'trustAllArg' global argument.
- */
- private BooleanArgument trustAllArg = null;
-
- /**
- * The 'trustStore' global argument.
- */
- private StringArgument trustStorePathArg = null;
-
- /**
- * The 'trustStorePassword' global argument.
- */
- private StringArgument trustStorePasswordArg = null;
-
- /**
- * The 'trustStorePasswordFile' global argument.
- */
- private FileBasedArgument trustStorePasswordFileArg = null;
-
- /**
- * The 'keyStore' global argument.
- */
- private StringArgument keyStorePathArg = null;
-
- /**
- * The 'keyStorePassword' global argument.
- */
- private StringArgument keyStorePasswordArg = null;
-
- /**
- * The 'keyStorePasswordFile' global argument.
- */
- private FileBasedArgument keyStorePasswordFileArg = null;
-
- /**
- * The 'certNicknameArg' global argument.
- */
- private StringArgument certNicknameArg = null;
-
- /**
* The Logger.
*/
static private final Logger LOG = Logger.getLogger(StatusCli.class.getName());
-
- /**
- * Return code: Uninstall successful.
- */
- static int SUCCESSFUL = 0;
- /**
- * Return code: User provided invalid data.
- */
- static int USER_DATA_ERROR = 1;
- /**
- * Return code: Bug.
- */
- static int BUG = 2;
-
/**
* The main method which is called by the status command lines.
* @param args the arguments passed by the status command lines.
@@ -166,19 +90,9 @@
*/
StatusCli(String[] args)
{
- /* Ignore the first 4 arguments */
- if ((args != null) && (args.length >= 4))
- {
- this.args = new String[args.length - 4];
- for (int i=0; i<this.args.length; i++)
- {
- this.args[i] = args[i+4];
- }
- }
- else
- {
- this.args = args;
- }
+ super(org.opends.guitools.statuspanel.StatusCli.class.getName(),
+ INFO_STATUS_CLI_USAGE_DESCRIPTION.get(), false);
+ this.args = args;
DirectoryServer.bootstrapClient();
}
@@ -190,219 +104,46 @@
*/
int run()
{
- int returnValue = SUCCESSFUL;
-
- ArrayList<Message> errors = new ArrayList<Message>();
-
- String directoryManagerPwd = null;
- String directoryManagerPwdFile = null;
- String directoryManagerDn = null;
-
- ArgumentParser argParser =
- new ArgumentParser(StatusPanelLauncher.class.getName(),
- INFO_STATUS_CLI_USAGE_DESCRIPTION.get(), false);
- BooleanArgument showUsage;
- BooleanArgument useSSLArg;
- BooleanArgument startTLSArg;
- StringArgument bindDN;
- StringArgument bindPW;
- FileBasedArgument bindPWFile;
-
- String scriptName;
- if (isWindows()) {
- scriptName = Installation.WINDOWS_STATUSCLI_FILE_NAME;
- } else {
- scriptName = Installation.UNIX_STATUSCLI_FILE_NAME;
- }
- System.setProperty(ServerConstants.PROPERTY_SCRIPT_NAME, scriptName);
try
{
- useSSLArg = new BooleanArgument("useSSL", OPTION_SHORT_USE_SSL,
- OPTION_LONG_USE_SSL, INFO_DESCRIPTION_USE_SSL.get());
- argParser.addArgument(useSSLArg);
-
- startTLSArg = new BooleanArgument("startTLS", OPTION_SHORT_START_TLS,
- OPTION_LONG_START_TLS,
- INFO_DESCRIPTION_START_TLS.get());
- argParser.addArgument(startTLSArg);
-
- bindDN = new StringArgument("binddn", OPTION_SHORT_BINDDN,
- OPTION_LONG_BINDDN, false, false, true,
- OPTION_VALUE_BINDDN, "cn=Directory Manager", null,
- INFO_STOPDS_DESCRIPTION_BINDDN.get());
- argParser.addArgument(bindDN);
-
- bindPW = new StringArgument("bindpw", OPTION_SHORT_BINDPWD,
- OPTION_LONG_BINDPWD, false, false,
- true,
- OPTION_VALUE_BINDPWD, null, null,
- INFO_STOPDS_DESCRIPTION_BINDPW.get());
- argParser.addArgument(bindPW);
-
- bindPWFile = new FileBasedArgument("bindpwfile",
- OPTION_SHORT_BINDPWD_FILE,
- OPTION_LONG_BINDPWD_FILE,
- false, false,
- OPTION_VALUE_BINDPWD_FILE,
- null, null,
- INFO_STOPDS_DESCRIPTION_BINDPWFILE.get());
- argParser.addArgument(bindPWFile);
-
- trustAllArg = new BooleanArgument("trustAll", 'X', "trustAll",
- INFO_DESCRIPTION_TRUSTALL.get());
- argParser.addArgument(trustAllArg);
-
- trustStorePathArg = new StringArgument("trustStorePath",
- OPTION_SHORT_TRUSTSTOREPATH, OPTION_LONG_TRUSTSTOREPATH, false,
- false, true, OPTION_VALUE_TRUSTSTOREPATH, null, null,
- INFO_DESCRIPTION_TRUSTSTOREPATH.get());
- argParser.addArgument(trustStorePathArg);
-
- trustStorePasswordArg = new StringArgument("trustStorePassword", null,
- OPTION_LONG_TRUSTSTORE_PWD, false, false, true,
- OPTION_VALUE_TRUSTSTORE_PWD, null, null,
- INFO_DESCRIPTION_TRUSTSTOREPASSWORD.get());
- argParser.addArgument(trustStorePasswordArg);
-
- trustStorePasswordFileArg =
- new FileBasedArgument("truststorepasswordfile",
- OPTION_SHORT_TRUSTSTORE_PWD_FILE, OPTION_LONG_TRUSTSTORE_PWD_FILE,
- false, false, OPTION_VALUE_TRUSTSTORE_PWD_FILE, null, null,
- INFO_DESCRIPTION_TRUSTSTOREPASSWORD_FILE.get());
- argParser.addArgument(trustStorePasswordFileArg);
-
- keyStorePathArg = new StringArgument("keyStorePath",
- OPTION_SHORT_KEYSTOREPATH, OPTION_LONG_KEYSTOREPATH, false, false,
- true, OPTION_VALUE_KEYSTOREPATH, null, null,
- INFO_DESCRIPTION_KEYSTOREPATH.get());
- argParser.addArgument(keyStorePathArg);
-
- keyStorePasswordArg = new StringArgument("keyStorePassword", null,
- OPTION_LONG_KEYSTORE_PWD, false, false, true,
- OPTION_VALUE_KEYSTORE_PWD, null, null,
- INFO_DESCRIPTION_KEYSTOREPASSWORD.get());
- argParser.addArgument(keyStorePasswordArg);
-
- keyStorePasswordFileArg = new FileBasedArgument("keystorepasswordfile",
- OPTION_SHORT_KEYSTORE_PWD_FILE, OPTION_LONG_KEYSTORE_PWD_FILE, false,
- false, OPTION_VALUE_KEYSTORE_PWD_FILE, null, null,
- INFO_DESCRIPTION_KEYSTOREPASSWORD_FILE.get());
- argParser.addArgument(keyStorePasswordFileArg);
-
- certNicknameArg = new StringArgument("certnickname", 'N', "certNickname",
- false, false, true, "{nickname}", null, null,
- INFO_DESCRIPTION_CERT_NICKNAME.get());
- argParser.addArgument(certNicknameArg);
-
- showUsage = new BooleanArgument("showusage", OPTION_SHORT_HELP,
- OPTION_LONG_HELP,
- INFO_DESCRIPTION_USAGE.get());
- argParser.addArgument(showUsage);
- argParser.setUsageArgument(showUsage);
+ initializeGlobalOption(System.err);
+ removeGlobalArgument(portArg);
+ removeGlobalArgument(hostNameArg);
+ removeGlobalArgument(verboseArg);
}
catch (ArgumentException ae)
{
Message message = ERR_CANNOT_INITIALIZE_ARGS.get(ae.getMessage());
System.err.println(wrap(message));
- return BUG;
+ return DsFrameworkCliReturnCode.ERROR_UNEXPECTED.getReturnCode();
}
+ // Validate user provided data
try
{
- argParser.parseArguments(args);
- directoryManagerDn = bindDN.getValue();
- directoryManagerPwd = bindPW.getValue();
- directoryManagerPwdFile = bindPWFile.getValue();
+ parseArguments(args);
}
catch (ArgumentException ae)
{
Message message = ERR_ERROR_PARSING_ARGS.get(ae.getMessage());
-
System.err.println(wrap(message));
- System.err.println(argParser.getUsage());
- return USER_DATA_ERROR;
+ System.err.println(getUsage());
+
+ return DsFrameworkCliReturnCode.ERROR_PARSING_ARGS.getReturnCode();
}
// If we should just display usage or version information,
// then print it and exit.
- if (argParser.usageOrVersionDisplayed())
+ if (usageOrVersionDisplayed())
{
- return SUCCESSFUL;
+ return DsFrameworkCliReturnCode.SUCCESSFUL_NOP.getReturnCode();
}
+ int v = validateGlobalOption(System.err);
- if ((directoryManagerPwdFile != null) && (directoryManagerPwd != null))
+ if (v != DsFrameworkCliReturnCode.SUCCESSFUL_NOP.getReturnCode())
{
- errors.add(wrap(INFO_CLI_STATUS_PWD_AND_PWD_FILE_PROVIDED.get()));
- }
- else
- {
- if (directoryManagerPwd != null && directoryManagerPwd.equals("-"))
- {
- // read the password from stdin.
- try
- {
- System.out.print(INFO_CLI_STATUS_LDAPAUTH_PASSWORD_PROMPT.get(
- directoryManagerDn));
- char[] pwChars = PasswordReader.readPassword();
- directoryManagerPwd = new String(pwChars);
- } catch(Exception ex)
- {
- errors.add(Message.raw(ex.getMessage()));
- }
- }
- if (directoryManagerPwdFile != null)
- {
- directoryManagerPwd = readPwdFromFile(directoryManagerPwdFile);
- if (directoryManagerPwd == null)
- {
- errors.add(wrap(INFO_CLI_STATUS_ERROR_READING_PWD_FILE.get(
- directoryManagerPwdFile)));
- }
- }
- }
-
- // Couldn't have at the same time trustAll and
- // trustStore related arg
- if (trustAllArg.isPresent() && trustStorePathArg.isPresent())
- {
- errors.add(ERR_TOOL_CONFLICTING_ARGS.get(trustAllArg.getLongIdentifier(),
- trustStorePathArg.getLongIdentifier()));
- }
- if (trustAllArg.isPresent() && trustStorePasswordArg.isPresent())
- {
- errors.add(ERR_TOOL_CONFLICTING_ARGS.get(trustAllArg.getLongIdentifier(),
- trustStorePasswordArg.getLongIdentifier()));
- }
- if (trustAllArg.isPresent() && trustStorePasswordFileArg.isPresent())
- {
- errors.add(ERR_TOOL_CONFLICTING_ARGS.get(trustAllArg.getLongIdentifier(),
- trustStorePasswordFileArg.getLongIdentifier()));
- }
-
- // Couldn't have at the same time trustStorePasswordArg and
- // trustStorePasswordFileArg
- if (trustStorePasswordArg.isPresent()
- && trustStorePasswordFileArg.isPresent())
- {
- errors.add(ERR_TOOL_CONFLICTING_ARGS.get(trustStorePasswordArg
- .getLongIdentifier(), trustStorePasswordFileArg.getLongIdentifier()));
- }
-
- // Couldn't have at the same time startTLSArg and
- // useSSLArg
- if (startTLSArg.isPresent()
- && useSSLArg.isPresent())
- {
- errors.add(ERR_TOOL_CONFLICTING_ARGS.get(startTLSArg.getLongIdentifier(),
- useSSLArg.getLongIdentifier()));
- }
- if (errors.size() > 0)
- {
- System.err.println(getMessageFromCollection(errors,
- LINE_SEPARATOR+LINE_SEPARATOR).toString());
- System.err.println();
- System.err.println(argParser.getUsage());
- returnValue = USER_DATA_ERROR;
+ System.err.println(getUsage());
+ return v;
}
else
{
@@ -414,13 +155,13 @@
ConfigFromFile offLineConf = new ConfigFromFile();
offLineConf.readConfiguration();
- ServerStatusDescriptor desc = createServerStatusDescriptor(
- directoryManagerDn, directoryManagerPwd);
-
try
{
if (isServerRunning)
{
+ String directoryManagerDn = getBindDN();
+ String directoryManagerPwd = getBindPassword(directoryManagerDn,
+ System.out, System.err);
if (directoryManagerDn == null)
{
directoryManagerDn = "";
@@ -429,6 +170,8 @@
{
directoryManagerPwd = "";
}
+ ServerStatusDescriptor desc = createServerStatusDescriptor(
+ directoryManagerDn, directoryManagerPwd);
ConfigFromLDAP onLineConf = new ConfigFromLDAP();
ConnectionProtocolPolicy policy;
if (startTLSArg.isPresent())
@@ -446,15 +189,16 @@
onLineConf.setConnectionInfo(offLineConf, policy, directoryManagerDn,
directoryManagerPwd, getTrustManager());
onLineConf.readConfiguration();
- // TO COMPLETE: check the certificates
updateDescriptorWithOnLineInfo(desc, onLineConf);
+ writeStatus(desc);
}
else
{
+ ServerStatusDescriptor desc = createServerStatusDescriptor(null,
+ null);
updateDescriptorWithOffLineInfo(desc, offLineConf);
+ writeStatus(desc);
}
-
- writeStatus(desc);
}
catch (ConfigException ce)
{
@@ -462,39 +206,7 @@
}
}
- return returnValue;
- }
-
- /**
- * Returns the password stored in a file. Returns <CODE>null</CODE> if no
- * password is found.
- * @param path the path of the file containing the password.
- * @return the password stored in a file. Returns <CODE>null</CODE> if no
- * password is found.
- */
- private String readPwdFromFile(String path)
- {
- String pwd = null;
- BufferedReader reader = null;
- try
- {
- reader = new BufferedReader(new FileReader(path));
- pwd = reader.readLine();
- }
- catch (Exception e)
- {
- }
- finally
- {
- try
- {
- if (reader != null)
- {
- reader.close();
- }
- } catch (Exception e) {}
- }
- return pwd;
+ return DsFrameworkCliReturnCode.SUCCESSFUL_NOP.getReturnCode();
}
private ServerStatusDescriptor createServerStatusDescriptor(String dn,
@@ -1204,165 +916,6 @@
}
return centered;
}
-
- /**
- * Handle TrustStore.
- *
- * @return The trustStore manager to be used for the command.
- */
- public ApplicationTrustManager getTrustManager()
- {
- ApplicationTrustManager truststoreManager = null ;
- KeyStore truststore = null ;
- if (trustAllArg.isPresent())
- {
- // Running a null TrustManager will force createLdapsContext and
- // createStartTLSContext to use a bindTrustManager.
- return null ;
- }
- else
- if (trustStorePathArg.isPresent())
- {
- try
- {
- FileInputStream fos = new FileInputStream(trustStorePathArg.getValue());
- String trustStorePasswordStringValue = null;
- char[] trustStorePasswordValue = null;
- if (trustStorePasswordArg.isPresent())
- {
- trustStorePasswordStringValue = trustStorePasswordArg.getValue();
- }
- else if (trustStorePasswordFileArg.isPresent())
- {
- trustStorePasswordStringValue = trustStorePasswordFileArg.getValue();
- }
-
- if (trustStorePasswordStringValue != null)
- {
- trustStorePasswordStringValue = System
- .getProperty("javax.net.ssl.trustStorePassword");
- }
-
-
- if (trustStorePasswordStringValue != null)
- {
- trustStorePasswordValue = trustStorePasswordStringValue.toCharArray();
- }
-
- truststore = KeyStore.getInstance(KeyStore.getDefaultType());
- truststore.load(fos, trustStorePasswordValue);
- fos.close();
- }
- catch (KeyStoreException e)
- {
- // Nothing to do: if this occurs we will systematically refuse the
- // certificates. Maybe we should avoid this and be strict, but we are
- // in a best effor mode.
- LOG.log(Level.WARNING, "Error with the truststore", e);
- }
- catch (NoSuchAlgorithmException e)
- {
- // Nothing to do: if this occurs we will systematically refuse the
- // certificates. Maybe we should avoid this and be strict, but we are
- // in a best effor mode.
- LOG.log(Level.WARNING, "Error with the truststore", e);
- }
- catch (CertificateException e)
- {
- // Nothing to do: if this occurs we will systematically refuse the
- // certificates. Maybe we should avoid this and be strict, but we are
- // in a best effor mode.
- LOG.log(Level.WARNING, "Error with the truststore", e);
- }
- catch (IOException e)
- {
- // Nothing to do: if this occurs we will systematically refuse the
- // certificates. Maybe we should avoid this and be strict, but we are
- // in a best effor mode.
- LOG.log(Level.WARNING, "Error with the truststore", e);
- }
- }
- truststoreManager = new ApplicationTrustManager(truststore);
- return truststoreManager;
- }
-
- /**
- * Handle KeyStore.
- *
- * @return The keyStore manager to be used for the command.
- */
- public KeyManager getKeyManager()
- {
- KeyStore keyStore = null;
- String keyStorePasswordValue = null;
- if (keyStorePathArg.isPresent())
- {
- try
- {
- FileInputStream fos = new FileInputStream(keyStorePathArg.getValue());
- if (keyStorePasswordArg.isPresent())
- {
- keyStorePasswordValue = keyStorePasswordArg.getValue();
- }
- else if (keyStorePasswordFileArg.isPresent())
- {
- keyStorePasswordValue = keyStorePasswordFileArg.getValue();
- }
- keyStore = KeyStore.getInstance(KeyStore.getDefaultType());
- keyStore.load(fos, keyStorePasswordValue.toCharArray());
- }
- catch (KeyStoreException e)
- {
- // Nothing to do: if this occurs we will systematically refuse
- // the
- // certificates. Maybe we should avoid this and be strict, but
- // we are
- // in a best effor mode.
- LOG.log(Level.WARNING, "Error with the keystore", e);
- }
- catch (NoSuchAlgorithmException e)
- {
- // Nothing to do: if this occurs we will systematically refuse
- // the
- // certificates. Maybe we should avoid this and be strict, but
- // we are
- // in a best effor mode.
- LOG.log(Level.WARNING, "Error with the keystore", e);
- }
- catch (CertificateException e)
- {
- // Nothing to do: if this occurs we will systematically refuse
- // the
- // certificates. Maybe we should avoid this and be strict, but
- // we are
- // in a best effor mode.
- LOG.log(Level.WARNING, "Error with the keystore", e);
- }
- catch (IOException e)
- {
- // Nothing to do: if this occurs we will systematically refuse
- // the
- // certificates. Maybe we should avoid this and be strict, but
- // we are
- // in a best effor mode.
- LOG.log(Level.WARNING, "Error with the keystore", e);
- }
- ApplicationKeyManager akm = new ApplicationKeyManager(keyStore,
- keyStorePasswordValue.toCharArray());
- if (certNicknameArg.isPresent())
- {
- return new SelectableCertificateKeyManager(akm, certNicknameArg
- .getValue());
- }
- else
- {
- return akm;
- }
- }
- else
- {
- return null;
- }
- }
}
+
diff --git a/opends/src/guitools/org/opends/guitools/statuspanel/StatusPanelController.java b/opends/src/guitools/org/opends/guitools/statuspanel/StatusPanelController.java
index baada89..d924a48 100644
--- a/opends/src/guitools/org/opends/guitools/statuspanel/StatusPanelController.java
+++ b/opends/src/guitools/org/opends/guitools/statuspanel/StatusPanelController.java
@@ -558,8 +558,7 @@
getFormattedProgressWithLineBreak(INFO_PROGRESS_STARTING.get()));
ArrayList<String> argList = new ArrayList<String>();
- Installation installation =
- new Installation(Utils.getInstallPathFromClasspath());
+ Installation installation = Installation.getLocal();
argList.add(Utils.getPath(installation.getServerStartCommandFile()));
String[] args = new String[argList.size()];
@@ -678,8 +677,7 @@
getFormattedProgressWithLineBreak(INFO_PROGRESS_STOPPING.get()));
ArrayList<String> argList = new ArrayList<String>();
- Installation installation =
- new Installation(Utils.getInstallPathFromClasspath());
+ Installation installation = Installation.getLocal();
argList.add(Utils.getPath(installation.getServerStopCommandFile()));
String[] args = new String[argList.size()];
argList.toArray(args);
diff --git a/opends/src/guitools/org/opends/guitools/uninstaller/UninstallCliHelper.java b/opends/src/guitools/org/opends/guitools/uninstaller/UninstallCliHelper.java
index 725c60f..f6d57b2 100644
--- a/opends/src/guitools/org/opends/guitools/uninstaller/UninstallCliHelper.java
+++ b/opends/src/guitools/org/opends/guitools/uninstaller/UninstallCliHelper.java
@@ -27,22 +27,38 @@
package org.opends.guitools.uninstaller;
-import org.opends.admin.ads.util.ApplicationTrustManager;
-import org.opends.quicksetup.*;
-import org.opends.quicksetup.util.Utils;
-import org.opends.server.util.args.Argument;
-import org.opends.server.util.args.ArgumentException;
-import org.opends.server.util.args.ArgumentParser;
+import org.opends.server.admin.client.cli.DsFrameworkCliReturnCode;
+import org.opends.admin.ads.ADSContext;
+import org.opends.admin.ads.ServerDescriptor;
+import org.opends.admin.ads.TopologyCache;
+import org.opends.admin.ads.TopologyCacheException;
+import org.opends.admin.ads.util.ApplicationTrustManager;
+import org.opends.guitools.statuspanel.ConfigFromFile;
+import org.opends.messages.Message;
+import org.opends.messages.MessageBuilder;
+
+import static org.opends.messages.AdminToolMessages.*;
+import static org.opends.messages.QuickSetupMessages.*;
+import org.opends.quicksetup.*;
+import org.opends.quicksetup.event.ProgressUpdateEvent;
+import org.opends.quicksetup.event.ProgressUpdateListener;
+import org.opends.quicksetup.util.PlainTextProgressMessageFormatter;
+import org.opends.quicksetup.util.ServerController;
+import org.opends.quicksetup.util.Utils;
+import org.opends.server.util.args.ArgumentException;
+
+
+import java.util.HashSet;
+import java.util.LinkedHashSet;
import java.util.Set;
import java.util.Collections;
import java.util.logging.Level;
import java.util.logging.Logger;
import java.io.IOException;
-import org.opends.messages.Message;
-import static org.opends.messages.AdminToolMessages.*;
-
+import javax.naming.NamingException;
+import javax.naming.ldap.InitialLdapContext;
/**
* The class used to provide some CLI interface in the uninstall.
@@ -59,6 +75,8 @@
static private final Logger LOG =
Logger.getLogger(UninstallCliHelper.class.getName());
+ private UninstallerArgumentParser parser;
+
/**
* Creates a UserData based in the arguments provided. It asks
* user for additional information if what is provided in the arguments is not
@@ -66,25 +84,23 @@
* @param args the ArgumentParser with the allowed arguments of the command
* line.
* @param rawArguments the arguments provided in the command line.
- * @param trustManager the Application Trust Manager to be used to connect
- * to the remote servers.
* @return the UserData object with what the user wants to uninstall
* and null if the user cancels the uninstallation.
* @throws UserDataException if there is an error parsing the data
* in the arguments.
*/
- public UninstallUserData createUserData(ArgumentParser args,
- String[] rawArguments, ApplicationTrustManager trustManager)
+ public UninstallUserData createUserData(UninstallerArgumentParser args,
+ String[] rawArguments)
throws UserDataException
{
+ parser = args;
UninstallUserData userData = new UninstallUserData();
boolean isInteractive;
boolean isSilent;
boolean isCancelled = false;
- /* Step 1: analyze the arguments. We assume that the arguments have
- * already been parsed.
+ /* Step 1: analyze the arguments.
*/
try
{
@@ -95,16 +111,27 @@
throw new UserDataException(null, ae.getMessageObject());
}
- Argument interactive = args.getArgumentForLongID(INTERACTIVE_OPTION_LONG);
- isInteractive = interactive != null && interactive.isPresent();
+ isInteractive = args.isInteractive();
- Argument silent = args.getArgumentForLongID(SILENT_OPTION_LONG);
- isSilent = silent != null && silent.isPresent();
+ isSilent = args.isSilent();
userData.setSilent(isSilent);
+ userData.setForceOnError(args.isForceOnError());
+ userData.setTrustManager(args.getTrustManager());
- /* Step 2: If this is an interactive uninstall ask for confirmation to
- * delete the different parts of the installation.
+ /* Step 2: check that the provided parameters are compatible.
+ */
+ MessageBuilder buf = new MessageBuilder();
+ int v = args.validateGlobalOption(buf);
+ if (v != DsFrameworkCliReturnCode.SUCCESSFUL_NOP.getReturnCode())
+ {
+ throw new UserDataException(null, buf.toMessage());
+ }
+
+ /* Step 3: If this is an interactive uninstall ask for confirmation to
+ * delete the different parts of the installation if the user did not
+ * specify anything to delete. If we are not in interactive mode
+ * check that the user specified something to be deleted.
*/
Set<String> outsideDbs;
Set<String> outsideLogs;
@@ -124,37 +151,70 @@
LOG.log(Level.INFO, "error determining outside logs", ioe);
}
- if (!isInteractive)
+ boolean somethingSpecifiedToDelete =
+ args.removeAll() ||
+ args.removeBackupFiles() ||
+ args.removeDatabases() ||
+ args.removeLDIFFiles() ||
+ args.removeConfigurationFiles() ||
+ args.removeLogFiles() ||
+ args.removeServerLibraries();
+
+ if (somethingSpecifiedToDelete)
{
- userData.setRemoveBackups(true);
- userData.setRemoveConfigurationAndSchema(true);
- userData.setRemoveDatabases(true);
- userData.setRemoveLDIFs(true);
- userData.setRemoveLibrariesAndTools(true);
- userData.setRemoveLogs(true);
+ userData.setRemoveBackups(args.removeAll() || args.removeBackupFiles());
+ userData.setRemoveConfigurationAndSchema(args.removeAll() ||
+ args.removeConfigurationFiles());
+ userData.setRemoveDatabases(args.removeAll() || args.removeDatabases());
+ userData.setRemoveLDIFs(args.removeAll() || args.removeLDIFFiles());
+ userData.setRemoveLibrariesAndTools(args.removeAll() ||
+ args.removeServerLibraries());
+ userData.setRemoveLogs(args.removeAll() || args.removeLogFiles());
userData.setExternalDbsToRemove(outsideDbs);
userData.setExternalLogsToRemove(outsideLogs);
}
else
{
- isCancelled = askWhatToDelete(userData, outsideDbs, outsideLogs);
+ if (!isInteractive)
+ {
+ throw new UserDataException(null,
+ INFO_CLI_UNINSTALL_NOTHING_TO_BE_UNINSTALLED_NON_INTERACTIVE.get());
+ }
+ else
+ {
+ isCancelled = askWhatToDelete(userData, outsideDbs, outsideLogs);
+ }
}
+ String adminUid = args.getAdministratorUID();
+ if ((adminUid == null) && !args.isInteractive())
+ {
+ adminUid = args.getDefaultAdministratorUID();
+ }
+ userData.setAdminUID(adminUid);
+ userData.setAdminPwd(args.getBindPassword());
+ String referencedHostName = args.getReferencedHostName();
+ if ((referencedHostName == null) && !args.isInteractive())
+ {
+ referencedHostName = args.getDefaultReferencedHostName();
+ }
+ userData.setReferencedHostName(referencedHostName);
/*
- * Step 3: check if server is running. Depending if it is running and the
+ * Step 4: check if server is running. Depending if it is running and the
* OS we are running, ask for authentication information.
*/
if (!isCancelled)
{
- isCancelled = askConfirmationToStop(userData, isInteractive);
+ isCancelled = checkServerState(userData, isInteractive);
}
- if (isCancelled)
+ if (isCancelled && !userData.isForceOnError())
{
userData = null;
}
+
return userData;
}
@@ -183,11 +243,11 @@
Message answer = promptConfirm(
INFO_CLI_UNINSTALL_WHAT_TO_DELETE.get(),
options[0], options);
- if (options[2].equals(answer))
+ if (options[2].toString().equals(answer.toString()))
{
cancelled = true;
}
- else if ("1".equals(answer))
+ else if (options[0].toString().equals(answer.toString()))
{
userData.setRemoveBackups(true);
userData.setRemoveConfigurationAndSchema(true);
@@ -221,11 +281,12 @@
)
};
+
Message[] validValues = {
- INFO_CLI_UNINSTALL_YES_LONG.get(),
- INFO_CLI_UNINSTALL_NO_LONG.get(),
- INFO_CLI_UNINSTALL_YES_SHORT.get(),
- INFO_CLI_UNINSTALL_NO_SHORT.get()
+ INFO_CLI_YES_LONG.get(),
+ INFO_CLI_NO_LONG.get(),
+ INFO_CLI_YES_SHORT.get(),
+ INFO_CLI_NO_SHORT.get()
};
boolean[] answers = new boolean[keys.length];
for (int i=0; i<keys.length; i++)
@@ -236,13 +297,13 @@
{
Message msg = keys[i];
answer = promptConfirm(
- msg, INFO_CLI_UNINSTALL_YES_LONG.get(),
+ msg, INFO_CLI_YES_LONG.get(),
validValues);
answers[i] =
- INFO_CLI_UNINSTALL_YES_LONG.get().toString().
+ INFO_CLI_YES_LONG.get().toString().
equalsIgnoreCase(answer.toString()) ||
- INFO_CLI_UNINSTALL_YES_SHORT.get().toString().
+ INFO_CLI_YES_SHORT.get().toString().
equalsIgnoreCase(answer.toString());
}
else
@@ -304,8 +365,8 @@
!userData.getRemoveLogs())
{
somethingSelected = false;
- System.out.println(Constants.LINE_SEPARATOR+
- INFO_CLI_UNINSTALL_NOTHING_TO_BE_UNINSTALLED.get());
+ printLineBreak();
+ printErrorMessage(INFO_CLI_UNINSTALL_NOTHING_TO_BE_UNINSTALLED.get());
}
else
{
@@ -319,8 +380,7 @@
/**
* Commodity method used to ask the user (when necessary) if the server must
- * be stopped or not. If required it also asks the user authentication to
- * be able to shut down the server in Windows.
+ * be stopped or not. It also prompts (if required) for authentication.
* @param userData the UserData object to be updated with the
* authentication of the user.
* @param interactive boolean telling whether this is an interactive uninstall
@@ -331,33 +391,145 @@
* provided by the user (in the particular case where we are on silent
* uninstall and some data is missing or not valid).
*/
- private boolean askConfirmationToStop(UserData userData,
+ private boolean checkServerState(UninstallUserData userData,
boolean interactive)
throws UserDataException
{
boolean cancelled = false;
- Status status = Installation.getLocal().getStatus();
- if (status.isServerRunning())
+ UninstallData conf = null;
+ try
{
+ conf = new UninstallData(Installation.getLocal());
+ }
+ catch (Throwable t)
+ {
+ LOG.log(Level.WARNING, "Error processing task: "+t, t);
+ throw new UserDataException(Step.CONFIRM_UNINSTALL,
+ Utils.getThrowableMsg(INFO_BUG_MSG.get(), t));
+ }
+ if (conf.isADS() && conf.isReplicationServer())
+ {
+ if (conf.isServerRunning())
+ {
if (interactive)
{
+ if (confirmToUpdateRemote())
+ {
+ cancelled = !askForAuthenticationIfNeeded(userData);
+ if (cancelled)
+ {
+ /* Ask for confirmation to stop server */
+ cancelled = !confirmToStopServer();
+ }
+ else
+ {
+ cancelled = !updateUserUninstallDataWithRemoteServers(userData,
+ interactive);
+ if (cancelled)
+ {
+ /* Ask for confirmation to stop server */
+ cancelled = !confirmToStopServer();
+ }
+ }
+ }
+ else
+ {
/* Ask for confirmation to stop server */
cancelled = !confirmToStopServer();
+ }
+ }
+ else
+ {
+ cancelled =
+ !updateUserUninstallDataWithRemoteServers(userData, interactive);
+ }
+ }
+ else
+ {
+ if (interactive)
+ {
+ if (confirmToUpdateRemoteAndStart())
+ {
+ boolean startWorked = startServer(userData.isSilent());
+ // Ask for authentication if needed, etc.
+ if (startWorked)
+ {
+ cancelled = !askForAuthenticationIfNeeded(userData);
+ if (cancelled)
+ {
+ /* Ask for confirmation to stop server */
+ cancelled = !confirmToStopServer();
+ }
+ else
+ {
+ cancelled = !updateUserUninstallDataWithRemoteServers(userData,
+ interactive);
+ if (cancelled)
+ {
+ /* Ask for confirmation to stop server */
+ cancelled = !confirmToStopServer();
+ }
+ }
+ }
+ else
+ {
+ userData.setStopServer(false);
+ if (interactive)
+ {
+ /* Ask for confirmation to delete files */
+ cancelled = !confirmDeleteFiles();
+ }
+ }
+ }
+ else
+ {
+ /* Ask for confirmation to stop server */
+ cancelled = !confirmToStopServer();
+ }
+ }
+ else
+ {
+ boolean startWorked = startServer(userData.isSilent());
+ // Ask for authentication if needed, etc.
+ if (startWorked)
+ {
+ userData.setStopServer(true);
+ cancelled =
+ !updateUserUninstallDataWithRemoteServers(userData, interactive);
+ }
+ else
+ {
+ cancelled = !userData.isForceOnError();
+ userData.setStopServer(false);
+ }
+ }
+ }
+ }
+ else
+ {
+ if (conf.isServerRunning())
+ {
+ if (interactive)
+ {
+ /* Ask for confirmation to stop server */
+ cancelled = !confirmToStopServer();
}
if (!cancelled)
{
- /* During all the confirmations, the server might be stopped. */
- userData.setStopServer(status.isServerRunning());
+ /* During all the confirmations, the server might be stopped. */
+ userData.setStopServer(
+ Installation.getLocal().getStatus().isServerRunning());
}
- }
- else
- {
- userData.setStopServer(false);
- if (interactive)
+ }
+ else
{
- /* Ask for confirmation to delete files */
- cancelled = !confirmDeleteFiles();
+ userData.setStopServer(false);
+ if (interactive)
+ {
+ /* Ask for confirmation to delete files */
+ cancelled = !confirmDeleteFiles();
+ }
}
}
return cancelled;
@@ -386,20 +558,504 @@
private boolean confirm(Message msg) {
boolean confirm = true;
Message[] validValues = {
- INFO_CLI_UNINSTALL_YES_SHORT.get(),
- INFO_CLI_UNINSTALL_NO_SHORT.get(),
- INFO_CLI_UNINSTALL_YES_LONG.get(),
- INFO_CLI_UNINSTALL_NO_LONG.get(),
+ INFO_CLI_YES_SHORT.get(),
+ INFO_CLI_NO_SHORT.get(),
+ INFO_CLI_YES_LONG.get(),
+ INFO_CLI_NO_LONG.get(),
};
Message answer = promptConfirm(msg, validValues[2], validValues);
-
- if (INFO_CLI_UNINSTALL_NO_SHORT.get().toString()
+ if (INFO_CLI_NO_SHORT.get().toString()
.equalsIgnoreCase(answer.toString()) ||
- INFO_CLI_UNINSTALL_NO_LONG.get().toString()
+ INFO_CLI_NO_LONG.get().toString()
.equalsIgnoreCase(answer.toString()))
{
confirm = false;
}
return confirm;
}
+
+ /**
+ * Ask for confirmation to update configuration on remote servers.
+ * @return <CODE>true</CODE> if the user wants to continue and stop the
+ * server. <CODE>false</CODE> otherwise.
+ */
+ private boolean confirmToUpdateRemote()
+ {
+ return confirm(INFO_CLI_UNINSTALL_CONFIRM_UPDATE_REMOTE.get());
+ }
+
+ /**
+ * Ask for confirmation to update configuration on remote servers.
+ * @return <CODE>true</CODE> if the user wants to continue and stop the
+ * server. <CODE>false</CODE> otherwise.
+ */
+ private boolean confirmToUpdateRemoteAndStart()
+ {
+ return confirm(INFO_CLI_UNINSTALL_CONFIRM_UPDATE_REMOTE_AND_START.get());
+ }
+
+ /**
+ * Ask for confirmation to provide again authentication.
+ * @return <CODE>true</CODE> if the user wants to provide authentication
+ * againr. <CODE>false</CODE> otherwise.
+ */
+ private boolean promptToProvideAuthenticationAgain()
+ {
+ return confirm(INFO_UNINSTALL_CONFIRM_PROVIDE_AUTHENTICATION_AGAIN.get());
+ }
+
+ /**
+ * Ask for data required to update configuration on remote servers. If
+ * all the data is provided and validated, we assume that the user wants
+ * to update the remote servers.
+ * @return <CODE>true</CODE> if the user wants to continue and update the
+ * remote servers. <CODE>false</CODE> otherwise.
+ */
+ private boolean askForAuthenticationIfNeeded(UninstallUserData userData)
+ {
+ boolean accepted = true;
+ String uid = userData.getAdminUID();
+ String pwd = userData.getAdminPwd();
+ boolean couldConnect = false;
+ ConfigFromFile conf = new ConfigFromFile();
+ conf.readConfiguration();
+ String ldapUrl = conf.getLDAPURL();
+ String startTlsUrl = conf.getStartTLSURL();
+ String ldapsUrl = conf.getLDAPSURL();
+ while (!couldConnect && accepted)
+ {
+ while (uid == null)
+ {
+ uid = askForAdministratorUID();
+ }
+ while (pwd == null)
+ {
+ pwd = askForAdministratorPwd();
+ }
+ userData.setAdminUID(uid);
+ userData.setAdminPwd(pwd);
+ InitialLdapContext ctx = null;
+ String usedUrl = null;
+ try
+ {
+ String dn = ADSContext.getAdministratorDN(uid);
+ if ((ldapsUrl != null) && (parser.useSSL() || !parser.startTLS()))
+ {
+ usedUrl = ldapsUrl;
+ ctx = Utils.createLdapsContext(ldapsUrl, dn, pwd,
+ Utils.getDefaultLDAPTimeout(), null, userData.getTrustManager());
+ }
+ else if ((startTlsUrl != null) &&
+ (!parser.useSSL() || parser.startTLS()))
+ {
+ usedUrl = startTlsUrl;
+ ctx = Utils.createStartTLSContext(startTlsUrl, dn, pwd,
+ Utils.getDefaultLDAPTimeout(), null, userData.getTrustManager(),
+ null);
+ }
+ else if ((ldapUrl != null) && !parser.useSSL() && !parser.startTLS())
+ {
+ usedUrl = ldapUrl;
+ ctx = Utils.createLdapContext(ldapUrl, dn, pwd,
+ Utils.getDefaultLDAPTimeout(), null);
+ }
+ else
+ {
+
+ LOG.log(Level.WARNING,
+ "Error retrieving a valid LDAP URL in conf file");
+ printErrorMessage(INFO_COULD_NOT_FIND_VALID_LDAPURL.get());
+ }
+ if (usedUrl != null)
+ {
+ userData.setLocalServerUrl(usedUrl);
+ couldConnect = true;
+ }
+ } catch (NamingException ne)
+ {
+ LOG.log(Level.WARNING, "Error connecting to server: "+ne, ne);
+
+ if (Utils.isCertificateException(ne))
+ {
+ accepted = promptForCertificateConfirmation(ne,
+ userData.getTrustManager(), usedUrl);
+ }
+ else
+ {
+ uid = null;
+ pwd = null;
+ printLineBreak();
+ printErrorMessage(
+ Utils.getThrowableMsg(INFO_ERROR_CONNECTING_TO_LOCAL.get(), ne));
+ accepted = promptToProvideAuthenticationAgain();
+ }
+
+ } catch (Throwable t)
+ {
+ LOG.log(Level.WARNING, "Error connecting to server: "+t, t);
+ uid = null;
+ pwd = null;
+ printErrorMessage(Utils.getThrowableMsg(INFO_BUG_MSG.get(), t));
+ accepted = promptToProvideAuthenticationAgain();
+ }
+ finally
+ {
+ if (ctx != null)
+ {
+ try
+ {
+ ctx.close();
+ }
+ catch (Throwable t)
+ {
+ LOG.log(Level.INFO, "Error closing connection: "+t, t);
+ }
+ }
+ }
+ }
+
+ if (accepted)
+ {
+ String referencedHostName = userData.getReferencedHostName();
+ while (referencedHostName == null)
+ {
+ referencedHostName = askForReferencedHostName(userData.getHostName());
+ }
+ userData.setReferencedHostName(referencedHostName);
+ }
+ userData.setUpdateRemoteReplication(accepted);
+ return accepted;
+ }
+
+ private String askForAdministratorUID()
+ {
+ return promptForString(INFO_UNINSTALL_CLI_ADMINISTRATOR_UID_PROMPT.get(),
+ Constants.GLOBAL_ADMIN_UID);
+ }
+
+ private String askForAdministratorPwd()
+ {
+ return promptForPassword(INFO_UNINSTALL_CLI_ADMINISTRATOR_PWD_PROMPT.get());
+ }
+
+ private String askForReferencedHostName(String defaultHostName)
+ {
+ return promptForString(INFO_UNINSTALL_CLI_REFERENCED_HOSTNAME_PROMPT.get(),
+ defaultHostName);
+ }
+
+ private boolean startServer(boolean supressOutput)
+ {
+ boolean serverStarted = false;
+ Application application = new Application()
+ {
+ /**
+ * {@inheritDoc}
+ */
+ public String getInstallationPath()
+ {
+ return Installation.getLocal().getRootDirectory().getAbsolutePath();
+ }
+ /**
+ * {@inheritDoc}
+ */
+ public ProgressStep getCurrentProgressStep()
+ {
+ return UninstallProgressStep.NOT_STARTED;
+ }
+ /**
+ * {@inheritDoc}
+ */
+ public Integer getRatio(ProgressStep step)
+ {
+ return 0;
+ }
+ /**
+ * {@inheritDoc}
+ */
+ public Message getSummary(ProgressStep step)
+ {
+ return null;
+ }
+ /**
+ * {@inheritDoc}
+ */
+ public boolean isFinished()
+ {
+ return false;
+ }
+ /**
+ * {@inheritDoc}
+ */
+ public boolean isCancellable()
+ {
+ return false;
+ }
+ /**
+ * {@inheritDoc}
+ */
+ public void cancel()
+ {
+ }
+ /**
+ * {@inheritDoc}
+ */
+ public void run()
+ {
+ }
+ };
+ application.setProgressMessageFormatter(
+ new PlainTextProgressMessageFormatter());
+ if (!supressOutput)
+ {
+ application.addProgressUpdateListener(
+ new ProgressUpdateListener() {
+ public void progressUpdate(ProgressUpdateEvent ev) {
+ System.out.print(ev.getNewLogs().toString());
+ System.out.flush();
+ }
+ });
+ }
+ ServerController controller = new ServerController(application,
+ Installation.getLocal());
+ try
+ {
+ if (!supressOutput)
+ {
+ printLineBreak();
+ }
+ controller.startServer(supressOutput);
+ if (!supressOutput)
+ {
+ printLineBreak();
+ }
+ serverStarted = Installation.getLocal().getStatus().isServerRunning();
+ }
+ catch (ApplicationException ae)
+ {
+ if (!supressOutput)
+ {
+ printErrorMessage(ae.getMessage());
+ }
+ }
+ return serverStarted;
+ }
+
+ /**
+ * Updates the contents of the UninstallUserData while trying to connect
+ * to the remote servers. It returns <CODE>true</CODE> if we could connect
+ * to the remote servers and all the presented certificates were accepted and
+ * <CODE>false</CODE> otherwise.
+ * continue if
+ * @param userData the user data to be updated.
+ * @param interactive whether we are in interactive mode or not.
+ * @return <CODE>true</CODE> if we could connect
+ * to the remote servers and all the presented certificates were accepted and
+ * <CODE>false</CODE> otherwise.
+ */
+ private boolean updateUserUninstallDataWithRemoteServers(
+ UninstallUserData userData, boolean interactive)
+ {
+ boolean accepted = false;
+ InitialLdapContext ctx = null;
+ try
+ {
+ ConfigFromFile conf = new ConfigFromFile();
+ conf.readConfiguration();
+ String ldapUrl = conf.getLDAPURL();
+ String startTlsUrl = conf.getStartTLSURL();
+ String ldapsUrl = conf.getLDAPSURL();
+ String adminUid = userData.getAdminUID();
+ String pwd = userData.getAdminPwd();
+ String dn = ADSContext.getAdministratorDN(adminUid);
+ if ((ldapsUrl != null) && (parser.useSSL() || !parser.startTLS()))
+ {
+ ctx = Utils.createLdapsContext(ldapsUrl, dn, pwd,
+ Utils.getDefaultLDAPTimeout(), null, userData.getTrustManager());
+ }
+ else if ((startTlsUrl != null) &&
+ (!parser.useSSL() || parser.startTLS()))
+ {
+ ctx = Utils.createStartTLSContext(startTlsUrl, dn, pwd,
+ Utils.getDefaultLDAPTimeout(), null, userData.getTrustManager(),
+ null);
+ }
+ else if ((ldapUrl != null) && !parser.useSSL() && !parser.startTLS())
+ {
+ ctx = Utils.createLdapContext(ldapUrl, dn, pwd,
+ Utils.getDefaultLDAPTimeout(), null);
+ }
+ else
+ {
+ LOG.log(Level.WARNING,
+ "Error retrieving a valid LDAP URL in conf file");
+ printErrorMessage(INFO_COULD_NOT_FIND_VALID_LDAPURL.get());
+ }
+ ADSContext adsContext = new ADSContext(ctx);
+ TopologyCache cache = new TopologyCache(adsContext,
+ userData.getTrustManager());
+ cache.reloadTopology();
+
+ accepted = handleTopologyCache(cache, interactive, userData);
+ userData.setRemoteServers(cache.getServers());
+ } catch (NamingException ne)
+ {
+ LOG.log(Level.WARNING, "Error connecting to server: "+ne, ne);
+ if (Utils.isCertificateException(ne))
+ {
+ printLineBreak();
+ printErrorMessage(INFO_ERROR_READING_CONFIG_LDAP_CERTIFICATE.get(
+ ne.getMessage()));
+ }
+ else
+ {
+ printLineBreak();
+ printErrorMessage(
+ Utils.getThrowableMsg(INFO_ERROR_CONNECTING_TO_LOCAL.get(), ne));
+ }
+ } catch (TopologyCacheException te)
+ {
+ LOG.log(Level.WARNING, "Error connecting to server: "+te, te);
+ printErrorMessage(Utils.getStringRepresentation(te));
+
+ } catch (Throwable t)
+ {
+ LOG.log(Level.WARNING, "Error connecting to server: "+t, t);
+ printErrorMessage(Utils.getThrowableMsg(INFO_BUG_MSG.get(), t));
+ }
+ finally
+ {
+ if (ctx != null)
+ {
+ try
+ {
+ ctx.close();
+ }
+ catch (Throwable t)
+ {
+ LOG.log(Level.INFO, "Error closing connection: "+t, t);
+ }
+ }
+ }
+ userData.setUpdateRemoteReplication(accepted);
+ return accepted;
+ }
+
+ /**
+ * Method that interacts with the user depending on what errors where
+ * encountered in the TopologyCache object. This method assumes that the
+ * TopologyCache has been reloaded.
+ * Returns <CODE>true</CODE> if the user accepts all the problems encountered
+ * and <CODE>false</CODE> otherwise.
+ * @param userData the user data.
+ * @param interactive if we are in interactive mode or not.
+ */
+ private boolean handleTopologyCache(TopologyCache cache, boolean interactive,
+ UninstallUserData userData)
+ {
+ boolean returnValue;
+ boolean stopProcessing = false;
+ boolean reloadTopologyCache = false;
+ ApplicationTrustManager trustManager = userData.getTrustManager();
+ Set<TopologyCacheException> exceptions =
+ new HashSet<TopologyCacheException>();
+ /* Analyze if we had any exception while loading servers. For the moment
+ * only throw the exception found if the user did not provide the
+ * Administrator DN and this caused a problem authenticating in one server
+ * or if there is a certificate problem.
+ */
+ Set<ServerDescriptor> servers = cache.getServers();
+ for (ServerDescriptor server : servers)
+ {
+ TopologyCacheException e = server.getLastException();
+ if (e != null)
+ {
+ exceptions.add(e);
+ }
+ }
+ Set<String> exceptionMsgs = new LinkedHashSet<String>();
+ /* Check the exceptions and see if we throw them or not. */
+ for (TopologyCacheException e : exceptions)
+ {
+ if (stopProcessing)
+ {
+ break;
+ }
+ switch (e.getType())
+ {
+ case NOT_GLOBAL_ADMINISTRATOR:
+ printErrorMessage(INFO_NOT_GLOBAL_ADMINISTRATOR_PROVIDED.get());
+ stopProcessing = true;
+ break;
+ case GENERIC_CREATING_CONNECTION:
+ if ((e.getCause() != null) &&
+ Utils.isCertificateException(e.getCause()))
+ {
+ if (interactive)
+ {
+ if (promptForCertificateConfirmation(e.getCause(),
+ trustManager, e.getLdapUrl()))
+ {
+ stopProcessing = true;
+ reloadTopologyCache = true;
+ }
+ else
+ {
+ stopProcessing = true;
+ }
+ }
+ else
+ {
+ stopProcessing = true;
+ String url = e.getLdapUrl();
+ int index = url.indexOf("//");
+ String hostPort = url.substring(index + 2);
+ printErrorMessage(
+ INFO_ERROR_READING_CONFIG_LDAP_CERTIFICATE_SERVER.get(
+ hostPort, e.getCause().getMessage()));
+ }
+ }
+ else
+ {
+ exceptionMsgs.add(Utils.getStringRepresentation(e));
+ }
+ break;
+ default:
+ exceptionMsgs.add(Utils.getStringRepresentation(e));
+ }
+ }
+ if (interactive)
+ {
+ if (!stopProcessing && (exceptionMsgs.size() > 0))
+ {
+ returnValue = confirm(
+ INFO_ERROR_READING_REGISTERED_SERVERS_CONFIRM_UPDATE_REMOTE.get(
+ Utils.getStringFromCollection(exceptionMsgs,
+ Constants.LINE_SEPARATOR)));
+ }
+ else if (reloadTopologyCache)
+ {
+ returnValue = updateUserUninstallDataWithRemoteServers(userData,
+ interactive);
+ }
+ else
+ {
+ returnValue = !stopProcessing;
+ }
+ }
+ else
+ {
+ if (exceptionMsgs.size() > 0)
+ {
+ printErrorMessage(Utils.getStringFromCollection(exceptionMsgs,
+ Constants.LINE_SEPARATOR));
+ returnValue = false;
+ }
+ else
+ {
+ returnValue = true;
+ }
+ }
+ return returnValue;
+ }
}
diff --git a/opends/src/guitools/org/opends/guitools/uninstaller/UninstallGuiLauncher.java b/opends/src/guitools/org/opends/guitools/uninstaller/UninstallGuiLauncher.java
new file mode 100644
index 0000000..3440e6c
--- /dev/null
+++ b/opends/src/guitools/org/opends/guitools/uninstaller/UninstallGuiLauncher.java
@@ -0,0 +1,179 @@
+/*
+ * 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
+ * trunk/opends/resource/legal-notices/OpenDS.LICENSE
+ * or https://OpenDS.dev.java.net/OpenDS.LICENSE.
+ * 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
+ *
+ *
+ * Portions Copyright 2007 Sun Microsystems, Inc.
+ */
+
+package org.opends.guitools.uninstaller;
+
+import static org.opends.messages.ToolMessages.INFO_DESCRIPTION_SHOWUSAGE;
+import static org.opends.server.tools.ToolConstants.OPTION_LONG_HELP;
+import static org.opends.server.tools.ToolConstants.OPTION_SHORT_HELP;
+
+import java.io.File;
+import java.util.logging.Logger;
+
+import org.opends.quicksetup.ApplicationReturnCode;
+import org.opends.quicksetup.Installation;
+import org.opends.quicksetup.QuickSetupLog;
+import org.opends.quicksetup.util.Utils;
+import org.opends.messages.AdminToolMessages;
+import org.opends.messages.ToolMessages;
+import org.opends.server.util.ServerConstants;
+import org.opends.server.util.args.ArgumentException;
+import org.opends.server.util.args.ArgumentParser;
+import org.opends.server.util.args.BooleanArgument;
+
+/**
+ * This class is called by the uninstall command lines to launch the uninstall
+ * of the Directory Server. It just checks the command line arguments and the
+ * environment and determines whether the graphical or the command line
+ * based uninstall much be launched.
+ */
+public class UninstallGuiLauncher extends UninstallLauncher {
+
+ /** Prefix for log files. */
+ static public final String LOG_FILE_PREFIX = "opends-uninstall-cli-";
+
+ /** Suffix for log files. */
+ static public final String LOG_FILE_SUFFIX = ".log";
+
+ static private final Logger LOG =
+ Logger.getLogger(UninstallGuiLauncher.class.getName());
+
+ /**
+ * The main method which is called by the uninstall command lines.
+ *
+ * @param args the arguments passed by the command lines. In the case
+ * we want to launch the cli setup they are basically the arguments that we
+ * will pass to the org.opends.server.tools.InstallDS class.
+ */
+ public static void main(String[] args) {
+ try {
+ QuickSetupLog.initLogFileHandler(
+ File.createTempFile(LOG_FILE_PREFIX, LOG_FILE_SUFFIX),
+ "org.opends.guitools.uninstaller");
+
+ } catch (Throwable t) {
+ System.err.println("Unable to initialize log");
+ t.printStackTrace();
+ }
+ new UninstallGuiLauncher(args).launch();
+ }
+
+ private ArgumentParser argParser;
+
+ /**
+ * Creates a launcher.
+ *
+ * @param args the arguments passed by the command lines.
+ */
+ public UninstallGuiLauncher(String[] args) {
+ super(args);
+
+ String scriptName;
+ if (Utils.isWindows()) {
+ scriptName = Installation.WINDOWS_UNINSTALL_GUI_FILE_NAME;
+ } else {
+ scriptName = Installation.UNIX_UNINSTALL_GUI_FILE_NAME;
+ }
+ System.setProperty(ServerConstants.PROPERTY_SCRIPT_NAME, scriptName);
+ }
+
+ /**
+ * Initialize the contents of the argument parser.
+ */
+ protected void initializeParser()
+ {
+ argParser = new ArgumentParser(getClass().getName(),
+ AdminToolMessages.INFO_UNINSTALL_LAUNCHER_USAGE_DESCRIPTION.get(),
+ false);
+ try
+ {
+ BooleanArgument showUsageArg = new BooleanArgument("showUsage",
+ OPTION_SHORT_HELP,
+ OPTION_LONG_HELP, INFO_DESCRIPTION_SHOWUSAGE.get());
+ argParser.addArgument(showUsageArg);
+ argParser.setUsageArgument(showUsageArg);
+ argParser.parseArguments(args);
+ }
+ catch (ArgumentException ae)
+ {
+ System.err.println(org.opends.server.util.StaticUtils.wrapText(
+ ToolMessages.ERR_CANNOT_INITIALIZE_ARGS.get(ae.getMessage()),
+ Utils.getCommandLineMaxLineWidth()));
+ }
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ public void launch() {
+ if (shouldPrintVersion())
+ {
+ if (!argParser.usageOrVersionDisplayed())
+ {
+ printVersion();
+ }
+ System.exit(ApplicationReturnCode.ReturnCode.PRINT_VERSION
+ .getReturnCode());
+ }
+ else if (shouldPrintUsage()) {
+ if (!argParser.usageOrVersionDisplayed())
+ {
+ printUsage(false);
+ }
+ System.exit(ApplicationReturnCode.ReturnCode.SUCCESSFUL.getReturnCode());
+ } else {
+ willLaunchGui();
+ int exitCode = launchGui(args);
+ if (exitCode != 0) {
+ File logFile = QuickSetupLog.getLogFile();
+ if (logFile != null)
+ {
+ guiLaunchFailed(logFile.toString());
+ }
+ else
+ {
+ guiLaunchFailed(null);
+ }
+ System.exit(exitCode);
+ }
+ }
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ protected boolean isCli() {
+ return false;
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ public ArgumentParser getArgumentParser() {
+ return this.argParser;
+ }
+}
\ No newline at end of file
diff --git a/opends/src/guitools/org/opends/guitools/uninstaller/UninstallLauncher.java b/opends/src/guitools/org/opends/guitools/uninstaller/UninstallLauncher.java
index 2fcf8be..3398ac5 100644
--- a/opends/src/guitools/org/opends/guitools/uninstaller/UninstallLauncher.java
+++ b/opends/src/guitools/org/opends/guitools/uninstaller/UninstallLauncher.java
@@ -28,21 +28,19 @@
package org.opends.guitools.uninstaller;
import static org.opends.messages.AdminToolMessages.*;
-import static org.opends.messages.ToolMessages.*;
import org.opends.messages.Message;
-import static org.opends.server.tools.ToolConstants.*;
+import org.opends.messages.ToolMessages;
import java.io.File;
import java.util.logging.Logger;
import org.opends.quicksetup.CliApplication;
-import org.opends.quicksetup.CliApplicationHelper;
import org.opends.quicksetup.Launcher;
import org.opends.quicksetup.Installation;
import org.opends.quicksetup.QuickSetupLog;
import org.opends.quicksetup.util.Utils;
import org.opends.server.util.ServerConstants;
+import org.opends.server.util.args.ArgumentException;
import org.opends.server.util.args.ArgumentParser;
-import org.opends.server.util.args.BooleanArgument;
/**
* This class is called by the uninstall command lines to launch the uninstall
@@ -62,7 +60,7 @@
Logger.getLogger(UninstallLauncher.class.getName());
/**
- * The main method which is called by the setup command lines.
+ * The main method which is called by the uninstall command lines.
*
* @param args the arguments passed by the command lines. In the case
* we want to launch the cli setup they are basically the arguments that we
@@ -81,7 +79,7 @@
new UninstallLauncher(args).launch();
}
- private ArgumentParser argParser;
+ private UninstallerArgumentParser argParser;
/**
* Creates a launcher.
@@ -99,45 +97,39 @@
}
System.setProperty(ServerConstants.PROPERTY_SCRIPT_NAME, scriptName);
- argParser = new ArgumentParser(getClass().getName(),
+ initializeParser();
+ }
+
+ /**
+ * Initialize the contents of the argument parser.
+ */
+ protected void initializeParser()
+ {
+ argParser = new UninstallerArgumentParser(getClass().getName(),
INFO_UNINSTALL_LAUNCHER_USAGE_DESCRIPTION.get(), false);
- BooleanArgument cli;
- BooleanArgument silent;
- BooleanArgument interactive;
- BooleanArgument showUsage;
try
{
- cli = new BooleanArgument("cli", 'c', "cli",
- INFO_UNINSTALLDS_DESCRIPTION_CLI.get());
- argParser.addArgument(cli);
- interactive = new BooleanArgument(
- CliApplicationHelper.INTERACTIVE_OPTION_LONG,
- CliApplicationHelper.INTERACTIVE_OPTION_SHORT,
- CliApplicationHelper.INTERACTIVE_OPTION_LONG,
- INFO_DESCRIPTION_INTERACTIVE.get());
- argParser.addArgument(interactive);
- silent = new BooleanArgument(
- CliApplicationHelper.SILENT_OPTION_LONG,
- CliApplicationHelper.SILENT_OPTION_SHORT,
- CliApplicationHelper.SILENT_OPTION_LONG,
- INFO_UNINSTALLDS_DESCRIPTION_SILENT.get());
- argParser.addArgument(silent);
- showUsage = new BooleanArgument("showusage", OPTION_SHORT_HELP,
- OPTION_LONG_HELP,
- INFO_DESCRIPTION_USAGE.get());
- argParser.addArgument(showUsage);
- argParser.setUsageArgument(showUsage);
+ argParser.initializeGlobalOption(System.err);
}
- catch (Throwable t)
+ catch (ArgumentException ae)
{
- System.out.println("ERROR: "+t);
- t.printStackTrace();
+ Message message =
+ ToolMessages.ERR_CANNOT_INITIALIZE_ARGS.get(ae.getMessage());
+ System.err.println(org.opends.server.util.StaticUtils.wrapText(message,
+ Utils.getCommandLineMaxLineWidth()));
}
}
/**
* {@inheritDoc}
*/
+ protected boolean isCli() {
+ return true;
+ }
+
+ /**
+ * {@inheritDoc}
+ */
protected void guiLaunchFailed(String logFilePath) {
if (logFilePath != null)
{
diff --git a/opends/src/guitools/org/opends/guitools/uninstaller/UninstallUserData.java b/opends/src/guitools/org/opends/guitools/uninstaller/UninstallUserData.java
index 132e45f..f1ffbe8 100644
--- a/opends/src/guitools/org/opends/guitools/uninstaller/UninstallUserData.java
+++ b/opends/src/guitools/org/opends/guitools/uninstaller/UninstallUserData.java
@@ -27,6 +27,8 @@
package org.opends.guitools.uninstaller;
+import org.opends.admin.ads.ServerDescriptor;
+import org.opends.admin.ads.util.ApplicationTrustManager;
import org.opends.quicksetup.UserData;
import java.util.Set;
@@ -46,6 +48,14 @@
private boolean removeLDIFs;
private boolean removeConfigurationAndSchema;
private boolean updateRemoteReplication;
+ private ApplicationTrustManager trustManager =
+ new ApplicationTrustManager(null);
+ private String adminUID;
+ private String adminPwd;
+ private String referencedHostName;
+ private String localServerUrl;
+ private HashSet<ServerDescriptor> remoteServers =
+ new HashSet<ServerDescriptor>();
/**
* Sets the database directories located outside the installation which must
@@ -228,4 +238,108 @@
{
return updateRemoteReplication;
}
+
+ /**
+ * Returns the trust manager that can be used to establish secure connections.
+ * @return the trust manager that can be used to establish secure connections.
+ */
+ public ApplicationTrustManager getTrustManager() {
+ return trustManager;
+ }
+
+ /**
+ * Sets the trust manager that can be used to establish secure connections.
+ * @param trustManager the trust manager that can be used to establish secure
+ * connections.
+ */
+ public void setTrustManager(ApplicationTrustManager trustManager) {
+ this.trustManager = trustManager;
+ }
+
+ /**
+ * Returns the administrator password provided by the user.
+ * @return the administrator password provided by the user.
+ */
+ public String getAdminPwd() {
+ return adminPwd;
+ }
+
+ /**
+ * Sets the administrator password provided by the user.
+ * @param adminPwd the administrator password provided by the user.
+ */
+ public void setAdminPwd(String adminPwd) {
+ this.adminPwd = adminPwd;
+ }
+
+ /**
+ * Returns the administrator UID provided by the user.
+ * @return the administrator UID provided by the user.
+ */
+ public String getAdminUID() {
+ return adminUID;
+ }
+
+ /**
+ * Sets the administrator UID provided by the user.
+ * @param adminUID the administrator UID provided by the user.
+ */
+ public void setAdminUID(String adminUID) {
+ this.adminUID = adminUID;
+ }
+
+ /**
+ * Returns the referenced host name provided by the user.
+ * @return the referenced host name provided by the user.
+ */
+ public String getReferencedHostName() {
+ return referencedHostName;
+ }
+
+ /**
+ * Sets the referenced host name provided by the user.
+ * @param referencedHostName the referenced host name provided by the user.
+ */
+ public void setReferencedHostName(String referencedHostName) {
+ this.referencedHostName = referencedHostName;
+ }
+
+ /**
+ * Returns the LDAP URL that we used to connect to the local server.
+ * @return the LDAP URL that we used to connect to the local server.
+ */
+ public String getLocalServerUrl() {
+ return localServerUrl;
+ }
+
+ /**
+ * Sets the LDAP URL that we used to connect to the local server.
+ * @param localServerUrl the LDAP URL that we used to connect to the local
+ * server.
+ */
+ public void setLocalServerUrl(String localServerUrl) {
+ this.localServerUrl = localServerUrl;
+ }
+
+ /**
+ * Returns a Set containing the ServerDescriptors discovered in the
+ * TopologyCache.
+ * @return a Set containing the ServerDescriptors discovered in the
+ * TopologyCache.
+ */
+ public Set<ServerDescriptor> getRemoteServers()
+ {
+ return new HashSet<ServerDescriptor>(remoteServers);
+ }
+
+ /**
+ * Sets the ServerDescriptors discovered in the TopologyCache.
+ * @param remoteServers the Set containing the ServerDescriptors discovered in
+ * the TopologyCache.
+ */
+ public void setRemoteServers(Set<ServerDescriptor> remoteServers)
+ {
+ this.remoteServers.clear();
+ this.remoteServers.addAll(remoteServers);
+ }
}
diff --git a/opends/src/guitools/org/opends/guitools/uninstaller/Uninstaller.java b/opends/src/guitools/org/opends/guitools/uninstaller/Uninstaller.java
index bf47898..b5fbc0b 100644
--- a/opends/src/guitools/org/opends/guitools/uninstaller/Uninstaller.java
+++ b/opends/src/guitools/org/opends/guitools/uninstaller/Uninstaller.java
@@ -75,7 +75,7 @@
import java.awt.event.WindowEvent;
import javax.naming.Context;
-import javax.naming.directory.SearchControls;
+import javax.naming.NamingException;
import javax.naming.ldap.InitialLdapContext;
import javax.swing.JFrame;
import javax.swing.SwingUtilities;
@@ -109,7 +109,6 @@
private MessageBuilder startProgressDetails = new MessageBuilder();
private UninstallData conf;
private String replicationServerHostPort;
- private TopologyCache lastLoadedCache;
/**
* Default constructor.
@@ -568,8 +567,10 @@
*/
public UserData createUserData(Launcher launcher)
throws UserDataException {
- return cliHelper.createUserData(launcher.getArgumentParser(),
- launcher.getArguments(), getTrustManager());
+ return cliHelper.createUserData(
+ (UninstallerArgumentParser)launcher.getArgumentParser(),
+ launcher.getArguments());
+
}
/**
@@ -1222,6 +1223,14 @@
}
/**
+ * {@inheritDoc}
+ */
+ protected ApplicationTrustManager getTrustManager()
+ {
+ return getUninstallUserData().getTrustManager();
+ }
+
+ /**
* This methods disables this server as a Windows service.
*
* @throws ApplicationException if something goes wrong.
@@ -1330,8 +1339,20 @@
loginDialog.setVisible(true);
if (!loginDialog.isCancelled())
{
+ getUninstallUserData().setAdminUID(loginDialog.getAdministratorUid());
+ getUninstallUserData().setAdminPwd(loginDialog.getAdministratorPwd());
+ getUninstallUserData().setReferencedHostName(loginDialog.getHostName());
final InitialLdapContext ctx = loginDialog.getContext();
-
+ try
+ {
+ getUninstallUserData().setLocalServerUrl(
+ (String)ctx.getEnvironment().get(Context.PROVIDER_URL));
+ }
+ catch (NamingException ne)
+ {
+ LOG.log(Level.WARNING, "Could not find local server: "+ne, ne);
+ getUninstallUserData().setLocalServerUrl("ldap://localhost:389");
+ }
replicationServerHostPort = loginDialog.getHostName() + ":" +
conf.getReplicationServerPort();
@@ -1488,7 +1509,7 @@
if (!stopProcessing && (exceptionMsgs.size() > 0))
{
Message confirmationMsg =
- INFO_ERROR_READING_REGISTERED_SERVERS_CONFIRM.get(
+ INFO_ERROR_READING_REGISTERED_SERVERS_CONFIRM_UPDATE_REMOTE.get(
getStringFromCollection(exceptionMsgs, "n"));
stopProcessing = !qs.displayConfirmation(confirmationMsg,
INFO_CONFIRMATION_TITLE.get());
@@ -1502,8 +1523,8 @@
if (!stopProcessing)
{
// Launch everything
- lastLoadedCache = cache;
getUninstallUserData().setUpdateRemoteReplication(true);
+ getUninstallUserData().setRemoteServers(cache.getServers());
getUserData().setStopServer(true);
qs.launch();
qs.setCurrentStep(getNextWizardStep(Step.CONFIRM_UNINSTALL));
@@ -1535,7 +1556,7 @@
getTrustManager().acceptCertificate(chain, authType, host);
BackgroundTask worker = new BackgroundTask()
{
- public Object processBackgroundTask()throws TopologyCacheException
+ public Object processBackgroundTask() throws TopologyCacheException
{
cache.reloadTopology();
return cache;
@@ -1590,14 +1611,16 @@
}
/**
- * This method updates the replication in the remote servers. It does not
- * thrown any exception and works in a best effort mode.
+ * This method updates the replication in the remote servers. It does
+ * throw ApplicationException if we are working on the force on error mode.
* It also tries to delete the server registration entry from the remote ADS
* servers.
+ * @throws ApplicationException if we are not working on force on error mode
+ * and there is an error.
*/
- private void removeRemoteServerReferences()
+ private void removeRemoteServerReferences() throws ApplicationException
{
- Set<ServerDescriptor> servers = lastLoadedCache.getServers();
+ Set<ServerDescriptor> servers = getUninstallUserData().getRemoteServers();
Map<ADSContext.ServerProperty, Object> serverADSProperties = null;
for (ServerDescriptor server : servers)
{
@@ -1631,9 +1654,12 @@
* we want to remove references to the server that we are trying to uninstall.
* @param serverADSProperties the Map with the ADS properties of the server
* that we are trying to uninstall.
+ * @throws ApplicationException if we are not working on force on error mode
+ * and there is an error.
*/
private void removeReferences(ServerDescriptor server,
Map<ADSContext.ServerProperty, Object> serverADSProperties)
+ throws ApplicationException
{
/* First check if the server must be updated based in the contents of the
* ServerDescriptor object. */
@@ -1688,27 +1714,11 @@
InitialLdapContext ctx = null;
try
{
- String dn =
- ADSContext.getAdministratorDN(loginDialog.getAdministratorUid());
- String pwd = loginDialog.getAdministratorPwd();
+ String dn = ADSContext.getAdministratorDN(
+ getUninstallUserData().getAdminUID());
+ String pwd = getUninstallUserData().getAdminPwd();
ctx = getRemoteConnection(server, dn, pwd, getTrustManager());
- try
- {
- /*
- * Search for the config to check that it is the directory manager.
- */
- SearchControls searchControls = new SearchControls();
- searchControls.setCountLimit(1);
- searchControls.setSearchScope(
- SearchControls. OBJECT_SCOPE);
- searchControls.setReturningAttributes(new String[] {"*"});
- ctx.search("cn=config", "objectclass=*", searchControls);
- }
- catch (Throwable t)
- {
- System.out.println("FUCK: "+t);
- t.printStackTrace();
- }
+
// Update replication servers and domains. If the domain
// is an ADS, then remove it from there.
removeReferences(ctx, server.getHostPort(true), serverADSProperties);
@@ -1718,19 +1728,30 @@
catch (ApplicationException ae)
{
errorOnRemoteOccurred = true;
- Message html = getFormattedError(ae, true);
- notifyListeners(html);
LOG.log(Level.INFO, "Error updating replication references in: "+
server.getHostPort(true), ae);
- }
- if (ctx != null)
- {
- try
+
+ if (getUninstallUserData().isForceOnError())
{
- ctx.close();
+ throw ae;
}
- catch (Throwable t)
+ else
{
+ Message html = getFormattedError(ae, true);
+ notifyListeners(html);
+ }
+ }
+ finally
+ {
+ if (ctx != null)
+ {
+ try
+ {
+ ctx.close();
+ }
+ catch (Throwable t)
+ {
+ }
}
}
}
@@ -1897,8 +1918,7 @@
// Compare the port of the URL we used.
try
{
- String usedUrl = (String)
- loginDialog.getContext().getEnvironment().get(Context.PROVIDER_URL);
+ String usedUrl = getUninstallUserData().getLocalServerUrl();
boolean isSecure = usedUrl.toLowerCase().startsWith("ldaps");
URI uri = new URI(usedUrl);
int port = uri.getPort();
diff --git a/opends/src/guitools/org/opends/guitools/uninstaller/UninstallerArgumentParser.java b/opends/src/guitools/org/opends/guitools/uninstaller/UninstallerArgumentParser.java
new file mode 100644
index 0000000..a693064
--- /dev/null
+++ b/opends/src/guitools/org/opends/guitools/uninstaller/UninstallerArgumentParser.java
@@ -0,0 +1,402 @@
+/*
+ * 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
+ * trunk/opends/resource/legal-notices/OpenDS.LICENSE
+ * or https://OpenDS.dev.java.net/OpenDS.LICENSE.
+ * 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
+ *
+ *
+ * Portions Copyright 2007 Sun Microsystems, Inc.
+ */
+
+package org.opends.guitools.uninstaller;
+
+import static org.opends.messages.ToolMessages.*;
+import static org.opends.messages.AdminToolMessages.*;
+import static org.opends.server.admin.client.cli.DsFrameworkCliReturnCode.*;
+
+import java.io.OutputStream;
+
+import org.opends.messages.Message;
+import org.opends.messages.MessageBuilder;
+import org.opends.quicksetup.CliApplicationHelper;
+import org.opends.quicksetup.Constants;
+import org.opends.quicksetup.UserData;
+import org.opends.server.admin.client.cli.SecureConnectionCliParser;
+import org.opends.server.tools.ToolConstants;
+import org.opends.server.util.args.ArgumentException;
+import org.opends.server.util.args.BooleanArgument;
+import org.opends.server.util.args.StringArgument;
+
+/**
+ * Class used to parse and populate the arguments of the Uninstaller.
+ *
+ */
+public class UninstallerArgumentParser extends SecureConnectionCliParser
+{
+ private BooleanArgument interactive;
+ private BooleanArgument forceOnError;
+ private BooleanArgument silent;
+ private BooleanArgument removeAll;
+ private BooleanArgument removeServerLibraries;
+ private BooleanArgument removeDatabases;
+ private BooleanArgument removeLogFiles;
+ private BooleanArgument removeConfigurationFiles;
+ private BooleanArgument removeBackupFiles;
+ private BooleanArgument removeLDIFFiles;
+
+ /**
+ * The 'admin UID' global argument.
+ */
+ private StringArgument adminUidArg;
+ private StringArgument referencedHostNameArg;
+
+ /**
+ * Creates a new instance of this argument parser with no arguments.
+ *
+ * @param mainClassName
+ * The fully-qualified name of the Java class that should
+ * be invoked to launch the program with which this
+ * argument parser is associated.
+ * @param toolDescription
+ * A human-readable description for the tool, which will be
+ * included when displaying usage information.
+ * @param longArgumentsCaseSensitive
+ * Indicates whether subcommand and long argument names
+ * should be treated in a case-sensitive manner.
+ */
+ public UninstallerArgumentParser(String mainClassName,
+ Message toolDescription, boolean longArgumentsCaseSensitive)
+ {
+ super(mainClassName, toolDescription, longArgumentsCaseSensitive);
+ }
+
+ /**
+ * Initialize Global option.
+ *
+ * @param outStream
+ * The output stream used for the usage.
+ * @throws ArgumentException
+ * If there is a problem with any of the parameters used
+ * to create this argument.
+ */
+ public void initializeGlobalOption(OutputStream outStream)
+ throws ArgumentException
+ {
+ removeAll = new BooleanArgument(
+ "remove-all",
+ 'a',
+ "remove-all",
+ INFO_UNINSTALLDS_DESCRIPTION_REMOVE_ALL.get()
+ );
+ addGlobalArgument(removeAll);
+ removeServerLibraries = new BooleanArgument(
+ "server-libraries",
+ 'l',
+ "server-libraries",
+ INFO_UNINSTALLDS_DESCRIPTION_REMOVE_SERVER_LIBRARIES.get()
+ );
+ addGlobalArgument(removeServerLibraries);
+ removeDatabases = new BooleanArgument(
+ "databases",
+ 'd',
+ "databases",
+ INFO_UNINSTALLDS_DESCRIPTION_REMOVE_DATABASES.get()
+ );
+ addGlobalArgument(removeDatabases);
+ removeLogFiles = new BooleanArgument(
+ "log-files",
+ 'L',
+ "log-files",
+ INFO_UNINSTALLDS_DESCRIPTION_REMOVE_LOG_FILES.get()
+ );
+ addGlobalArgument(removeLogFiles);
+ removeConfigurationFiles = new BooleanArgument(
+ "configuration-files",
+ 'c',
+ "configuration-files",
+ INFO_UNINSTALLDS_DESCRIPTION_REMOVE_CONFIGURATION_FILES.get()
+ );
+ addGlobalArgument(removeConfigurationFiles);
+ removeBackupFiles = new BooleanArgument(
+ "backup-files",
+ 'b',
+ "backup-files",
+ INFO_UNINSTALLDS_DESCRIPTION_REMOVE_BACKUP_FILES.get()
+ );
+ addGlobalArgument(removeBackupFiles);
+ removeLDIFFiles = new BooleanArgument(
+ "ldif-files",
+ 'e',
+ "ldif-files",
+ INFO_UNINSTALLDS_DESCRIPTION_REMOVE_LDIF_FILES.get()
+ );
+ addGlobalArgument(removeLDIFFiles);
+ interactive = new BooleanArgument(
+ CliApplicationHelper.INTERACTIVE_OPTION_LONG,
+ CliApplicationHelper.INTERACTIVE_OPTION_SHORT,
+ CliApplicationHelper.INTERACTIVE_OPTION_LONG,
+ INFO_DESCRIPTION_INTERACTIVE.get());
+ addGlobalArgument(interactive);
+ forceOnError = new BooleanArgument(
+ "forceOnError",
+ 'f',
+ "forceOnError",
+ INFO_UNINSTALLDS_DESCRIPTION_FORCE.get());
+ addGlobalArgument(forceOnError);
+ silent = new BooleanArgument(
+ CliApplicationHelper.SILENT_OPTION_LONG,
+ CliApplicationHelper.SILENT_OPTION_SHORT,
+ CliApplicationHelper.SILENT_OPTION_LONG,
+ INFO_UNINSTALLDS_DESCRIPTION_SILENT.get());
+ addGlobalArgument(silent);
+ adminUidArg = new StringArgument("adminUID", 'I',
+ "adminUID", false, false, true, "adminUID",
+ Constants.GLOBAL_ADMIN_UID, null, INFO_DESCRIPTION_ADMINUID.get());
+ addGlobalArgument(adminUidArg);
+ super.initializeGlobalOption(outStream);
+ removeGlobalArgument(bindDnArg);
+ removeGlobalArgument(hostNameArg);
+ removeGlobalArgument(portArg);
+ removeGlobalArgument(verboseArg);
+ UserData uData = new UserData();
+ referencedHostNameArg = new StringArgument("referencedHostName",
+ ToolConstants.OPTION_SHORT_HOST,
+ "referencedHostName", false, false, true,
+ ToolConstants.OPTION_VALUE_HOST,
+ uData.getHostName(), null, INFO_DESCRIPTION_REFERENCED_HOST.get());
+ addGlobalArgument(referencedHostNameArg);
+ }
+
+ /**
+ * Tells whether the user specified to have an interactive uninstall or not.
+ * This method must be called after calling parseArguments.
+ * @return <CODE>true</CODE> if the user specified to have an interactive
+ * uninstall and <CODE>false</CODE> otherwise.
+ */
+ public boolean isInteractive()
+ {
+ return interactive.isPresent();
+ }
+
+ /**
+ * Tells whether the user specified to force on non critical error in the non
+ * interactive mode.
+ * @return <CODE>true</CODE> if the user specified to force the uninstall in
+ * non critical error and <CODE>false</CODE> otherwise.
+ */
+ public boolean isForceOnError()
+ {
+ return forceOnError.isPresent();
+ }
+
+ /**
+ * Tells whether the user specified to have a silent uninstall or not.
+ * This method must be called after calling parseArguments.
+ * @return <CODE>true</CODE> if the user specified to have a silent
+ * uninstall and <CODE>false</CODE> otherwise.
+ */
+ public boolean isSilent()
+ {
+ return silent.isPresent();
+ }
+
+ /**
+ * Tells whether the user specified to remove all files.
+ * This method must be called after calling parseArguments.
+ * @return <CODE>true</CODE> if the user specified to remove all files and
+ * <CODE>false</CODE> otherwise.
+ */
+ public boolean removeAll()
+ {
+ return removeAll.isPresent();
+ }
+
+ /**
+ * Tells whether the user specified to remove library files.
+ * This method must be called after calling parseArguments.
+ * @return <CODE>true</CODE> if the user specified to remove library files and
+ * <CODE>false</CODE> otherwise.
+ */
+ public boolean removeServerLibraries()
+ {
+ return removeServerLibraries.isPresent();
+ }
+
+ /**
+ * Tells whether the user specified to remove database files.
+ * This method must be called after calling parseArguments.
+ * @return <CODE>true</CODE> if the user specified to remove database files
+ * and <CODE>false</CODE> otherwise.
+ */
+ public boolean removeDatabases()
+ {
+ return removeDatabases.isPresent();
+ }
+
+ /**
+ * Tells whether the user specified to remove configuration files.
+ * This method must be called after calling parseArguments.
+ * @return <CODE>true</CODE> if the user specified to remove configuration
+ * files and <CODE>false</CODE> otherwise.
+ */
+ public boolean removeConfigurationFiles()
+ {
+ return removeConfigurationFiles.isPresent();
+ }
+
+ /**
+ * Tells whether the user specified to remove backup files.
+ * This method must be called after calling parseArguments.
+ * @return <CODE>true</CODE> if the user specified to remove backup files and
+ * <CODE>false</CODE> otherwise.
+ */
+ public boolean removeBackupFiles()
+ {
+ return removeBackupFiles.isPresent();
+ }
+
+ /**
+ * Tells whether the user specified to remove LDIF files.
+ * This method must be called after calling parseArguments.
+ * @return <CODE>true</CODE> if the user specified to remove LDIF files and
+ * <CODE>false</CODE> otherwise.
+ */
+ public boolean removeLDIFFiles()
+ {
+ return removeLDIFFiles.isPresent();
+ }
+
+ /**
+ * Tells whether the user specified to remove log files.
+ * This method must be called after calling parseArguments.
+ * @return <CODE>true</CODE> if the user specified to remove log files and
+ * <CODE>false</CODE> otherwise.
+ */
+ public boolean removeLogFiles()
+ {
+ return removeLogFiles.isPresent();
+ }
+
+ /**
+ * Returns the Administrator UID provided in the command-line.
+ * @return the Administrator UID provided in the command-line.
+ */
+ public String getAdministratorUID()
+ {
+ String uid = null;
+ if (adminUidArg.isPresent())
+ {
+ uid = adminUidArg.getValue();
+ }
+ return uid;
+ }
+
+ /**
+ * Returns the default Administrator UID value.
+ * @return the default Administrator UID value.
+ */
+ public String getDefaultAdministratorUID()
+ {
+ return adminUidArg.getDefaultValue();
+ }
+
+ /**
+ * Returns the Host name to update remote references as provided in the
+ * command-line.
+ * @return the Host name to update remote references as provided in the
+ * command-line.
+ */
+ public String getReferencedHostName()
+ {
+ String hostName = null;
+ if (referencedHostNameArg.isPresent())
+ {
+ hostName = referencedHostNameArg.getValue();
+ }
+ return hostName;
+ }
+
+ /**
+ * Returns the default value for the Host name to update remote references as
+ * provided in the command-line.
+ * @return the default value for the Host name to update remote references as
+ * provided in the command-line.
+ */
+ public String getDefaultReferencedHostName()
+ {
+ return referencedHostNameArg.getDefaultValue();
+ }
+
+ /**
+ * Indication if provided global options are validate.
+ *
+ * @param buf the MessageBuilder to write the error messages.
+ * @return return code.
+ */
+ public int validateGlobalOption(MessageBuilder buf)
+ {
+ int returnValue;
+ if (interactive.isPresent() && forceOnError.isPresent())
+ {
+ Message message = ERR_TOOL_CONFLICTING_ARGS.get(
+ interactive.getLongIdentifier(),
+ forceOnError.getLongIdentifier());
+ if (buf.length() > 0)
+ {
+ buf.append(EOL);
+ }
+ buf.append(message);
+ }
+ if (removeAll.isPresent())
+ {
+ BooleanArgument[] removeArgs = {
+ removeServerLibraries,
+ removeDatabases,
+ removeLogFiles,
+ removeConfigurationFiles,
+ removeBackupFiles,
+ removeLDIFFiles
+ };
+ for (int i=0; i<removeArgs.length; i++)
+ {
+ if (removeArgs[i].isPresent())
+ {
+ Message message = ERR_TOOL_CONFLICTING_ARGS.get(
+ removeAll.getLongIdentifier(),
+ removeArgs[i].getLongIdentifier());
+ if (buf.length() > 0)
+ {
+ buf.append(EOL);
+ }
+ buf.append(message);
+ }
+ }
+ }
+ if (buf.length() > 0)
+ {
+ returnValue = CONFLICTING_ARGS.getReturnCode();
+ }
+ else
+ {
+ returnValue = SUCCESSFUL_NOP.getReturnCode();
+ }
+ return returnValue;
+ }
+}
diff --git a/opends/src/guitools/org/opends/guitools/uninstaller/ui/LoginDialog.java b/opends/src/guitools/org/opends/guitools/uninstaller/ui/LoginDialog.java
index f1d7d6b..380c332 100644
--- a/opends/src/guitools/org/opends/guitools/uninstaller/ui/LoginDialog.java
+++ b/opends/src/guitools/org/opends/guitools/uninstaller/ui/LoginDialog.java
@@ -552,7 +552,8 @@
else
{
// This is a bug
- throwable.printStackTrace();
+ LOG.log(Level.SEVERE, "Unexpected throwable: "+throwable,
+ throwable);
displayError(
Utils.getThrowableMsg(INFO_BUG_MSG.get(), throwable),
INFO_ERROR_TITLE.get());
diff --git a/opends/src/messages/messages/admin_tool.properties b/opends/src/messages/messages/admin_tool.properties
index f91a294..8f8d5a2 100644
--- a/opends/src/messages/messages/admin_tool.properties
+++ b/opends/src/messages/messages/admin_tool.properties
@@ -21,13 +21,6 @@
INFO_CANNOT_CONNECT_WITH_ADS_CREDENTIALS_WITHOUT_CAUSE=Could not connect to \
the Directory Server with the provided credentials.%nCheck that the \
Administrative User ID and password are valid.
-INFO_CLI_STATUS_ERROR_READING_PWD_FILE=Could not read the password from file \
- %s. Check that the file path is correct, that you have access rights to it \
- and that it contains a password.
-INFO_CLI_STATUS_LDAPAUTH_PASSWORD_PROMPT=Password for user %s:
-INFO_CLI_STATUS_PWD_AND_PWD_FILE_PROVIDED=You cannot provide Bind Password \
- (-w or --bindPassword) and Bind Password File (-W or --bindPasswordFile) at \
- the same time.
INFO_CLI_UNINSTALL_CONFIRM_BACKUPS=Remove Backup Files Contained in bak \
Directory?
INFO_CLI_UNINSTALL_CONFIRM_CONFIGURATION_SCHEMA=Remove Configuration and \
@@ -50,24 +43,47 @@
INFO_CLI_UNINSTALL_CONFIRM_STOP=The OpenDS server is currently running and \
must be stopped before uninstallation can continue.%nStop the Server and \
permanently delete the files?
-INFO_CLI_UNINSTALL_ERROR_READING_STDIN=Unexpected error reading standard \
- input.
-INFO_CLI_UNINSTALL_NO_LONG=no
-INFO_CLI_UNINSTALL_NO_SHORT=n
+INFO_CLI_UNINSTALL_NOTHING_TO_BE_UNINSTALLED_NON_INTERACTIVE=You must select \
+ the elements to uninstall. Use the options described in the usage to specify \
+ what must be uninstalled.
INFO_CLI_UNINSTALL_NOTHING_TO_BE_UNINSTALLED=You must select something to be \
uninstalled.
INFO_CLI_UNINSTALL_SERVER_STOPPED=The Server is Stopped.
-INFO_CLI_UNINSTALL_STRING_PROMPT=%s%n[%s]:
-INFO_CLI_UNINSTALL_UNKNOWN_ARGUMENT=Unknown argument %s
+INFO_CLI_UNINSTALL_CONFIRM_UPDATE_REMOTE=This server is configured \
+to do replication. In order to remove references to this server in other \
+OpenDS servers you must provide administrator authentication. Do you want to \
+provide authentication to remove the remote references?
+INFO_CLI_UNINSTALL_CONFIRM_UPDATE_REMOTE_AND_START=This server is configured \
+to do replication. In order to remove references to this server in other \
+OpenDS servers the server must be started and then you must provide \
+administrator authentication. Do you want to start the server and then \
+provide authentication to remove the remote references?
+INFO_UNINSTALL_CLI_ADMINISTRATOR_UID_PROMPT=Global Administrator User ID
+INFO_UNINSTALL_CLI_ADMINISTRATOR_PWD_PROMPT=Global Administrator Password:
+INFO_UNINSTALL_CLI_REFERENCED_HOSTNAME_PROMPT=The name of this host (or IP \
+address) as it is referenced in remote servers for replication
+INFO_UNINSTALL_CONFIRM_PROVIDE_AUTHENTICATION_AGAIN=Do you want to provide \
+authentication again? (If you say no, the references to this server in other \
+OpenDS servers will not be removed).
INFO_CLI_UNINSTALL_WHAT_TO_DELETE=Do you want to remove all components of \
OpenDS or select the components to remove?%n1. Remove all components%n2. \
Select the components to be removed%n3. Neither; Quit the uninstaller
-INFO_CLI_UNINSTALL_YES_LONG=yes
-INFO_CLI_UNINSTALL_YES_SHORT=y
+INFO_CLI_YES_LONG=yes
+INFO_CLI_YES_SHORT=y
+INFO_CLI_NO_LONG=no
+INFO_CLI_NO_SHORT=n
INFO_CLOSE_BUTTON_UNINSTALL_TOOLTIP=Close Uninstall Window
INFO_CONFIRM_CLOSE_UNINSTALL_MSG=OpenDS Uninstall has not yet completed.%nAre \
you sure you want to close the Uninstall Window?
INFO_CONFIRM_CLOSE_UNINSTALL_TITLE=Confirmation Required
+INFO_CLI_ACCEPT_CERTIFICATE_LONG=accept
+INFO_CLI_ACCEPT_CERTIFICATE_SHORT=a
+INFO_CLI_REJECT_CERTIFICATE_LONG=reject
+INFO_CLI_REJECT_CERTIFICATE_SHORT=r
+INFO_CLI_VIEW_CERTIFICATE_LONG=view
+INFO_CLI_VIEW_CERTIFICATE_SHORT=v
+INFO_CLI_ACCEPT_CERTIFICATE_PROMPT=Do you want to accept, view or reject the \
+certificate?
INFO_CONFIRM_RESTART_MESSAGE=Are you sure you want to Restart the Directory \
Server?
INFO_CONFIRM_RESTART_TITLE=Confirmation Required
@@ -98,6 +114,10 @@
continue. Do you want the uninstaller to stop the server for you and continue \
with the uninstall? If you click No, you will need to stop the server \
manually to continue.
+INFO_ERROR_READING_REGISTERED_SERVERS_CONFIRM_UPDATE_REMOTE=The following \
+ errors were encountered reading the configuration of the existing \
+ servers:\n%s\nDo you want the uninstaller to try to remove the references to \
+ this server in a best-effort mode?
INFO_CONFIRM_UNINSTALL_SERVER_RUNNING_TITLE=Server is Running
INFO_CONFIRM_UNINSTALL_STEP=Uninstall Options
INFO_CONNECTIONS_LABEL=Open Connections:
@@ -273,3 +293,27 @@
INFO_UNINSTALL_LOGIN_UID_TOOLTIP=The Global Administrator User ID to be used \
to read and update configuration in other OpenDS servers.
INFO_UNKNOWN_LABEL=--
+INFO_UNINSTALLDS_DESCRIPTION_FORCE=Specifies whether the uninstall should \
+ continue if there is an error updating references to this server in remote \
+ OpenDS instances or not. This argument is not compatible with interactive \
+ argument
+INFO_DESCRIPTION_REFERENCED_HOST=The name of this host (or IP address) as \
+ it is referenced in remote servers for replication
+INFO_UNINSTALLDS_DESCRIPTION_CLI=Specifies to use the command line \
+ install. If not specified the graphical interface will be launched. The \
+ rest of the options (excluding help and version) will only be taken into \
+ account if this option is specified
+INFO_UNINSTALLDS_DESCRIPTION_SILENT=Perform a silent uninstall (no \
+progress information is written to the standard output)
+INFO_UNINSTALLDS_DESCRIPTION_REMOVE_ALL=Remove all components of \
+ OpenDS (this option is not compatible with the rest of remove options)
+INFO_UNINSTALLDS_DESCRIPTION_REMOVE_SERVER_LIBRARIES=Remove Server Libraries \
+and Administrative Tools
+INFO_UNINSTALLDS_DESCRIPTION_REMOVE_DATABASES=Remove database contents
+INFO_UNINSTALLDS_DESCRIPTION_REMOVE_LOG_FILES=Remove log files
+INFO_UNINSTALLDS_DESCRIPTION_REMOVE_CONFIGURATION_FILES=Remove configuration \
+files
+INFO_UNINSTALLDS_DESCRIPTION_REMOVE_BACKUP_FILES=Remove backup files
+INFO_UNINSTALLDS_DESCRIPTION_REMOVE_LDIF_FILES=Remove LDIF files
+INFO_DESCRIPTION_ADMINUID=Specifies the User ID of the Global Administrator to \
+use to bind to the server
\ No newline at end of file
diff --git a/opends/src/messages/messages/quicksetup.properties b/opends/src/messages/messages/quicksetup.properties
index 0724ad2..3c3293c 100644
--- a/opends/src/messages/messages/quicksetup.properties
+++ b/opends/src/messages/messages/quicksetup.properties
@@ -60,6 +60,12 @@
INFO_CERTIFICATE_DIALOG_TITLE=Certificate Not Trusted
INFO_CERTIFICATE_EXCEPTION=You must accept the certificate presented by \
%s:%s.
+INFO_ERROR_READING_CONFIG_LDAP_CERTIFICATE=Error reading data from server. \
+ There is an error with the certificate presented by the server.\nDetails: \
+ %s
+INFO_ERROR_READING_CONFIG_LDAP_CERTIFICATE_SERVER=Error reading data from \
+ server %s. There is an error with the certificate presented by the \
+ server.\nDetails: %s
INFO_CERTIFICATE_EXPIRED=%s - Expired
INFO_CERTIFICATE_EXPIRES_ON_LABEL=Expires On:
INFO_CERTIFICATE_HIDE_DETAILS_TEXT=<br><br><a href="">Hide Certificate \
@@ -67,21 +73,36 @@
INFO_CERTIFICATE_ISSUED_BY_LABEL=Issued By:
INFO_CERTIFICATE_LABEL=Certificate:
INFO_CERTIFICATE_NAME_MISMATCH_TEXT=The Certificate presented by the server \
- %0$s:%1$s could not be trusted.<br><br>There is a name mismatch between the \
- name of the server (%0$s) and the subject DN of the certificate. This could \
+ %s:%s could not be trusted.<br><br>There is a name mismatch between the \
+ name of the server (%s) and the subject DN of the certificate. This could \
be caused because you are connected to a server pretending to be \
- %0$s:%1$s.<br><br>Before accepting this certificate, you should examine the \
- server''s certificate carefully.<br><br>Are you willing to accept this \
- certificate for the purpose of identifying the server %0$s:%1$s?
+ %s:%s.<br><br>Before accepting this certificate, you should examine the \
+ server's certificate carefully.<br><br>Are you willing to accept this \
+ certificate for the purpose of identifying the server %s:%s?
+INFO_CERTIFICATE_NAME_MISMATCH_TEXT_CLI=The Certificate presented by the server \
+ %s:%s could not be trusted.\nThere is a name mismatch between the name of \
+ the server (%s) and the subject DN of the certificate. This could be caused \
+ because you are connected to a server pretending to be %s:%s.\n\
+ Before accepting this certificate, you should examine the server's \
+ certificate carefully.\nAre you willing to accept this certificate for \
+ the purpose of identifying the server %s:%s?
INFO_CERTIFICATE_NOT_TRUSTED_TEXT=The Certificate presented by the server \
- %0$s:%1$s could not be trusted.<br><br>Possible reasons for this \
+ %s:%s could not be trusted.<br><br>Possible reasons for this \
error:<br> -The Certificate Authority that issued the \
certificate is not recognized (this is the case of the self-signed \
- certificates).<br> -The server''s certificate is \
+ certificates).<br> -The server's certificate is \
incomplete due to a misconfiguration.<br> -The \
- server''s certificate has expired.<br>Before accepting this certificate, you \
- should examine the server''s certificate carefully.<br><br>Are you willing to \
- accept this certificate for the purpose of identifying the server %0$s:%1$s?
+ server's certificate has expired.<br>Before accepting this certificate, you \
+ should examine the server's certificate carefully.<br><br>Are you willing to \
+ accept this certificate for the purpose of identifying the server %s:%s?
+INFO_CERTIFICATE_NOT_TRUSTED_TEXT_CLI=The Certificate presented by the server \
+ %s:%s could not be trusted.\nPossible reasons for this error:\n\
+ -The Certificate Authority that issued the certificate is not recognized (this \
+ is the case of the self-signed certificates).\n-The server's certificate is \
+ incomplete due to a misconfiguration.\n-The server's certificate has \
+ expired.\nBefore accepting this certificate, you should examine the server's \
+ certificate carefully.\nAre you willing to accept this certificate for the \
+ purpose of identifying the server %s:%s?
INFO_CERTIFICATE_NOT_VALID_YET=%s - Not valid yet
INFO_CERTIFICATE_PUBLIC_KEY_LABEL=Public Key:
INFO_CERTIFICATE_SERIAL_NUMBER_LABEL=Serial Number:
@@ -255,9 +276,9 @@
%s\bat\windows-service.bat -d command-line to disable the service manually.
INFO_ERROR_DURING_INITIALIZATION_LOG=Error during the initialization with \
contents from server %s. Last log details: %s. Task state: %s. Check the \
- error logs of the server for more information.
+ error logs of %s for more information.
INFO_ERROR_DURING_INITIALIZATION_NO_LOG=Error during the initialization with \
- contents from server %0$s. Task state: %1$s. Check the error logs of %0$s \
+ contents from server %s. Task state: %s. Check the error logs of %s \
for more information.
INFO_ERROR_EMPTY_RESPONSE=ERROR: The response value may not be an empty \
string
@@ -307,7 +328,7 @@
INFO_ERROR_PROP_VALUE=The value of property %s could not be determined.
INFO_ERROR_READING_ERROROUTPUT=Error Reading error output.
INFO_ERROR_READING_OUTPUT=Error Reading output.
-INFO_ERROR_READING_REGISTERED_SERVERS_CONFIRM=The following errors where \
+INFO_ERROR_READING_REGISTERED_SERVERS_CONFIRM=The following errors were \
encountered reading the configuration of the existing servers:%n%s%n%nDo you \
want to continue?
INFO_ERROR_READING_SERVER_CONFIGURATION=Error reading configuration. \
@@ -934,11 +955,11 @@
INFO_UPGRADE_BUILD_ID_UNKNOWN=Unknown
INFO_UPGRADE_CANCELED=Upgrade canceled.
INFO_UPGRADE_CHOOSE_VERSION_BUILD_LIST_ERROR=<b>Error Accessing Build \
- Information.</b><br>Unable to retrieve the list of builds from %0$s due to: \
- %1$s.<br>Possible Causes:<br><ul><li>Need to specify a \
+ Information.</b><br>Unable to retrieve the list of builds from %s due to: \
+ %s.<br>Possible Causes:<br><ul><li>Need to specify a \
proxy.<br><table><tr><td><input value="Specify Proxy" \
type="submit"></input></td><td>Current Proxy: \
- %2$s<td></tr></table><br></li><li>%0$s is down or experiencing \
+ %s<td></tr></table><br></li><li>%s is down or experiencing \
difficulty.</li></ul><br>You can still continue with upgrade but will need to \
download a build separately and then point to it in the wizard.
INFO_UPGRADE_CHOOSE_VERSION_LOADING_BUILD_INFO=Loading remote build \
@@ -962,7 +983,7 @@
INFO_UPGRADE_CHOOSE_VERSION_UNABLE_TO_ACCESS_BUILD_INFO=Unable to access \
remote build information.
INFO_UPGRADE_FILE_PROMPT=Enter the name and path of the OpenDS install file \
- (.zip):
+ (.zip)
INFO_UPGRADE_LAUNCHER_DESCRIPTION=This utility may be used to upgrade the \
Directory Server to a newer version.
INFO_UPGRADE_LAUNCHER_GUI_LAUNCHED_FAILED=%n%nThe graphical upgrade launch \
diff --git a/opends/src/messages/messages/tools.properties b/opends/src/messages/messages/tools.properties
index dbe76fa..d632bdb 100644
--- a/opends/src/messages/messages/tools.properties
+++ b/opends/src/messages/messages/tools.properties
@@ -1996,11 +1996,6 @@
INFO_UPGRADE_DESCRIPTION_INTERACTIVE_1191=Prompt for any required information \
rather than fail
INFO_UPGRADE_DESCRIPTION_SILENT_1192=Perform a silent upgrade
-INFO_UNINSTALLDS_DESCRIPTION_CLI_1193=Specifies to use the command line \
- install. If not specified the graphical interface will be launched. The \
- silent install option will only be taken into account if this option is \
- specified
-INFO_UNINSTALLDS_DESCRIPTION_SILENT_1194=Perform a silent uninstall
INFO_LDIFIMPORT_DESCRIPTION_COUNT_REJECTS_1195=Count the number of entries \
rejected by the server and return that value as the exit code (values > 255 \
will be reduced to 255 due to exit code restrictions)
diff --git a/opends/src/messages/messages/utility.properties b/opends/src/messages/messages/utility.properties
index 72fddc9..4e5cad1 100644
--- a/opends/src/messages/messages/utility.properties
+++ b/opends/src/messages/messages/utility.properties
@@ -425,3 +425,6 @@
INFO_SUBCMDPARSER_SUBCMD_HELP_HEADING_166=To get the list of subcommands use:
SEVERE_ERR_EMBEDUTILS_SERVER_ALREADY_RUNNING_167=The Directory Server cannot \
be started because it is already running
+INFO_SUBCMDPARSER_OPTIONS_168={options}
+INFO_SUBCMDPARSER_SUBCMD_AND_OPTIONS_169={subcommand} {options}
+INFO_SUBCMDPARSER_WHERE_OPTIONS_INCLUDE_170=\ where {options} include:
\ No newline at end of file
diff --git a/opends/src/messages/src/org/opends/messages/MessageDescriptor.java b/opends/src/messages/src/org/opends/messages/MessageDescriptor.java
index 4dbbdcb..1dbe91c 100644
--- a/opends/src/messages/src/org/opends/messages/MessageDescriptor.java
+++ b/opends/src/messages/src/org/opends/messages/MessageDescriptor.java
@@ -546,7 +546,7 @@
}
/**
- * Subclass for creating messages with ten arguements.
+ * Subclass for creating messages with ten arguments.
*/
static public class Arg10<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10>
extends MessageDescriptor {
diff --git a/opends/src/quicksetup/org/opends/quicksetup/Application.java b/opends/src/quicksetup/org/opends/quicksetup/Application.java
index 27f9de7..e80aeb0 100644
--- a/opends/src/quicksetup/org/opends/quicksetup/Application.java
+++ b/opends/src/quicksetup/org/opends/quicksetup/Application.java
@@ -40,9 +40,10 @@
import org.opends.quicksetup.util.ServerController;
import org.opends.quicksetup.util.ProgressMessageFormatter;
import org.opends.quicksetup.ui.GuiApplication;
+import org.opends.quicksetup.util.Utils;
import static org.opends.messages.QuickSetupMessages.*;
-import static org.opends.quicksetup.util.Utils.*;
+
import java.io.PrintStream;
import java.io.ByteArrayOutputStream;
@@ -683,25 +684,7 @@
*/
protected String getStringRepresentation(TopologyCacheException e)
{
- MessageBuilder buf = new MessageBuilder();
-
- String ldapUrl = e.getLdapUrl();
- if (ldapUrl != null)
- {
- String hostName = ldapUrl.substring(ldapUrl.indexOf("://") + 3);
- buf.append(INFO_SERVER_ERROR.get(hostName));
- buf.append(" ");
- }
- if (e.getCause() instanceof NamingException)
- {
- buf.append(getThrowableMsg(INFO_BUG_MSG.get(), e.getCause()));
- }
- else
- {
- // This is unexpected.
- buf.append(getThrowableMsg(INFO_BUG_MSG.get(), e.getCause()));
- }
- return buf.toString();
+ return Utils.getStringRepresentation(e);
}
/**
diff --git a/opends/src/quicksetup/org/opends/quicksetup/CliApplicationHelper.java b/opends/src/quicksetup/org/opends/quicksetup/CliApplicationHelper.java
index 89be10e..3ecaade 100644
--- a/opends/src/quicksetup/org/opends/quicksetup/CliApplicationHelper.java
+++ b/opends/src/quicksetup/org/opends/quicksetup/CliApplicationHelper.java
@@ -27,19 +27,26 @@
package org.opends.quicksetup;
+
+import org.opends.admin.ads.util.ApplicationTrustManager;
+import org.opends.quicksetup.ui.CertificateDialog;
import org.opends.messages.Message;
import org.opends.messages.MessageBuilder;
+import static org.opends.messages.AdminToolMessages.*;
import static org.opends.messages.QuickSetupMessages.*;
import org.opends.quicksetup.util.Utils;
import org.opends.server.util.args.ArgumentParser;
import org.opends.server.util.args.ArgumentException;
import org.opends.server.util.args.BooleanArgument;
+import org.opends.server.util.PasswordReader;
import org.opends.server.util.StaticUtils;
import java.io.ByteArrayOutputStream;
import java.io.InputStream;
import java.io.PrintStream;
+import java.net.URI;
+import java.security.cert.X509Certificate;
import java.util.Set;
import java.util.ArrayList;
import java.util.logging.Logger;
@@ -90,7 +97,7 @@
Message defaultValue,
Message[] validValues) {
- System.out.println();
+ printLineBreak();
boolean isValid = false;
Message response = null;
@@ -103,7 +110,7 @@
System.out.flush();
response = Message.raw(readLine());
- if (response.equals(""))
+ if (response.toString().equals(""))
{
response = defaultValue;
}
@@ -130,12 +137,12 @@
* @return The string value read from the user.
*/
protected String promptForString(Message prompt, String defaultValue) {
- System.out.println();
+ printLineBreak();
String wrappedPrompt = StaticUtils.wrapText(prompt,
Utils.getCommandLineMaxLineWidth());
while (true) {
- System.out.println(wrappedPrompt);
+ System.out.print(wrappedPrompt);
if (defaultValue == null) {
System.out.print(": ");
@@ -162,6 +169,41 @@
}
}
+ /**
+ * Interactively prompts (on standard output) the user to provide a password
+ * value.
+ *
+ * @param msg The prompt to present to the user.
+ *
+ * @return The string value read from the user.
+ */
+ protected String promptForPassword(Message msg)
+ {
+ String pwd;
+ printLineBreak();
+ String wrappedPrompt = StaticUtils.wrapText(msg,
+ Utils.getCommandLineMaxLineWidth());
+ System.out.print(wrappedPrompt+" ");
+ System.out.flush();
+ try
+ {
+ char[] pwChars = PasswordReader.readPassword();
+ if ((pwChars == null) || pwChars.length == 0)
+ {
+ pwd = null;
+ }
+ else
+ {
+ pwd = new String(pwChars);
+ }
+ }
+ catch (Throwable t)
+ {
+ LOG.log(Level.WARNING, "Error reading password: "+t, t);
+ pwd = null;
+ }
+ return pwd;
+ }
/**
* Reads a line of text from standard input.
@@ -217,7 +259,7 @@
}
catch (Exception e)
{
- err.println(INFO_CLI_ERROR_READING_STDIN.get());
+ err.println(INFO_CLI_ERROR_READING_STDIN.get().toString());
return null;
}
}
@@ -345,4 +387,234 @@
return argParser;
}
+
+ /**
+ * Displays an error message in the error output (wrapping it if necessary).
+ * @param msg the error message to be displayed.
+ */
+ protected void printErrorMessage(Message msg)
+ {
+ System.err.println(org.opends.server.util.StaticUtils.wrapText(msg,
+ Utils.getCommandLineMaxLineWidth()));
+ }
+
+ /**
+ * Displays an error message in the error output (wrapping it if necessary).
+ * @param msg the error message to be displayed.
+ */
+ protected void printErrorMessage(String msg)
+ {
+ System.err.println(org.opends.server.util.StaticUtils.wrapText(msg,
+ Utils.getCommandLineMaxLineWidth()));
+ }
+
+ /**
+ * Prints a line break in the standard output.
+ */
+ protected void printLineBreak()
+ {
+ System.out.println();
+ }
+
+ /**
+ * Prompts the user to accept the certificate.
+ * @param t the throwable that was generated because the certificate was
+ * not trusted.
+ * @param trustManager the global trustManager that contains the certificates
+ * accepted by the user.
+ * @param usedUrl the LDAP URL used to connect to the server.
+ * @return <CODE>true</CODE> if the user accepted the certificate and
+ * <CODE>false</CODE> otherwise.
+ */
+ protected boolean promptForCertificateConfirmation(Throwable t,
+ ApplicationTrustManager trustManager, String usedUrl)
+ {
+ boolean returnValue = false;
+ ApplicationTrustManager.Cause cause = trustManager.getLastRefusedCause();
+
+ LOG.log(Level.INFO, "Certificate exception cause: "+cause);
+ UserDataCertificateException.Type excType = null;
+ if (cause == ApplicationTrustManager.Cause.NOT_TRUSTED)
+ {
+ excType = UserDataCertificateException.Type.NOT_TRUSTED;
+ }
+ else if (cause ==
+ ApplicationTrustManager.Cause.HOST_NAME_MISMATCH)
+ {
+ excType = UserDataCertificateException.Type.HOST_NAME_MISMATCH;
+ }
+ else
+ {
+ System.err.println();
+ Message msg = Utils.getThrowableMsg(INFO_ERROR_CONNECTING_TO_LOCAL.get(),
+ t);
+ printErrorMessage(msg);
+ }
+
+ if (excType != null)
+ {
+ String h;
+ int p;
+ try
+ {
+ URI uri = new URI(usedUrl);
+ h = uri.getHost();
+ p = uri.getPort();
+ }
+ catch (Throwable t1)
+ {
+ LOG.log(Level.WARNING, "Error parsing ldap url of ldap url.", t1);
+ h = INFO_NOT_AVAILABLE_LABEL.get().toString();
+ p = -1;
+ }
+ UserDataCertificateException udce =
+ new UserDataCertificateException(Step.REPLICATION_OPTIONS,
+ INFO_CERTIFICATE_EXCEPTION.get(h, String.valueOf(p)), t, h, p,
+ trustManager.getLastRefusedChain(),
+ trustManager.getLastRefusedAuthType(), excType);
+
+ returnValue = handleCertificateException(udce, trustManager, true);
+ }
+ return returnValue;
+ }
+
+ /**
+ * Prompts the user to accept the certificate that generated the provided
+ * UserDataCertificateException.
+ * @param trustManager the global trustManager that contains the certificates
+ * accepted by the user.
+ * @param udce the UserDataCertificateException that was generated.
+ * @param trustManager the global trustManager that contains the certificates
+ * accepted by the user.
+ * @param displayErrorMessage whether to display the message describing
+ * the error encountered (certificate not trusted) or only prompt to accept
+ * the certificate.
+ * @return <CODE>true</CODE> if the user accepted the certificate and
+ * <CODE>false</CODE> otherwise.
+ */
+ private boolean handleCertificateException(
+ UserDataCertificateException udce, ApplicationTrustManager trustManager,
+ boolean displayErrorMessage)
+ {
+ boolean accepted = false;
+ Message msg;
+ if (udce.getType() == UserDataCertificateException.Type.NOT_TRUSTED)
+ {
+ msg = INFO_CERTIFICATE_NOT_TRUSTED_TEXT_CLI.get(
+ udce.getHost(), String.valueOf(udce.getPort()),
+ udce.getHost(), String.valueOf(udce.getPort()));
+ }
+ else
+ {
+ msg = INFO_CERTIFICATE_NAME_MISMATCH_TEXT_CLI.get(
+ udce.getHost(), String.valueOf(udce.getPort()),
+ udce.getHost(),
+ udce.getHost(), String.valueOf(udce.getPort()),
+ udce.getHost(), String.valueOf(udce.getPort()));
+ }
+ if (displayErrorMessage)
+ {
+ printLineBreak();
+ printErrorMessage(msg);
+ }
+ Message[] validValues = {
+ INFO_CLI_ACCEPT_CERTIFICATE_LONG.get(),
+ INFO_CLI_REJECT_CERTIFICATE_LONG.get(),
+ INFO_CLI_VIEW_CERTIFICATE_LONG.get(),
+ INFO_CLI_ACCEPT_CERTIFICATE_SHORT.get(),
+ INFO_CLI_REJECT_CERTIFICATE_SHORT.get(),
+ INFO_CLI_VIEW_CERTIFICATE_SHORT.get()
+ };
+ Message answer = promptConfirm(INFO_CLI_ACCEPT_CERTIFICATE_PROMPT.get(),
+ validValues[0], validValues);
+
+ if (INFO_CLI_REJECT_CERTIFICATE_LONG.get().toString().equalsIgnoreCase(
+ answer.toString()) ||
+ INFO_CLI_REJECT_CERTIFICATE_SHORT.get().toString().equalsIgnoreCase(
+ answer.toString()))
+ {
+ accepted = false;
+ }
+ else if (INFO_CLI_VIEW_CERTIFICATE_LONG.get().toString().equalsIgnoreCase(
+ answer.toString()) ||
+ INFO_CLI_VIEW_CERTIFICATE_SHORT.get().toString().equalsIgnoreCase(
+ answer.toString()))
+ {
+ printLineBreak();
+ displayCertificate(udce);
+ accepted = handleCertificateException(udce, trustManager, false);
+ }
+ else
+ {
+ X509Certificate[] chain = udce.getChain();
+ String authType = udce.getAuthType();
+ String host = udce.getHost();
+
+ if ((chain != null) && (authType != null) && (host != null))
+ {
+ LOG.log(Level.INFO, "Accepting certificate presented by host "+host);
+ trustManager.acceptCertificate(chain, authType, host);
+ accepted = true;
+ }
+ else
+ {
+ if (chain == null)
+ {
+ LOG.log(Level.WARNING,
+ "The chain is null for the UserDataCertificateException");
+ }
+ if (authType == null)
+ {
+ LOG.log(Level.WARNING,
+ "The auth type is null for the UserDataCertificateException");
+ }
+ if (host == null)
+ {
+ LOG.log(Level.WARNING,
+ "The host is null for the UserDataCertificateException");
+ }
+ }
+ }
+ return accepted;
+ }
+
+ private void displayCertificate(UserDataCertificateException udce)
+ {
+ Message[] labels =
+ {
+ INFO_CERTIFICATE_SUBJECT_LABEL.get(),
+ INFO_CERTIFICATE_ISSUED_BY_LABEL.get(),
+ INFO_CERTIFICATE_VALID_FROM_LABEL.get(),
+ INFO_CERTIFICATE_EXPIRES_ON_LABEL.get(),
+ INFO_CERTIFICATE_TYPE_LABEL.get(),
+ INFO_CERTIFICATE_SERIAL_NUMBER_LABEL.get(),
+ INFO_CERTIFICATE_SIGNATURE_LABEL.get(),
+ INFO_CERTIFICATE_SIGNATURE_ALGORITHM_LABEL.get(),
+ INFO_CERTIFICATE_VERSION_LABEL.get(),
+ INFO_CERTIFICATE_PUBLIC_KEY_LABEL.get()
+ };
+ for (int i=0; i<udce.getChain().length; i++)
+ {
+ X509Certificate cert = udce.getChain()[i];
+ String[] values =
+ {
+ cert.getSubjectX500Principal().getName().toString(),
+ cert.getIssuerX500Principal().getName().toString(),
+ CertificateDialog.getValidFrom(cert),
+ CertificateDialog.getExpiresOn(cert),
+ cert.getType(),
+ String.valueOf(cert.getSerialNumber()),
+ CertificateDialog.getSignature(cert).toString(),
+ String.valueOf(cert.getSigAlgName()),
+ String.valueOf(cert.getVersion()),
+ cert.getPublicKey().toString()
+ };
+ for (int j=0; j<labels.length; j++)
+ {
+ System.out.println(StaticUtils.wrapText(labels[j]+" "+values[j],
+ Utils.getCommandLineMaxLineWidth()));
+ }
+ }
+ System.out.flush();
+ }
}
diff --git a/opends/src/quicksetup/org/opends/quicksetup/Constants.java b/opends/src/quicksetup/org/opends/quicksetup/Constants.java
index a227f07..4f8f260 100644
--- a/opends/src/quicksetup/org/opends/quicksetup/Constants.java
+++ b/opends/src/quicksetup/org/opends/quicksetup/Constants.java
@@ -27,6 +27,8 @@
package org.opends.quicksetup;
+import org.opends.admin.ads.ADSContext;
+
/**
* Defines common constants.
*/
@@ -73,7 +75,7 @@
public static final String DIRECTORY_MANAGER_DN = "cn=Directory Manager";
/** Default global admin UID. */
- public static final String GLOBAL_ADMIN_UID = "admin";
+ public static final String GLOBAL_ADMIN_UID = ADSContext.GLOBAL_ADMIN_UID;
/** These HTML tags cause a line break in formatted text. */
public static final String[] BREAKING_TAGS = {
HTML_LINE_BREAK,
diff --git a/opends/src/quicksetup/org/opends/quicksetup/Installation.java b/opends/src/quicksetup/org/opends/quicksetup/Installation.java
index 5147d22..8716da8 100644
--- a/opends/src/quicksetup/org/opends/quicksetup/Installation.java
+++ b/opends/src/quicksetup/org/opends/quicksetup/Installation.java
@@ -149,6 +149,17 @@
public static final String WINDOWS_UNINSTALL_FILE_NAME = "uninstall.bat";
/**
+ * The UNIX uninstall script file name.
+ */
+ public static final String UNIX_UNINSTALL_GUI_FILE_NAME = "uninstall-gui";
+
+ /**
+ * The Windows uninstall batch file name.
+ */
+ public static final String WINDOWS_UNINSTALL_GUI_FILE_NAME =
+ "uninstall-gui.bat";
+
+ /**
* The UNIX upgrade script file name.
*/
public static final String UNIX_UPGRADE_FILE_NAME = "upgrade";
diff --git a/opends/src/quicksetup/org/opends/quicksetup/Launcher.java b/opends/src/quicksetup/org/opends/quicksetup/Launcher.java
index 4633c0d..98eac43 100644
--- a/opends/src/quicksetup/org/opends/quicksetup/Launcher.java
+++ b/opends/src/quicksetup/org/opends/quicksetup/Launcher.java
@@ -262,7 +262,7 @@
/**
* Prints the version statement to standard output terminal.
*/
- private void printVersion()
+ protected void printVersion()
{
System.out.print(PRINTABLE_VERSION_STRING);
}
diff --git a/opends/src/quicksetup/org/opends/quicksetup/UserData.java b/opends/src/quicksetup/org/opends/quicksetup/UserData.java
index 25611a8..bb79638 100644
--- a/opends/src/quicksetup/org/opends/quicksetup/UserData.java
+++ b/opends/src/quicksetup/org/opends/quicksetup/UserData.java
@@ -85,12 +85,15 @@
private boolean interactive;
+ private boolean forceOnError;
+
/**
* Creates a user data object with default values.
*/
public UserData() {
startServer = true;
enableWindowsService = false;
+ forceOnError = true;
NewSuffixOptions defaultNewSuffixOptions = new NewSuffixOptions(
NewSuffixOptions.Type.CREATE_BASE_ENTRY, "dc=example,dc=com");
@@ -466,6 +469,26 @@
}
/**
+ * Sets whether or not we must continue when there is a non critical error.
+ * @param forceOnError where true indicates to continue uninstall if there is
+ * a non critical error.
+ */
+ public void setForceOnError(boolean forceOnError) {
+ this.forceOnError = forceOnError;
+ }
+
+ /**
+ * Indicates whether or not the user has requested to continue when a non
+ * critical error occurs.
+ *
+ * @return boolean where true indicates to continue uninstall if there is a
+ * non critical error.
+ */
+ public boolean isForceOnError() {
+ return this.forceOnError;
+ }
+
+ /**
* Sets whether or not this session should solicite feedback from the user
* for missing information.
* @param interactive boolean where true indicates this application
diff --git a/opends/src/quicksetup/org/opends/quicksetup/UserDataCertificateException.java b/opends/src/quicksetup/org/opends/quicksetup/UserDataCertificateException.java
index d6e3304..afd5050 100644
--- a/opends/src/quicksetup/org/opends/quicksetup/UserDataCertificateException.java
+++ b/opends/src/quicksetup/org/opends/quicksetup/UserDataCertificateException.java
@@ -77,8 +77,7 @@
Throwable t, String host, int port, X509Certificate[] chain,
String authType, Type type)
{
- super(step, message);
- initCause(t);
+ super(step, message, t);
this.host = host;
this.port = port;
this.chain = chain;
diff --git a/opends/src/quicksetup/org/opends/quicksetup/UserDataException.java b/opends/src/quicksetup/org/opends/quicksetup/UserDataException.java
index 0d02e3b..9faad80 100644
--- a/opends/src/quicksetup/org/opends/quicksetup/UserDataException.java
+++ b/opends/src/quicksetup/org/opends/quicksetup/UserDataException.java
@@ -54,6 +54,18 @@
}
/**
+ * Constructor for UserDataException.
+ * @param step the step in the wizard where the exception occurred.
+ * @param message the localized message describing the error.
+ * @param t the Exception that generated this exception.
+ */
+ public UserDataException(WizardStep step, Message message, Throwable t)
+ {
+ super(message, t);
+ this.step = step;
+ }
+
+ /**
* Returns the step of the wizard in which this exception occurred.
* @return the step of the wizard in which this exception occurred.
*/
diff --git a/opends/src/quicksetup/org/opends/quicksetup/installer/InstallLauncher.java b/opends/src/quicksetup/org/opends/quicksetup/installer/InstallLauncher.java
index e47ef74..f4897d3 100644
--- a/opends/src/quicksetup/org/opends/quicksetup/installer/InstallLauncher.java
+++ b/opends/src/quicksetup/org/opends/quicksetup/installer/InstallLauncher.java
@@ -291,8 +291,7 @@
newArgList.add("--configClass");
newArgList.add("org.opends.server.extensions.ConfigFileHandler");
newArgList.add("--configFile");
- Installation installation =
- new Installation(Utils.getInstallPathFromClasspath());
+ Installation installation = Installation.getLocal();
newArgList.add(Utils.getPath(installation.getCurrentConfigurationFile()));
String[] newArgs = new String[newArgList.size()];
diff --git a/opends/src/quicksetup/org/opends/quicksetup/installer/Installer.java b/opends/src/quicksetup/org/opends/quicksetup/installer/Installer.java
index c59d04a..b445d57 100644
--- a/opends/src/quicksetup/org/opends/quicksetup/installer/Installer.java
+++ b/opends/src/quicksetup/org/opends/quicksetup/installer/Installer.java
@@ -4021,12 +4021,13 @@
if (lastLogMsg == null)
{
errorMsg = INFO_ERROR_DURING_INITIALIZATION_NO_LOG.get(
- sourceServerDisplay, state);
+ sourceServerDisplay, state, sourceServerDisplay);
}
else
{
errorMsg = INFO_ERROR_DURING_INITIALIZATION_LOG.get(
- sourceServerDisplay, lastLogMsg, state);
+ sourceServerDisplay, lastLogMsg, state,
+ sourceServerDisplay);
}
if (helper.isCompletedWithErrors(state))
diff --git a/opends/src/quicksetup/org/opends/quicksetup/ui/CertificateDialog.java b/opends/src/quicksetup/org/opends/quicksetup/ui/CertificateDialog.java
index c047b01..db303b0 100644
--- a/opends/src/quicksetup/org/opends/quicksetup/ui/CertificateDialog.java
+++ b/opends/src/quicksetup/org/opends/quicksetup/ui/CertificateDialog.java
@@ -258,12 +258,16 @@
Message text;
if (ce.getType() == UserDataCertificateException.Type.NOT_TRUSTED)
{
- text = INFO_CERTIFICATE_NOT_TRUSTED_TEXT.get(ce.getHost(),
- String.valueOf(ce.getPort()));
+ text = INFO_CERTIFICATE_NOT_TRUSTED_TEXT.get(
+ ce.getHost(), String.valueOf(ce.getPort()),
+ ce.getHost(), String.valueOf(ce.getPort()));
}
else
{
text = INFO_CERTIFICATE_NAME_MISMATCH_TEXT.get(
+ ce.getHost(), String.valueOf(ce.getPort()),
+ ce.getHost(),
+ ce.getHost(), String.valueOf(ce.getPort()),
ce.getHost(), String.valueOf(ce.getPort()));
}
JPanel p = UIFactory.makeJPanel();
@@ -292,7 +296,7 @@
mb.toString(), UIFactory.INSTRUCTIONS_FONT);
MessageBuilder mb2 = new MessageBuilder();
mb2.append(text);
- mb2.append(INFO_CERTIFICATE_SHOW_DETAILS_TEXT.get());
+ mb2.append(INFO_CERTIFICATE_HIDE_DETAILS_TEXT.get());
explanationWithHideDetails = UIFactory.applyFontToHtml(
mb2.toString(), UIFactory.INSTRUCTIONS_FONT);
@@ -530,6 +534,36 @@
return c;
}
+ /**
+ * Returns the string representation for the date from which the certificate
+ * is valid.
+ * @param cert the certificate object.
+ * @return the string representation for the date from which the certificate
+ * is valid.
+ */
+ public static String getValidFrom(X509Certificate cert)
+ {
+ String s;
+ Date date = cert.getNotBefore();
+ DateFormat df = DateFormat.getDateTimeInstance(DateFormat.SHORT,
+ DateFormat.SHORT);
+ String value = df.format(date);
+ boolean isNotValidYet = false;
+ long t1 = System.currentTimeMillis();
+ long t2 = date.getTime();
+ isNotValidYet = t1 < t2;
+
+ if (isNotValidYet)
+ {
+ s = INFO_CERTIFICATE_NOT_VALID_YET.get(value).toString();
+ }
+ else
+ {
+ s = value;
+ }
+ return s;
+ }
+
private JComponent createExpiresOnComponent(X509Certificate cert)
{
JComponent c;
@@ -556,6 +590,36 @@
return c;
}
+ /**
+ * Returns the string representation for the date from which the certificate
+ * is expired.
+ * @param cert the certificate object.
+ * @return the string representation for the date from which the certificate
+ * is expired.
+ */
+ public static String getExpiresOn(X509Certificate cert)
+ {
+ String s;
+ Date date = cert.getNotAfter();
+ DateFormat df = DateFormat.getDateTimeInstance(DateFormat.SHORT,
+ DateFormat.SHORT);
+ String value = df.format(date);
+ boolean isExpired = false;
+ long t1 = System.currentTimeMillis();
+ long t2 = date.getTime();
+ isExpired = t1 > t2;
+
+ if (isExpired)
+ {
+ s = INFO_CERTIFICATE_EXPIRED.get(value).toString();
+ }
+ else
+ {
+ s = value;
+ }
+ return s;
+ }
+
private JComponent createTypeComponent(X509Certificate cert)
{
Message type = Message.raw(cert.getType());
@@ -568,7 +632,15 @@
return makeValueLabel(serialNumber);
}
- private JComponent createSignatureComponent(X509Certificate cert)
+
+ /**
+ * Returns the string representation using hexadecimal addresses of the
+ * signature of a given certificate.
+ * @param cert the certificate object.
+ * @return the string representation using hexadecimal addresses of the
+ * signature of a given certificate.
+ */
+ public static Message getSignature(X509Certificate cert)
{
byte[] sig = cert.getSignature();
MessageBuilder sb = new MessageBuilder();
@@ -580,7 +652,12 @@
}
sb.append(Integer.toHexString(((int) sig[i]) & 0xFF));
}
- return UIFactory.makeTextPane(sb.toMessage(),
+ return sb.toMessage();
+ }
+
+ private JComponent createSignatureComponent(X509Certificate cert)
+ {
+ return UIFactory.makeTextPane(getSignature(cert),
UIFactory.TextStyle.SECONDARY_FIELD_VALID);
}
diff --git a/opends/src/quicksetup/org/opends/quicksetup/ui/DirectoryManagerAuthenticationDialog.java b/opends/src/quicksetup/org/opends/quicksetup/ui/DirectoryManagerAuthenticationDialog.java
index fcd3306..afedd88 100644
--- a/opends/src/quicksetup/org/opends/quicksetup/ui/DirectoryManagerAuthenticationDialog.java
+++ b/opends/src/quicksetup/org/opends/quicksetup/ui/DirectoryManagerAuthenticationDialog.java
@@ -336,8 +336,7 @@
Boolean isServerRunning = Boolean.TRUE;
try
{
- String installPath = getInstallPathFromClasspath();
- Installation installation = new Installation(installPath);
+ Installation installation = Installation.getLocal();
int port = installation.getCurrentConfiguration().getPort();
String ldapUrl = "ldap://localhost:"+port;
InitialLdapContext ctx =
diff --git a/opends/src/quicksetup/org/opends/quicksetup/ui/QuickSetup.java b/opends/src/quicksetup/org/opends/quicksetup/ui/QuickSetup.java
index 746a685..67ea53e 100644
--- a/opends/src/quicksetup/org/opends/quicksetup/ui/QuickSetup.java
+++ b/opends/src/quicksetup/org/opends/quicksetup/ui/QuickSetup.java
@@ -381,13 +381,13 @@
public Object processBackgroundTask() throws UserDataException {
try
{
- String rootDirectory;
+ Installation installation;
if (isWebStart()) {
- rootDirectory = application.getUserData().getServerLocation();
+ installation =
+ new Installation(application.getUserData().getServerLocation());
} else {
- rootDirectory = getInstallPathFromClasspath();
+ installation = Installation.getLocal();
}
- Installation installation = new Installation(rootDirectory);
String cmd = getPath(installation.getStatusPanelCommandFile());
ProcessBuilder pb = new ProcessBuilder(cmd);
Map<String, String> env = pb.environment();
diff --git a/opends/src/quicksetup/org/opends/quicksetup/upgrader/ui/BuildListDownloadErrorPanel.java b/opends/src/quicksetup/org/opends/quicksetup/upgrader/ui/BuildListDownloadErrorPanel.java
index 3d1f387..2a6d569 100644
--- a/opends/src/quicksetup/org/opends/quicksetup/upgrader/ui/BuildListDownloadErrorPanel.java
+++ b/opends/src/quicksetup/org/opends/quicksetup/upgrader/ui/BuildListDownloadErrorPanel.java
@@ -89,7 +89,7 @@
Message html =
INFO_UPGRADE_CHOOSE_VERSION_BUILD_LIST_ERROR.get(baseContext,
reason.getLocalizedMessage(),
- proxyString);
+ proxyString, baseContext);
/* This helps with debugger the HTML rendering
StringBuffer content = new StringBuffer();
diff --git a/opends/src/quicksetup/org/opends/quicksetup/util/Utils.java b/opends/src/quicksetup/org/opends/quicksetup/util/Utils.java
index b08513a..e8c5fe4 100644
--- a/opends/src/quicksetup/org/opends/quicksetup/util/Utils.java
+++ b/opends/src/quicksetup/org/opends/quicksetup/util/Utils.java
@@ -48,6 +48,7 @@
import javax.net.ssl.HostnameVerifier;
import javax.net.ssl.TrustManager;
+import org.opends.admin.ads.TopologyCacheException;
import org.opends.admin.ads.util.ConnectionUtils;
import org.opends.quicksetup.*;
import org.opends.quicksetup.webstart.JnlpProperties;
@@ -665,6 +666,35 @@
}
/**
+ * Gets a localized representation of the provide TopologyCacheException.
+ * @param te the exception.
+ * @return a localized representation of the provide TopologyCacheException.
+ */
+ public static String getStringRepresentation(TopologyCacheException te)
+ {
+ MessageBuilder buf = new MessageBuilder();
+
+ String ldapUrl = te.getLdapUrl();
+ if (ldapUrl != null)
+ {
+ String hostName = ldapUrl.substring(ldapUrl.indexOf("://") + 3);
+ buf.append(INFO_SERVER_ERROR.get(hostName));
+ buf.append(" ");
+ }
+ if (te.getCause() instanceof NamingException)
+ {
+ buf.append(getThrowableMsg(INFO_ERROR_CONNECTING_TO_LOCAL.get(),
+ te.getCause()));
+ }
+ else
+ {
+ // This is unexpected.
+ buf.append(getThrowableMsg(INFO_BUG_MSG.get(), te.getCause()));
+ }
+ return buf.toString();
+ }
+
+ /**
* Sets the permissions of the provided paths with the provided permission
* String.
* @param paths the paths to set permissions on.
diff --git a/opends/src/server/org/opends/server/admin/client/cli/SecureConnectionCliParser.java b/opends/src/server/org/opends/server/admin/client/cli/SecureConnectionCliParser.java
index cb99e31..09f6979 100644
--- a/opends/src/server/org/opends/server/admin/client/cli/SecureConnectionCliParser.java
+++ b/opends/src/server/org/opends/server/admin/client/cli/SecureConnectionCliParser.java
@@ -175,8 +175,7 @@
Logger.getLogger(SecureConnectionCliParser.class.getName());
/**
- * Creates a new instance of this subcommand argument parser with no
- * arguments.
+ * Creates a new instance of this argument parser with no arguments.
*
* @param mainClassName
* The fully-qualified name of the Java class that should
@@ -295,6 +294,32 @@
}
/**
+ * Get the password which has to be used for the command without prompting
+ * the user. If no password was specified, return null.
+ *
+ * @return The password stored into the specified file on by the
+ * command line argument, or null it if not specified.
+ */
+ public String getBindPassword()
+ {
+ String pwd;
+ if (bindPasswordArg.isPresent())
+ {
+ pwd = bindPasswordArg.getValue();
+ }
+ else
+ if (bindPasswordFileArg.isPresent())
+ {
+ pwd = bindPasswordFileArg.getValue();
+ }
+ else
+ {
+ pwd = null;
+ }
+ return pwd;
+ }
+
+ /**
* Initialize Global option.
*
* @param outStream
@@ -435,10 +460,11 @@
/**
* Indication if provided global options are validate.
*
- * @param err the stream to be used to print error message.
+ * @param buf the MessageBuilder to write the error messages.
* @return return code.
*/
- public int validateGlobalOption(PrintStream err) {
+ public int validateGlobalOption(MessageBuilder buf)
+ {
ArrayList<Message> errors = new ArrayList<Message>();
// Couldn't have at the same time bindPassword and bindPasswordFile
if (bindPasswordArg.isPresent() && bindPasswordFileArg.isPresent()) {
@@ -491,7 +517,6 @@
if (errors.size() > 0)
{
- MessageBuilder buf = new MessageBuilder();
for (Message error : errors)
{
if (buf.length() > 0)
@@ -500,12 +525,27 @@
}
buf.append(error);
}
- err.println(wrapText(buf.toString(), MAX_LINE_WIDTH));
return CONFLICTING_ARGS.getReturnCode();
}
return SUCCESSFUL_NOP.getReturnCode();
}
+ /**
+ * Indication if provided global options are validate.
+ *
+ * @param err the stream to be used to print error message.
+ * @return return code.
+ */
+ public int validateGlobalOption(PrintStream err)
+ {
+ MessageBuilder buf = new MessageBuilder();
+ int returnValue = validateGlobalOption(buf);
+ if (buf.length() > 0)
+ {
+ err.println(wrapText(buf.toString(), MAX_LINE_WIDTH));
+ }
+ return returnValue;
+ }
/**
* Indicate if the verbose mode is required.
diff --git a/opends/src/server/org/opends/server/util/args/ArgumentParser.java b/opends/src/server/org/opends/server/util/args/ArgumentParser.java
index c3a1ec3..fd230c5 100644
--- a/opends/src/server/org/opends/server/util/args/ArgumentParser.java
+++ b/opends/src/server/org/opends/server/util/args/ArgumentParser.java
@@ -1028,8 +1028,7 @@
}
}
buffer.append(EOL);
-
- buffer.append(" where {options} include:");
+ buffer.append(INFO_SUBCMDPARSER_WHERE_OPTIONS_INCLUDE.get());
buffer.append(EOL);
// --version is a builtin option
diff --git a/opends/src/server/org/opends/server/util/args/SubCommandArgumentParser.java b/opends/src/server/org/opends/server/util/args/SubCommandArgumentParser.java
index 0aca8af..5d8a591 100644
--- a/opends/src/server/org/opends/server/util/args/SubCommandArgumentParser.java
+++ b/opends/src/server/org/opends/server/util/args/SubCommandArgumentParser.java
@@ -63,7 +63,7 @@
* it is allowed to re-use subcommand-specific options for different purposes
* between different subcommands.
*/
-public class SubCommandArgumentParser
+public class SubCommandArgumentParser extends ArgumentParser
{
// The argument that will be used to trigger the display of usage information.
private Argument usageArgument;
@@ -138,6 +138,7 @@
public SubCommandArgumentParser(String mainClassName, Message toolDescription,
boolean longArgumentsCaseSensitive)
{
+ super(mainClassName, toolDescription, longArgumentsCaseSensitive);
this.mainClassName = mainClassName;
this.toolDescription = toolDescription;
this.longArgumentsCaseSensitive = longArgumentsCaseSensitive;
@@ -1496,7 +1497,7 @@
* @return A string containing usage information based on the defined
* arguments.
*/
- public Message getUsage()
+ public String getUsage()
{
MessageBuilder buffer = new MessageBuilder();
@@ -1513,7 +1514,7 @@
getSubCommandUsage(buffer, subCommand);
}
- return buffer.toMessage();
+ return buffer.toMessage().toString();
}
@@ -1607,9 +1608,10 @@
}
-
- // Get default usage.
- private void getUsage(OutputStream outputStream)
+ /**
+ * {@inheritDoc}
+ */
+ public void getUsage(OutputStream outputStream)
throws IOException {
outputStream.write(getBytes(String.valueOf(getUsage())));
}
@@ -1636,20 +1638,29 @@
buffer.append(" ");
buffer.append(scriptName);
- buffer.append(" {subcommand} {options}");
-
- buffer.append(EOL);
- buffer.append(EOL);
-
- if (c.isEmpty())
+ if (subCommands.isEmpty())
{
- buffer.append(INFO_SUBCMDPARSER_SUBCMD_HELP_HEADING.get());
+ buffer.append(" "+INFO_SUBCMDPARSER_OPTIONS.get());
}
else
{
- buffer.append(INFO_SUBCMDPARSER_SUBCMD_HEADING.get());
+ buffer.append(" "+INFO_SUBCMDPARSER_SUBCMD_AND_OPTIONS.get());
}
- buffer.append(EOL);
+
+ if (!subCommands.isEmpty())
+ {
+ buffer.append(EOL);
+ buffer.append(EOL);
+ if (c.isEmpty())
+ {
+ buffer.append(INFO_SUBCMDPARSER_SUBCMD_HELP_HEADING.get());
+ }
+ else
+ {
+ buffer.append(INFO_SUBCMDPARSER_SUBCMD_HEADING.get());
+ }
+ buffer.append(EOL);
+ }
if (c.isEmpty()) {
// Display usage arguments (except the default one).
@@ -1691,8 +1702,16 @@
buffer.append(EOL);
if (showGlobalOptions) {
- buffer.append(INFO_SUBCMDPARSER_GLOBAL_HEADING.get());
- buffer.append(EOL);
+ if (subCommands.isEmpty())
+ {
+ buffer.append(INFO_SUBCMDPARSER_WHERE_OPTIONS_INCLUDE.get());
+ buffer.append(EOL);
+ }
+ else
+ {
+ buffer.append(INFO_SUBCMDPARSER_GLOBAL_HEADING.get());
+ buffer.append(EOL);
+ }
// --version is a builtin option
boolean dashVAccepted = true;
--
Gitblit v1.10.0