From 882a2fdd7a2eec0d9175069fb0dec13e13db4d05 Mon Sep 17 00:00:00 2001
From: jvergara <jvergara@localhost>
Date: Fri, 20 Nov 2009 18:49:24 +0000
Subject: [PATCH] Fix for issue 3442 (Add options -w password and -D rootDN to control-panel) Know the user can specify the password, bind DN, host name, port and to accept all the certificates automatically from the command-line when launching the control-panel.
---
opendj-sdk/opends/src/guitools/org/opends/guitools/controlpanel/ControlPanelArgumentParser.java | 287 ++++++++++++++++++++++++++++
opendj-sdk/opends/src/guitools/org/opends/guitools/controlpanel/ControlPanel.java | 91 ++++++++
opendj-sdk/opends/src/guitools/org/opends/guitools/controlpanel/ControlPanelLauncher.java | 39 ---
opendj-sdk/opends/src/guitools/org/opends/guitools/controlpanel/util/BlindApplicationTrustManager.java | 81 ++++++++
opendj-sdk/opends/src/guitools/org/opends/guitools/controlpanel/ui/LocalOrRemotePanel.java | 90 ++++++++
opendj-sdk/opends/src/ads/org/opends/admin/ads/util/ApplicationTrustManager.java | 3
opendj-sdk/opends/src/messages/messages/admin_tool.properties | 3
7 files changed, 552 insertions(+), 42 deletions(-)
diff --git a/opendj-sdk/opends/src/ads/org/opends/admin/ads/util/ApplicationTrustManager.java b/opendj-sdk/opends/src/ads/org/opends/admin/ads/util/ApplicationTrustManager.java
index bef7e83..553872a 100644
--- a/opendj-sdk/opends/src/ads/org/opends/admin/ads/util/ApplicationTrustManager.java
+++ b/opendj-sdk/opends/src/ads/org/opends/admin/ads/util/ApplicationTrustManager.java
@@ -56,7 +56,8 @@
* it cannot be retrieved this class will only accept the certificates
* explicitly accepted by the user (and specified by calling acceptCertificate).
*
- * NOTE: this class is not aimed to be used when we have connections in paralel.
+ * NOTE: this class is not aimed to be used when we have connections in
+ * parallel.
*/
public class ApplicationTrustManager implements X509TrustManager
{
diff --git a/opendj-sdk/opends/src/guitools/org/opends/guitools/controlpanel/ControlPanel.java b/opendj-sdk/opends/src/guitools/org/opends/guitools/controlpanel/ControlPanel.java
index a3a35c2..fdb88e8 100644
--- a/opendj-sdk/opends/src/guitools/org/opends/guitools/controlpanel/ControlPanel.java
+++ b/opendj-sdk/opends/src/guitools/org/opends/guitools/controlpanel/ControlPanel.java
@@ -27,6 +27,8 @@
package org.opends.guitools.controlpanel;
+import java.awt.Component;
+import java.awt.Container;
import java.awt.event.WindowAdapter;
import java.awt.event.WindowEvent;
@@ -38,13 +40,16 @@
import org.opends.guitools.controlpanel.datamodel.ControlPanelInfo;
import org.opends.guitools.controlpanel.ui.ControlCenterMainPane;
import org.opends.guitools.controlpanel.ui.GenericDialog;
+import org.opends.guitools.controlpanel.ui.LocalOrRemotePanel;
import org.opends.guitools.controlpanel.ui.MainMenuBar;
+import org.opends.guitools.controlpanel.util.BlindApplicationTrustManager;
import org.opends.guitools.controlpanel.util.Utilities;
import org.opends.messages.AdminToolMessages;
import org.opends.quicksetup.Installation;
import org.opends.messages.Message;
import org.opends.quicksetup.util.Utils;
import org.opends.server.util.DynamicConstants;
+import org.opends.server.util.args.ArgumentException;
/**
* The class that is in charge of creating the main dialog of the ControlPanel
@@ -56,6 +61,7 @@
{
private JFrame dlg;
private ControlPanelInfo info;
+ private ControlPanelArgumentParser argParser;
private ControlCenterMainPane controlCenterPane;
/**
@@ -87,7 +93,8 @@
* Method that creates the ControlCenterInfo object that will be in all the
* control panel. Nothing is done here: the user must say whether the server
* is local or remote.
- * @param args the arguments that are passed in the command line.
+ * @param args the arguments that are passed in the command line. The code
+ * assumes that the arguments have been already validated.
*/
public void initialize(String[] args)
{
@@ -95,6 +102,22 @@
// Call Installation because the LocalOrRemotePanel uses it to check
// whether the server is running or not and to get the install path.
Installation.getLocal();
+ argParser = new ControlPanelArgumentParser(ControlPanel.class.getName());
+ try
+ {
+ argParser.initializeArguments();
+ argParser.parseArguments(args);
+ }
+ catch (ArgumentException ae)
+ {
+ // Bug
+ throw new IllegalStateException("Arguments not correctly parsed: "+ae,
+ ae);
+ }
+ if (argParser.isTrustAll())
+ {
+ info.setTrustManager(new BlindApplicationTrustManager());
+ }
}
/**
@@ -102,18 +125,29 @@
*/
public void createAndDisplayGUI()
{
- GenericDialog localOrRemote =
+ final GenericDialog localOrRemote =
ControlCenterMainPane.getLocalOrRemoteDialog(info);
Utilities.centerOnScreen(localOrRemote);
+
+ if (argParser.getBindPassword() != null)
+ {
+ updateLocalOrRemotePanel(localOrRemote);
+ getLocalOrRemotePanel(localOrRemote.getContentPane()).
+ setCallOKWhenVisible(true);
+ }
+
localOrRemote.setVisible(true);
+ getLocalOrRemotePanel(localOrRemote.getContentPane()).
+ setCallOKWhenVisible(false);
+
if (info.getServerDescriptor() == null)
{
MainMenuBar menuBar = new MainMenuBar(info);
// Assume that the user decided to quit the application
menuBar.quitClicked();
}
- // To be sure that the dlg receives the new configuration event before
+ // To be sure that the dialog receives the new configuration event before
// calling pack.
SwingUtilities.invokeLater(new Runnable()
{
@@ -177,4 +211,55 @@
}
}
}
+
+ private void updateLocalOrRemotePanel(GenericDialog localOrRemote)
+ {
+ LocalOrRemotePanel panel =
+ getLocalOrRemotePanel(localOrRemote.getContentPane());
+ if (panel != null)
+ {
+ if (argParser.getExplicitHostName() != null)
+ {
+ panel.setHostName(argParser.getExplicitHostName());
+ panel.setRemote(true);
+ }
+ if (argParser.getExplicitPort() != -1)
+ {
+ panel.setPort(argParser.getExplicitPort());
+ panel.setRemote(true);
+ }
+ if (argParser.getExplicitBindDn() != null)
+ {
+ panel.setBindDN(argParser.getExplicitBindDn());
+ }
+ if (argParser.getBindPassword() != null)
+ {
+ panel.setBindPassword(argParser.getBindPassword().toCharArray());
+ }
+ }
+ }
+
+ private LocalOrRemotePanel getLocalOrRemotePanel(Container c)
+ {
+ LocalOrRemotePanel panel = null;
+ if (c instanceof LocalOrRemotePanel)
+ {
+ panel = (LocalOrRemotePanel)c;
+ }
+ else
+ {
+ for (Component comp : c.getComponents())
+ {
+ if (comp instanceof Container)
+ {
+ panel = getLocalOrRemotePanel((Container)comp);
+ }
+ if (panel != null)
+ {
+ break;
+ }
+ }
+ }
+ return panel;
+ }
}
diff --git a/opendj-sdk/opends/src/guitools/org/opends/guitools/controlpanel/ControlPanelArgumentParser.java b/opendj-sdk/opends/src/guitools/org/opends/guitools/controlpanel/ControlPanelArgumentParser.java
new file mode 100644
index 0000000..04ff2f0
--- /dev/null
+++ b/opendj-sdk/opends/src/guitools/org/opends/guitools/controlpanel/ControlPanelArgumentParser.java
@@ -0,0 +1,287 @@
+/*
+ * 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
+ *
+ *
+ * Copyright 2009 Sun Microsystems, Inc.
+ */
+
+package org.opends.guitools.controlpanel;
+
+import static org.opends.messages.AdminToolMessages.*;
+import static org.opends.messages.ToolMessages.*;
+import static org.opends.server.tools.ToolConstants.OPTION_LONG_BINDDN;
+import static org.opends.server.tools.ToolConstants.OPTION_LONG_BINDPWD;
+import static org.opends.server.tools.ToolConstants.OPTION_LONG_BINDPWD_FILE;
+import static org.opends.server.tools.ToolConstants.OPTION_LONG_HELP;
+import static org.opends.server.tools.ToolConstants.OPTION_LONG_HOST;
+import static org.opends.server.tools.ToolConstants.OPTION_LONG_PORT;
+import static org.opends.server.tools.ToolConstants.OPTION_LONG_TRUSTALL;
+import static org.opends.server.tools.ToolConstants.OPTION_SHORT_BINDDN;
+import static org.opends.server.tools.ToolConstants.OPTION_SHORT_BINDPWD;
+import static org.opends.server.tools.ToolConstants.OPTION_SHORT_BINDPWD_FILE;
+import static org.opends.server.tools.ToolConstants.OPTION_SHORT_HELP;
+import static org.opends.server.tools.ToolConstants.OPTION_SHORT_HOST;
+import static org.opends.server.tools.ToolConstants.OPTION_SHORT_PORT;
+import static org.opends.server.tools.ToolConstants.OPTION_SHORT_TRUSTALL;
+
+import java.util.LinkedHashSet;
+
+import org.opends.messages.Message;
+import org.opends.quicksetup.Constants;
+import org.opends.quicksetup.UserData;
+import org.opends.quicksetup.util.Utils;
+import org.opends.server.admin.AdministrationConnector;
+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.IntegerArgument;
+import org.opends.server.util.args.StringArgument;
+
+/**
+ * Class used to parse the arguments of the control panel command-line.
+ */
+public class ControlPanelArgumentParser extends ArgumentParser
+{
+ /**
+ * The 'hostName' global argument.
+ */
+ private StringArgument hostNameArg = null;
+
+ /**
+ * The 'port' global argument.
+ */
+ private IntegerArgument portArg = null;
+
+ /**
+ * The 'bindDN' global argument.
+ */
+ private StringArgument bindDnArg = null;
+
+ /**
+ * The 'bindPasswordFile' global argument.
+ */
+ private FileBasedArgument bindPasswordFileArg = null;
+
+ /**
+ * The 'bindPassword' global argument.
+ */
+ private StringArgument bindPasswordArg = null;
+
+ /**
+ * The 'trustAllArg' global argument.
+ */
+ private BooleanArgument trustAllArg = null;
+
+ private BooleanArgument showUsageArg;
+
+ /**
+ * The default constructor for this class.
+ * @param mainClassName the class name of the main class for the command-line
+ * that is being used.
+ */
+ public ControlPanelArgumentParser(String mainClassName)
+ {
+ super(mainClassName,
+ INFO_CONTROL_PANEL_LAUNCHER_USAGE_DESCRIPTION.get(),
+ false);
+ }
+
+ /**
+ * Returns the default value for the administration port.
+ * @return the default value for the administration port.
+ */
+ public static int getDefaultAdministrationPort()
+ {
+ return AdministrationConnector.DEFAULT_ADMINISTRATION_CONNECTOR_PORT;
+ }
+
+ /**
+ * Returns the default bind DN.
+ * @return the default bind DN.
+ */
+ public static String getDefaultBindDN()
+ {
+ return "cn=Directory Manager";
+ }
+
+ /**
+ * Initializes the arguments without parsing them.
+ * @throws ArgumentException if there was an error creating or adding the
+ * arguments. If this occurs is likely to be a bug.
+ */
+ public void initializeArguments() throws ArgumentException
+ {
+ hostNameArg = new StringArgument("host", OPTION_SHORT_HOST,
+ OPTION_LONG_HOST, false, false, true, INFO_HOST_PLACEHOLDER.get(),
+ UserData.getDefaultHostName(),
+ null, INFO_DESCRIPTION_HOST.get());
+ hostNameArg.setPropertyName(OPTION_LONG_HOST);
+ addArgument(hostNameArg);
+
+ portArg = new IntegerArgument("port", OPTION_SHORT_PORT, OPTION_LONG_PORT,
+ false, false, true, INFO_PORT_PLACEHOLDER.get(),
+ getDefaultAdministrationPort(), null,
+ INFO_DESCRIPTION_ADMIN_PORT.get());
+ portArg.setPropertyName(OPTION_LONG_PORT);
+ addArgument(portArg);
+
+ bindDnArg = new StringArgument("bindDN", OPTION_SHORT_BINDDN,
+ OPTION_LONG_BINDDN, false, false, true, INFO_BINDDN_PLACEHOLDER.get(),
+ getDefaultBindDN(), null, INFO_DESCRIPTION_BINDDN.get());
+ bindDnArg.setPropertyName(OPTION_LONG_BINDDN);
+ addArgument(bindDnArg);
+
+ bindPasswordArg = new StringArgument("bindPassword",
+ OPTION_SHORT_BINDPWD, OPTION_LONG_BINDPWD, false, false, true,
+ INFO_BINDPWD_PLACEHOLDER.get(), null, null,
+ INFO_DESCRIPTION_BINDPASSWORD.get());
+ bindPasswordArg.setPropertyName(OPTION_LONG_BINDPWD);
+ addArgument(bindPasswordArg);
+
+ bindPasswordFileArg = new FileBasedArgument("bindPasswordFile",
+ OPTION_SHORT_BINDPWD_FILE, OPTION_LONG_BINDPWD_FILE, false, false,
+ INFO_BINDPWD_FILE_PLACEHOLDER.get(), null, null,
+ INFO_DESCRIPTION_BINDPASSWORDFILE.get());
+ bindPasswordFileArg.setPropertyName(OPTION_LONG_BINDPWD_FILE);
+ addArgument(bindPasswordFileArg);
+
+ trustAllArg = new BooleanArgument("trustAll", OPTION_SHORT_TRUSTALL,
+ OPTION_LONG_TRUSTALL, INFO_DESCRIPTION_TRUSTALL.get());
+ trustAllArg.setPropertyName(OPTION_LONG_TRUSTALL);
+ addArgument(trustAllArg);
+
+ showUsageArg = new BooleanArgument("help", OPTION_SHORT_HELP,
+ OPTION_LONG_HELP,
+ INFO_DESCRIPTION_USAGE.get());
+ addArgument(showUsageArg);
+ setUsageArgument(showUsageArg);
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ @Override()
+ public void parseArguments(String[] args) throws ArgumentException
+ {
+ LinkedHashSet<Message> errorMessages = new LinkedHashSet<Message>();
+ try
+ {
+ super.parseArguments(args);
+ }
+ catch (ArgumentException ae)
+ {
+ errorMessages.add(ae.getMessageObject());
+ }
+
+ if (bindPasswordArg.isPresent() && bindPasswordFileArg.isPresent())
+ {
+ Message message = ERR_TOOL_CONFLICTING_ARGS.get(
+ bindPasswordArg.getLongIdentifier(),
+ bindPasswordFileArg.getLongIdentifier());
+ errorMessages.add(message);
+ }
+
+ if (errorMessages.size() > 0)
+ {
+ Message message = ERR_CANNOT_INITIALIZE_ARGS.get(
+ Utils.getMessageFromCollection(errorMessages,
+ Constants.LINE_SEPARATOR));
+ throw new ArgumentException(message);
+ }
+ }
+
+ /**
+ * Returns the host name explicitly provided in the command-line.
+ * @return the host name bind DN explicitly provided in the command-line.
+ * Returns <CODE>null</CODE> if no bind DN was explicitly provided.
+ */
+ public String getExplicitHostName()
+ {
+ String hostName = null;
+ if (hostNameArg.isPresent())
+ {
+ hostName = hostNameArg.getValue();
+ }
+ return hostName;
+ }
+
+ /**
+ * Returns the administration port explicitly provided in the command-line.
+ * @return the administration port explicitly provided in the command-line.
+ * Returns -1 if no port was explicitly provided.
+ */
+ public int getExplicitPort()
+ {
+ int port = -1;
+ if (portArg.isPresent())
+ {
+ try
+ {
+ port = portArg.getIntValue();
+ }
+ catch (ArgumentException ae)
+ {
+ throw new IllegalStateException("Error parsing data: "+ae, ae);
+ }
+ }
+ return port;
+ }
+
+ /**
+ * Returns the bind DN explicitly provided in the command-line.
+ * @return the bind DN explicitly provided in the command-line.
+ * Returns <CODE>null</CODE> if no bind DN was explicitly provided.
+ */
+ public String getExplicitBindDn()
+ {
+ String dn = null;
+ if (bindDnArg.isPresent())
+ {
+ dn = bindDnArg.getValue();
+ }
+ return dn;
+ }
+
+ /**
+ * Get the password which has to be used for the command without prompting
+ * the user. If no password was specified, return <CODE>null</CODE>.
+ *
+ * @return The password stored into the specified file on by the
+ * command line argument, or <CODE>null</CODE> it if not specified.
+ */
+ public String getBindPassword()
+ {
+ return getBindPassword(bindPasswordArg, bindPasswordFileArg);
+ }
+
+ /**
+ * Returns whether the user specified to trust all certificates or not.
+ * @return whether the user specified to trust all certificates or not.
+ */
+ public boolean isTrustAll()
+ {
+ return trustAllArg.isPresent();
+ }
+
+}
diff --git a/opendj-sdk/opends/src/guitools/org/opends/guitools/controlpanel/ControlPanelLauncher.java b/opendj-sdk/opends/src/guitools/org/opends/guitools/controlpanel/ControlPanelLauncher.java
index 1c741b1..75d81b3 100644
--- a/opendj-sdk/opends/src/guitools/org/opends/guitools/controlpanel/ControlPanelLauncher.java
+++ b/opendj-sdk/opends/src/guitools/org/opends/guitools/controlpanel/ControlPanelLauncher.java
@@ -29,7 +29,6 @@
import static org.opends.messages.AdminToolMessages.*;
import static org.opends.messages.ToolMessages.*;
-import static org.opends.server.tools.ToolConstants.*;
import java.io.File;
import java.io.PrintStream;
@@ -42,14 +41,10 @@
import org.opends.guitools.controlpanel.util.ControlPanelLog;
import org.opends.messages.AdminToolMessages;
import org.opends.messages.Message;
-import org.opends.quicksetup.Installation;
import org.opends.quicksetup.util.Utils;
import org.opends.server.util.DynamicConstants;
-import org.opends.server.util.ServerConstants;
import org.opends.server.util.StaticUtils;
import org.opends.server.util.args.ArgumentException;
-import org.opends.server.util.args.ArgumentParser;
-import org.opends.server.util.args.BooleanArgument;
/**
* The class that is invoked directly by the control-panel command-line. This
@@ -60,7 +55,7 @@
*/
public class ControlPanelLauncher
{
- static private ArgumentParser argParser;
+ static private ControlPanelArgumentParser argParser;
/** Prefix for log files. */
static public final String LOG_FILE_PREFIX = "opends-control-panel-";
@@ -85,36 +80,12 @@
t.printStackTrace();
}
- argParser = new ArgumentParser(ControlPanelLauncher.class.getName(),
- INFO_CONTROL_PANEL_LAUNCHER_USAGE_DESCRIPTION.get(), false);
- BooleanArgument showUsage;
- String scriptName;
- if (Utils.isWindows()) {
- scriptName = Installation.WINDOWS_CONTROLPANEL_FILE_NAME;
- } else {
- scriptName = Installation.UNIX_CONTROLPANEL_FILE_NAME;
- }
- if (System.getProperty(ServerConstants.PROPERTY_SCRIPT_NAME) == null)
- {
- System.setProperty(ServerConstants.PROPERTY_SCRIPT_NAME, scriptName);
- }
+ argParser = new ControlPanelArgumentParser(
+ ControlPanelLauncher.class.getName());
+ // Validate user provided data
try
{
- showUsage = new BooleanArgument("showusage", OPTION_SHORT_HELP,
- OPTION_LONG_HELP,
- INFO_DESCRIPTION_USAGE.get());
- argParser.addArgument(showUsage);
- argParser.setUsageArgument(showUsage);
- }
- catch (Throwable t)
- {
- System.err.println("ERROR: "+t);
- t.printStackTrace();
- }
-
-// Validate user provided data
- try
- {
+ argParser.initializeArguments();
argParser.parseArguments(args);
}
catch (ArgumentException ae)
diff --git a/opendj-sdk/opends/src/guitools/org/opends/guitools/controlpanel/ui/LocalOrRemotePanel.java b/opendj-sdk/opends/src/guitools/org/opends/guitools/controlpanel/ui/LocalOrRemotePanel.java
index 8ab5a40..45e7016 100644
--- a/opendj-sdk/opends/src/guitools/org/opends/guitools/controlpanel/ui/LocalOrRemotePanel.java
+++ b/opendj-sdk/opends/src/guitools/org/opends/guitools/controlpanel/ui/LocalOrRemotePanel.java
@@ -59,6 +59,7 @@
import org.opends.admin.ads.ServerDescriptor;
import org.opends.admin.ads.util.ApplicationTrustManager;
import org.opends.admin.ads.util.ConnectionUtils;
+import org.opends.guitools.controlpanel.ControlPanelArgumentParser;
import org.opends.guitools.controlpanel.datamodel.ConfigReadException;
import org.opends.guitools.controlpanel.datamodel.CustomSearchResult;
import org.opends.guitools.controlpanel.event.ConfigurationChangeEvent;
@@ -67,6 +68,7 @@
import org.opends.guitools.controlpanel.util.Utilities;
import org.opends.messages.Message;
import org.opends.quicksetup.Installation;
+import org.opends.quicksetup.UserData;
import org.opends.quicksetup.UserDataCertificateException;
import org.opends.quicksetup.ui.CertificateDialog;
import org.opends.quicksetup.util.UIKeyStore;
@@ -100,6 +102,8 @@
private boolean isLocalServerRunning;
+ private boolean callOKWhenVisible;
+
private static final Logger LOG =
Logger.getLogger(LocalOrRemotePanel.class.getName());
@@ -130,6 +134,76 @@
}
/**
+ * Sets the displayed host name.
+ * @param hostName the host name.
+ */
+ public void setHostName(String hostName)
+ {
+ this.hostName.setText(hostName);
+ }
+
+ /**
+ * Sets the displayed administration port.
+ * @param port the displayed administration port.
+ */
+ public void setPort(int port)
+ {
+ this.port.setText(String.valueOf(port));
+ }
+
+ /**
+ * Sets the displayed bind DN.
+ * @param bindDN the displayed bind DN.
+ */
+ public void setBindDN(String bindDN)
+ {
+ this.dn.setText(bindDN);
+ }
+
+ /**
+ * Sets the displayed password.
+ * @param pwd the password.
+ */
+ public void setBindPassword(char[] pwd)
+ {
+ this.pwd.setText(new String(pwd));
+ }
+
+ /**
+ * Sets whether the panel should display the remote or the local server.
+ * @param remote whether the panel should display the remote or the local
+ * server.
+ */
+ public void setRemote(boolean remote)
+ {
+ int index = remote ? 1 : 0;
+ combo.setSelectedIndex(index);
+ updateComponentState();
+ }
+
+ /**
+ * Method to be called when we want the panel to call automatically okClicked
+ * method when the panel is made visible.
+ * @param callOKWhenVisible whether okClicked must be called automatically
+ * when the panel is made visible or not.
+ */
+ public void setCallOKWhenVisible(boolean callOKWhenVisible)
+ {
+ this.callOKWhenVisible = callOKWhenVisible;
+ }
+
+ /**
+ * Returns whether okClicked must be called automatically when the panel is
+ * made visible or not.
+ * @return whether okClicked must be called automatically when the panel is
+ * made visible or not.
+ */
+ public boolean isCallOKWhenVisible()
+ {
+ return callOKWhenVisible;
+ }
+
+ /**
* Creates the layout of the panel (but the contents are not populated here).
*/
private void createLayout()
@@ -172,6 +246,7 @@
gbc.insets.left = 10;
add(localNotRunning, gbc);
hostName = Utilities.createMediumTextField();
+ hostName.setText(UserData.getDefaultHostName());
add(hostName, gbc);
gbc.insets.top = 10;
gbc.gridy ++;
@@ -216,7 +291,8 @@
gbc.gridx = 1;
gbc.insets.left = 10;
port = Utilities.createMediumTextField();
- port.setText("4444");
+ port.setText(String.valueOf(
+ ControlPanelArgumentParser.getDefaultAdministrationPort()));
gbc.weightx = 1.0;
gbc.fill = GridBagConstraints.HORIZONTAL;
add(port, gbc);
@@ -230,7 +306,8 @@
add(dnLabel, gbc);
gbc.insets.left = 10;
gbc.gridx = 1;
- dn = Utilities.createTextField("cn=Directory Manager", 20);
+ dn = Utilities.createTextField(
+ ControlPanelArgumentParser.getDefaultBindDN(), 20);
gbc.weightx = 1.0;
gbc.fill = GridBagConstraints.HORIZONTAL;
gbc.insets.left = 10;
@@ -314,11 +391,18 @@
{
comp.requestFocusInWindow();
}
+ if (isCallOKWhenVisible())
+ {
+ okClicked();
+ }
}
};
displayMessage(INFO_CTRL_PANEL_LOADING_PANEL_SUMMARY.get());
worker.startBackgroundTask();
- pwd.setText("");
+ if (!isCallOKWhenVisible())
+ {
+ pwd.setText("");
+ }
}
}
diff --git a/opendj-sdk/opends/src/guitools/org/opends/guitools/controlpanel/util/BlindApplicationTrustManager.java b/opendj-sdk/opends/src/guitools/org/opends/guitools/controlpanel/util/BlindApplicationTrustManager.java
new file mode 100644
index 0000000..631bb6c
--- /dev/null
+++ b/opendj-sdk/opends/src/guitools/org/opends/guitools/controlpanel/util/BlindApplicationTrustManager.java
@@ -0,0 +1,81 @@
+/*
+ * 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
+ *
+ *
+ * Copyright 2009 Sun Microsystems, Inc.
+ */
+package org.opends.guitools.controlpanel.util;
+
+import java.security.cert.X509Certificate;
+
+import java.security.cert.CertificateException;
+
+import org.opends.admin.ads.util.ApplicationTrustManager;
+
+/**
+ * An application trust manager that accepts all the certificates.
+ *
+ */
+public class BlindApplicationTrustManager extends ApplicationTrustManager
+{
+ /**
+ * Default constructor.
+ */
+ public BlindApplicationTrustManager()
+ {
+ super(null);
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ public void checkClientTrusted(X509Certificate[] chain, String authType)
+ throws CertificateException
+ {
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ public void checkServerTrusted(X509Certificate[] chain, String authType)
+ throws CertificateException
+ {
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ public X509Certificate[] getAcceptedIssuers()
+ {
+ return new X509Certificate[0];
+ }
+
+ /**
+ * Creates a copy of this ApplicationTrustManager.
+ * @return a copy of this ApplicationTrustManager.
+ */
+ public BlindApplicationTrustManager createCopy()
+ {
+ return new BlindApplicationTrustManager();
+ }
+}
diff --git a/opendj-sdk/opends/src/messages/messages/admin_tool.properties b/opendj-sdk/opends/src/messages/messages/admin_tool.properties
index 6cd70f2..cb52c5f 100644
--- a/opendj-sdk/opends/src/messages/messages/admin_tool.properties
+++ b/opendj-sdk/opends/src/messages/messages/admin_tool.properties
@@ -296,7 +296,8 @@
details.
INFO_CONTROL_PANEL_LAUNCHER_USAGE_DESCRIPTION=This utility can be used to \
display the Control Panel window which displays basic server information and \
- allows to do some basic administration tasks on the server.
+ allows to do some basic administration tasks on the server.%n%nIf no host \
+ name or port is provided, the tool will try to connect to the local server.
INFO_STOP_BUTTON_LABEL=Stop
INFO_STOP_BUTTON_TOOLTIP=Stops the Directory Server
INFO_BASEDN_NOT_REPLICATED_LABEL=Disabled
--
Gitblit v1.10.0