From b82bba89685861390afefda907bab6a56770ce84 Mon Sep 17 00:00:00 2001
From: neil_a_wilson <neil_a_wilson@localhost>
Date: Fri, 18 Aug 2006 19:54:43 +0000
Subject: [PATCH] Add a very basic setup mechanism for the server. It will provide a means to interactively prompt the user for some key settings (LDAP port, base DN, root DN, and root password), will check that the specified port is usable, and can create the base entry or import an existing LDIF file.
---
opends/src/server/org/opends/server/util/PasswordReader.java | 42 +++++++++++++++++++++++++++++++++++++++++-
1 files changed, 41 insertions(+), 1 deletions(-)
diff --git a/opends/src/server/org/opends/server/util/PasswordReader.java b/opends/src/server/org/opends/server/util/PasswordReader.java
index be35e67..ae360ba 100644
--- a/opends/src/server/org/opends/server/util/PasswordReader.java
+++ b/opends/src/server/org/opends/server/util/PasswordReader.java
@@ -207,7 +207,7 @@
while (true)
{
int charRead = System.in.read();
- if ((charRead == -1) || (charRead == '\r') || (charRead == '\n'))
+ if ((charRead == -1) || (charRead == '\n'))
{
// This is the end of the value.
if (pos == 0)
@@ -222,6 +222,46 @@
return pwChars;
}
}
+ else if (charRead == '\r')
+ {
+ int char2 = System.in.read();
+ if (char2 == '\n')
+ {
+ // This is the end of the value.
+ if (pos == 0)
+ {
+ return null;
+ }
+ else
+ {
+ pwChars = new char[pos];
+ System.arraycopy(pwBuffer, 0, pwChars, 0, pos);
+ Arrays.fill(pwBuffer, '\u0000');
+ return pwChars;
+ }
+ }
+ else
+ {
+ // Append the characters to the buffer and continue.
+ pwBuffer[pos++] = (char) charRead;
+ if (pos >= pwBuffer.length)
+ {
+ char[] newBuffer = new char[pwBuffer.length+100];
+ System.arraycopy(pwBuffer, 0, newBuffer, 0, pwBuffer.length);
+ Arrays.fill(pwBuffer, '\u0000');
+ pwBuffer = newBuffer;
+ }
+
+ pwBuffer[pos++] = (char) char2;
+ if (pos >= pwBuffer.length)
+ {
+ char[] newBuffer = new char[pwBuffer.length+100];
+ System.arraycopy(pwBuffer, 0, newBuffer, 0, pwBuffer.length);
+ Arrays.fill(pwBuffer, '\u0000');
+ pwBuffer = newBuffer;
+ }
+ }
+ }
else
{
// Append the value to the buffer and continue.
--
Gitblit v1.10.0