opendj-server-legacy/src/main/java/org/opends/guitools/controlpanel/datamodel/ControlPanelInfo.java
@@ -1087,13 +1087,10 @@ } /** * Returns <CODE>true</CODE> if the configuration must be deregistered and * <CODE>false</CODE> otherwise. * This is required when we use the ConfigFileHandler to update the * configuration, in these cases cn=config must the deregistered from the * ConfigFileHandler and after that register again. * @return <CODE>true</CODE> if the configuration must be deregistered and * <CODE>false</CODE> otherwise. * Returns {@code true} if the configuration must be deregistered and {@code false} otherwise. * This is required when we update the configuration, in these cases {@code cn=config} * must the deregistered and after that register again. * @return {@code true} if the configuration must be deregistered and {@code false} otherwise. */ public boolean mustDeregisterConfig() { opendj-server-legacy/src/main/java/org/opends/guitools/controlpanel/task/DeleteBaseDNAndBackendTask.java
@@ -436,7 +436,7 @@ { ConfigurationHandler configHandler = DirectoryServer.getConfigurationHandler(); final Entry configEntry = configHandler.getEntry(entryDn); final Entry newEntry = new LinkedHashMapEntry(configEntry); final Entry newEntry = LinkedHashMapEntry.deepCopyOfEntry(configEntry); AttributeType attrType = Schema.getDefaultSchema().getAttributeType( attrName, CoreSchema.getDirectoryStringSyntax()); newEntry.replaceAttribute(new LinkedAttribute(AttributeDescription.create(attrType), newBaseDNs)); opendj-server-legacy/src/main/java/org/opends/quicksetup/installer/Installer.java
@@ -123,6 +123,7 @@ import org.opends.server.tools.BackendTypeHelper.BackendTypeUIAdapter; import org.opends.server.types.HostPort; import org.opends.server.util.CertificateManager; import org.opends.server.util.CollectionUtils; import org.opends.server.util.DynamicConstants; import org.opends.server.util.SetupUtils; import org.opends.server.util.StaticUtils; @@ -210,9 +211,6 @@ private boolean createdRemoteAds; private String lastImportProgress; /** A static String that contains the class name of ConfigFileHandler. */ protected static final String DEFAULT_CONFIG_CLASS_NAME = "org.opends.server.extensions.ConfigFileHandler"; /** Aliases of self-signed certificates. */ protected static final String SELF_SIGNED_CERT_ALIASES[] = new String[] { SecurityOptions.SELF_SIGNED_CERT_ALIAS, @@ -823,18 +821,11 @@ writeHostName(); checkAbort(); List<String> argList = new ArrayList<>(); argList.add("-C"); argList.add(getConfigurationClassName()); argList.add("-c"); argList.add(getConfigurationFile()); argList.add("-h"); argList.add(getUserData().getHostName()); argList.add("-p"); argList.add(String.valueOf(getUserData().getServerPort())); argList.add("--adminConnectorPort"); argList.add(String.valueOf(getUserData().getAdminConnectorPort())); List<String> argList = CollectionUtils.newArrayList( "-c", getConfigurationFile(), "-h", getUserData().getHostName(), "-p", String.valueOf(getUserData().getServerPort()), "--adminConnectorPort", String.valueOf(getUserData().getAdminConnectorPort())); final SecurityOptions sec = getUserData().getSecurityOptions(); // TODO: even if the user does not configure SSL maybe we should choose @@ -2966,7 +2957,7 @@ if (errorMsgs.isEmpty()) { AuthenticationData auth = new AuthenticationData(); auth.setHostPort(new HostPort(host, port != null ? port : 0)); auth.setHostPort(new HostPort("".equals(host) ? null : host, port != null ? port : 0)); auth.setDn(dn); auth.setPwd(pwd); auth.setUseSecureConnection(true); @@ -4143,18 +4134,6 @@ return getPath(getInstallation().getCurrentConfigurationFile()); } /** * Returns the configuration class name to be used when invoking the * command-lines. * * @return the configuration class name to be used when invoking the * command-lines. */ private String getConfigurationClassName() { return DEFAULT_CONFIG_CLASS_NAME; } private String getLocalReplicationServer() { return getUserData().getHostName() + ":" + getUserData().getReplicationOptions().getReplicationPort(); opendj-server-legacy/src/main/java/org/opends/server/core/DirectoryServer.java
@@ -5925,7 +5925,9 @@ } } if (directoryServer.configurationHandler != null) { directoryServer.configurationHandler.finalize(); } EntryCache<?> ec = DirectoryServer.getEntryCache(); if (ec != null) @@ -6943,6 +6945,7 @@ { theDirectoryServer.setEnvironmentConfig(environmentConfig); theDirectoryServer.bootstrapServer(); theDirectoryServer.initializeConfiguration(); } catch (InitializationException ie) { 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; opendj-server-legacy/src/main/java/org/opends/server/types/HostPort.java
@@ -157,7 +157,7 @@ */ public static HostPort allAddresses(int port) { return new HostPort(port); return new HostPort(WILDCARD_ADDRESS, port); } /** @@ -175,22 +175,6 @@ } /** * Creates a new {@code HostPort} object with the specified port number but no * host. * * @param port * The port number for this {@code HostPort} object. */ private HostPort(int port) { this.host = null; this.normalizedHost = null; this.port = normalizePort(port); } /** * Creates a new {@code HostPort} object with the specified port * number but no explicit host. * @@ -200,9 +184,14 @@ */ public HostPort(String host, int port) { if (host != null) { this.host = removeExtraChars(host); this.normalizedHost = normalizeHost(this.host); this.port = normalizePort(port); } else { this.host = null; this.normalizedHost = null; } this.port = normalizePort(port, host); } @@ -314,9 +303,9 @@ * the port number to validate * @return the port number if valid */ private int normalizePort(int port) private int normalizePort(int port, String host) { if (1 <= port && port <= 65535) if ((1 <= port && port <= 65535) || (port == 0 && host == null)) { return port; } @@ -382,27 +371,11 @@ @Override public String toString() { return toString(host); } /** * Inner computation for #toString() and {@link #toNormalizedString()}. * * @param hostName * the hostName to use for this computation * @return the String representation fo4r this object */ private String toString(String hostName) if (host != null && host.contains(":")) { if (hostName != null) { if (hostName.contains(":")) { return "[" + hostName + "]:" + port; return "[" + host + "]:" + port; } return hostName + ":" + port; } return WILDCARD_ADDRESS + ":" + port; return host + ":" + port; } /** opendj-server-legacy/src/test/java/org/opends/server/types/HostPortTest.java
@@ -48,6 +48,14 @@ } @Test public void undefinedHostPort() { final HostPort hp = new HostPort(null, 0); assertThat(hp.getHost()).isNull(); assertThat(hp.getPort()).isEqualTo(0); } @Test public void valueOfEqualsHashCodeIPv4() { final HostPort hp1 = HostPort.valueOf("home:1"); @@ -135,7 +143,7 @@ @Test public void allAddressesNullHost() { HostPort hp = HostPort.allAddresses(1); assertThat(hp.getHost()).isNull(); assertThat(hp.getHost()).isEqualTo("0.0.0.0"); assertThat(hp.getPort()).isEqualTo(1); }