From d780c3e5eacc6278222a767913c4414e116becb4 Mon Sep 17 00:00:00 2001
From: jvergara <jvergara@localhost>
Date: Wed, 18 Nov 2009 12:46:01 +0000
Subject: [PATCH] Fix for issue 3256 (Add certificate settings options in setup CLI) When the user chooses to generate a self-signed certificate in the command-line setup, prompt to provide the host name that will be used to generate the certificate.
---
opends/src/server/org/opends/server/tools/InstallDS.java | 37 +++++++++++++++++++++++++++++++++++++
1 files changed, 37 insertions(+), 0 deletions(-)
diff --git a/opends/src/server/org/opends/server/tools/InstallDS.java b/opends/src/server/org/opends/server/tools/InstallDS.java
index 8dcc98e..1f66e80 100644
--- a/opends/src/server/org/opends/server/tools/InstallDS.java
+++ b/opends/src/server/org/opends/server/tools/InstallDS.java
@@ -949,6 +949,7 @@
}
SecurityOptions securityOptions;
LinkedList<String> keystoreAliases = new LinkedList<String>();
+ uData.setHostName(argParser.hostNameArg.getValue());
if (argParser.generateSelfSignedCertificateArg.isPresent())
{
securityOptions = SecurityOptions.createSelfSignedCertificateOptions(
@@ -1739,6 +1740,8 @@
{
securityOptions = SecurityOptions.createSelfSignedCertificateOptions(
enableSSL, enableStartTLS, ldapsPort);
+ String hostName = promptForHostNameIfRequired();
+ uData.setHostName(hostName);
}
else if (argParser.useJavaKeyStoreArg.isPresent())
{
@@ -1850,6 +1853,8 @@
}
if (certType == SELF_SIGNED)
{
+ String hostName = promptForHostNameIfRequired();
+ uData.setHostName(hostName);
securityOptions = SecurityOptions.createSelfSignedCertificateOptions(
enableSSL, enableStartTLS, ldapsPort);
}
@@ -2711,4 +2716,36 @@
LOG.log(Level.WARNING, "Error resetting arguments: "+t, t);
}
}
+
+ private String promptForHostNameIfRequired() throws UserDataException
+ {
+ String hostName = null;
+ if (argParser.hostNameArg.isPresent())
+ {
+ hostName = argParser.hostNameArg.getValue();
+ }
+ else
+ {
+ int nTries = 0;
+ while (hostName == null)
+ {
+ if (nTries >= CONFIRMATION_MAX_TRIES)
+ {
+ throw new UserDataException(null,
+ ERR_TRIES_LIMIT_REACHED.get(CONFIRMATION_MAX_TRIES));
+ }
+
+ try
+ {
+ hostName = readInput(INFO_INSTALLDS_PROMPT_HOST_NAME.get(),
+ argParser.hostNameArg.getDefaultValue());
+ }
+ catch (CLIException ce)
+ {
+ LOG.log(Level.WARNING, "Error reading input: "+ce, ce);
+ }
+ }
+ }
+ return hostName;
+ }
}
--
Gitblit v1.10.0