From 37eafc118d988c7635f02b3c9cb0187f3af7c60a Mon Sep 17 00:00:00 2001
From: Jean-Noël Rouvignac <jean-noel.rouvignac@forgerock.com>
Date: Tue, 05 Apr 2016 09:45:19 +0000
Subject: [PATCH] OPENDJ-2819 Setup error (NPE)
---
opendj-server-legacy/src/main/java/org/opends/server/tools/ConfigureDS.java | 55 ++++++++++++++++++++++---------------------------------
1 files changed, 22 insertions(+), 33 deletions(-)
diff --git a/opendj-server-legacy/src/main/java/org/opends/server/tools/ConfigureDS.java b/opendj-server-legacy/src/main/java/org/opends/server/tools/ConfigureDS.java
index f552e22..181976d 100644
--- a/opendj-server-legacy/src/main/java/org/opends/server/tools/ConfigureDS.java
+++ b/opendj-server-legacy/src/main/java/org/opends/server/tools/ConfigureDS.java
@@ -51,7 +51,6 @@
import org.forgerock.opendj.ldap.LinkedAttribute;
import org.forgerock.opendj.ldap.LinkedHashMapEntry;
import org.forgerock.opendj.ldap.AttributeDescription;
-import org.forgerock.opendj.ldap.ByteString;
import org.forgerock.opendj.ldap.schema.AttributeType;
import org.forgerock.opendj.ldap.schema.Syntax;
import org.forgerock.opendj.server.config.client.BackendCfgClient;
@@ -74,6 +73,7 @@
import org.opends.server.types.LDIFImportConfig;
import org.opends.server.types.NullOutputStream;
import org.opends.server.util.LDIFReader;
+import org.opends.server.util.ServerConstants;
import com.forgerock.opendj.cli.Argument;
import com.forgerock.opendj.cli.ArgumentException;
@@ -720,7 +720,7 @@
{
try
{
- getConfigEntry(dn);
+ configHandler.getEntry(dn);
}
catch (final Exception e)
{
@@ -767,7 +767,7 @@
updateConfigEntryWithAttribute(
DN_LDAP_CONNECTION_HANDLER, ATTR_LISTEN_PORT,
DirectoryServer.getDefaultIntegerSyntax(),
- ByteString.valueOfInt(ldapPort.getIntValue()));
+ ldapPort.getIntValue());
}
catch (final Exception e)
{
@@ -786,7 +786,7 @@
DN_ADMIN_CONNECTOR,
ATTR_LISTEN_PORT,
DirectoryServer.getDefaultIntegerSyntax(),
- ByteString.valueOfInt(adminConnectorPort.getIntValue()));
+ adminConnectorPort.getIntValue());
}
catch (final Exception e)
{
@@ -805,13 +805,13 @@
DN_LDAPS_CONNECTION_HANDLER,
ATTR_LISTEN_PORT,
DirectoryServer.getDefaultIntegerSyntax(),
- ByteString.valueOfInt(ldapsPort.getIntValue()));
+ ldapsPort.getIntValue());
updateConfigEntryWithAttribute(
DN_LDAPS_CONNECTION_HANDLER,
ATTR_CONNECTION_HANDLER_ENABLED,
DirectoryServer.getDefaultBooleanSyntax(),
- ByteString.valueOfUtf8("TRUE"));
+ ServerConstants.TRUE_VALUE);
}
catch (final Exception e)
{
@@ -830,13 +830,13 @@
DN_JMX_CONNECTION_HANDLER,
ATTR_LISTEN_PORT,
DirectoryServer.getDefaultIntegerSyntax(),
- ByteString.valueOfInt(jmxPort.getIntValue()));
+ jmxPort.getIntValue());
updateConfigEntryWithAttribute(
DN_JMX_CONNECTION_HANDLER,
ATTR_CONNECTION_HANDLER_ENABLED,
DirectoryServer.getDefaultBooleanSyntax(),
- ByteString.valueOfUtf8("TRUE"));
+ ServerConstants.TRUE_VALUE);
}
catch (final Exception e)
{
@@ -855,7 +855,7 @@
DN_LDAP_CONNECTION_HANDLER,
ATTR_ALLOW_STARTTLS,
DirectoryServer.getDefaultBooleanSyntax(),
- ByteString.valueOfUtf8("TRUE"));
+ ServerConstants.TRUE_VALUE);
}
catch (final Exception e)
{
@@ -877,7 +877,7 @@
keyManagerProviderDN.getValue(),
ATTR_KEYMANAGER_ENABLED,
DirectoryServer.getDefaultBooleanSyntax(),
- ByteString.valueOfUtf8("TRUE"));
+ ServerConstants.TRUE_VALUE);
}
catch (final Exception e)
{
@@ -897,7 +897,7 @@
keyManagerProviderDN.getValue(),
ATTR_KEYSTORE_FILE,
DirectoryServer.getDefaultStringSyntax(),
- ByteString.valueOfUtf8(keyManagerPath.getValue()));
+ keyManagerPath.getValue());
}
catch (final Exception e)
{
@@ -918,7 +918,7 @@
attributeDN,
ATTR_KEYMANAGER_DN,
DirectoryServer.getDefaultStringSyntax(),
- ByteString.valueOfUtf8(keyManagerProviderDN.getValue()));
+ keyManagerProviderDN.getValue());
}
catch (final Exception e)
{
@@ -939,7 +939,7 @@
trustManagerProviderDN.getValue(),
ATTR_TRUSTMANAGER_ENABLED,
DirectoryServer.getDefaultBooleanSyntax(),
- ByteString.valueOfUtf8("TRUE"));
+ ServerConstants.TRUE_VALUE);
}
catch (final Exception e)
{
@@ -979,7 +979,7 @@
attributeDN,
ATTR_TRUSTMANAGER_DN,
DirectoryServer.getDefaultStringSyntax(),
- ByteString.valueOfUtf8(trustManagerProviderDN.getValue()));
+ trustManagerProviderDN.getValue());
}
catch (final Exception e)
{
@@ -995,17 +995,11 @@
{
if (arg.isPresent())
{
- Object[] values = new ByteString[attrValues.size()];
- int index = 0;
- for (String attrValue : attrValues)
- {
- values[index++] = ByteString.valueOfUtf8(attrValue);
- }
updateConfigEntryWithAttribute(
attributeDN,
attrName,
DirectoryServer.getDefaultStringSyntax(),
- values);
+ attrValues.toArray(new Object[attrValues.size()]));
}
else
{
@@ -1040,13 +1034,13 @@
DN_ROOT_USER,
ATTR_ROOTDN_ALTERNATE_BIND_DN,
DirectoryServer.getDefaultStringSyntax(),
- ByteString.valueOfUtf8(rootDN.toString()));
+ rootDN);
final String encodedPassword = SaltedSHA512PasswordStorageScheme.encodeOffline(getBytes(rootPW));
updateConfigEntryWithAttribute(
DN_ROOT_USER,
ATTR_USER_PASSWORD,
DirectoryServer.getDefaultStringSyntax(),
- ByteString.valueOfUtf8(encodedPassword));
+ encodedPassword);
}
catch (final Exception e)
{
@@ -1064,7 +1058,7 @@
DN_DIGEST_MD5_SASL_MECHANISM,
"ds-cfg-server-fqdn",
DirectoryServer.getDefaultStringSyntax(),
- ByteString.valueOfUtf8(hostName.getValue()));
+ hostName.getValue());
}
catch (final Exception e)
{
@@ -1114,7 +1108,7 @@
DN_CRYPTO_MANAGER,
ATTR_CRYPTO_CIPHER_KEY_WRAPPING_TRANSFORMATION,
DirectoryServer.getDefaultStringSyntax(),
- ByteString.valueOfUtf8(alternativeCipher));
+ alternativeCipher);
}
catch (final Exception e)
{
@@ -1129,7 +1123,7 @@
private void updateConfigEntryWithAttribute(String entryDn, String attributeName, Syntax syntax, Object...values)
throws DirectoryException, ConfigException
{
- org.forgerock.opendj.ldap.Entry configEntry = getConfigEntry(DN.valueOf(entryDn));
+ org.forgerock.opendj.ldap.Entry configEntry = configHandler.getEntry(DN.valueOf(entryDn));
final org.forgerock.opendj.ldap.Entry newEntry = putAttribute(configEntry, attributeName, syntax, values);
configHandler.replaceEntry(configEntry, newEntry);
}
@@ -1138,16 +1132,11 @@
private void updateConfigEntryByRemovingAttribute(String entryDn, String attributeName)
throws DirectoryException, ConfigException
{
- final org.forgerock.opendj.ldap.Entry configEntry = getConfigEntry(DN.valueOf(entryDn));
+ final org.forgerock.opendj.ldap.Entry configEntry = configHandler.getEntry(DN.valueOf(entryDn));
final Entry newEntry = removeAttribute(Converters.to(configEntry), attributeName);
configHandler.replaceEntry(configEntry, Converters.from(newEntry));
}
- private org.forgerock.opendj.ldap.Entry getConfigEntry(DN dn) throws ConfigException
- {
- return configHandler.getEntry(dn);
- }
-
/**
* Duplicate the provided entry, and put an attribute to the duplicated entry.
* <p>
@@ -1158,7 +1147,7 @@
private org.forgerock.opendj.ldap.Entry putAttribute(
org.forgerock.opendj.ldap.Entry configEntry, String attrName, Syntax syntax, Object...values)
{
- org.forgerock.opendj.ldap.Entry newEntry = new LinkedHashMapEntry(configEntry);
+ org.forgerock.opendj.ldap.Entry newEntry = LinkedHashMapEntry.deepCopyOfEntry(configEntry);
AttributeType attrType = DirectoryServer.getAttributeType(attrName, syntax);
newEntry.replaceAttribute(new LinkedAttribute(AttributeDescription.create(attrType), values));
return newEntry;
--
Gitblit v1.10.0