opendj3-server-dev/src/ads/org/opends/admin/ads/TopologyCache.java
@@ -26,11 +26,6 @@ */ package org.opends.admin.ads; import static org.opends.messages.QuickSetupMessages .INFO_ERROR_READING_CONFIG_LDAP_CERTIFICATE_SERVER; import static org.opends.messages.QuickSetupMessages .INFO_NOT_GLOBAL_ADMINISTRATOR_PROVIDED; import java.util.Collection; import java.util.Date; import java.util.HashMap; @@ -58,6 +53,8 @@ import org.opends.admin.ads.util.ServerLoader; import org.opends.quicksetup.util.Utils; import static org.opends.messages.QuickSetupMessages.*; /** * This class allows to read the configuration of the different servers that are * registered in a given ADS server. It provides a read only view of the @@ -219,17 +216,7 @@ */ private void readReplicationMonitoring() { Set<ReplicaDescriptor> replicasToUpdate = new HashSet<ReplicaDescriptor>(); for (ServerDescriptor server : getServers()) { for (ReplicaDescriptor replica : server.getReplicas()) { if (replica.isReplicated()) { replicasToUpdate.add(replica); } } } Set<ReplicaDescriptor> replicasToUpdate = getReplicasToUpdate(); for (ServerDescriptor server : getServers()) { if (server.isReplicationServer()) @@ -237,26 +224,10 @@ // If is replication server, then at least we were able to read the // configuration, so assume that we might be able to read monitoring // (even if an exception occurred before). Set<ReplicaDescriptor> candidateReplicas = new HashSet<ReplicaDescriptor>(); // It contains replication information: analyze it. String repServer = server.getReplicationServerHostPort(); for (SuffixDescriptor suffix : getSuffixes()) { Set<String> repServers = suffix.getReplicationServers(); for (String r : repServers) { if (r.equalsIgnoreCase(repServer)) { candidateReplicas.addAll(suffix.getReplicas()); break; } } } Set<ReplicaDescriptor> candidateReplicas = getCandidateReplicas(server); if (!candidateReplicas.isEmpty()) { Set<ReplicaDescriptor> updatedReplicas = new HashSet<ReplicaDescriptor>(); Set<ReplicaDescriptor> updatedReplicas = new HashSet<ReplicaDescriptor>(); try { updateReplicas(server, candidateReplicas, updatedReplicas); @@ -277,6 +248,49 @@ } } private Set<ReplicaDescriptor> getReplicasToUpdate() { Set<ReplicaDescriptor> replicasToUpdate = new HashSet<ReplicaDescriptor>(); for (ServerDescriptor server : getServers()) { for (ReplicaDescriptor replica : server.getReplicas()) { if (replica.isReplicated()) { replicasToUpdate.add(replica); } } } return replicasToUpdate; } private Set<ReplicaDescriptor> getCandidateReplicas(ServerDescriptor server) { Set<ReplicaDescriptor> candidateReplicas = new HashSet<ReplicaDescriptor>(); // It contains replication information: analyze it. String repServer = server.getReplicationServerHostPort(); for (SuffixDescriptor suffix : getSuffixes()) { if (containsIgnoreCase(suffix.getReplicationServers(), repServer)) { candidateReplicas.addAll(suffix.getReplicas()); } } return candidateReplicas; } private boolean containsIgnoreCase(Set<String> col, String toFind) { for (String s : col) { if (s.equalsIgnoreCase(toFind)) { return true; } } return false; } /** * Sets the list of LDAP URLs and connection type that are preferred to be * used to connect to the servers. When we have a server to which we can @@ -310,9 +324,7 @@ */ public Set<ServerDescriptor> getServers() { HashSet<ServerDescriptor> copy = new HashSet<ServerDescriptor>(); copy.addAll(servers); return copy; return new HashSet<ServerDescriptor>(servers); } /** @@ -324,9 +336,7 @@ */ public Set<SuffixDescriptor> getSuffixes() { HashSet<SuffixDescriptor> copy = new HashSet<SuffixDescriptor>(); copy.addAll(suffixes); return copy; return new HashSet<SuffixDescriptor>(suffixes); } /** @@ -431,8 +441,7 @@ break; case GENERIC_CREATING_CONNECTION: if ((e.getCause() != null) && Utils.isCertificateException(e.getCause())) if (Utils.isCertificateException(e.getCause())) { exceptionMsgs.add( INFO_ERROR_READING_CONFIG_LDAP_CERTIFICATE_SERVER.get( @@ -532,7 +541,7 @@ { try { replica.setMissingChanges(new Integer(s)); replica.setMissingChanges(Integer.valueOf(s)); } catch (Throwable t) { opendj3-server-dev/src/ads/org/opends/admin/ads/util/ConnectionUtils.java
@@ -30,14 +30,10 @@ import java.io.IOException; import java.net.ConnectException; import java.net.URI; import java.security.GeneralSecurityException; import java.util.HashSet; import java.util.Hashtable; import java.util.Set; import org.forgerock.i18n.LocalizableMessage; import org.forgerock.i18n.slf4j.LocalizedLogger; import javax.naming.CommunicationException; import javax.naming.Context; import javax.naming.NamingEnumeration; @@ -52,9 +48,10 @@ import javax.naming.ldap.StartTlsResponse; import javax.net.ssl.HostnameVerifier; import javax.net.ssl.KeyManager; import javax.net.ssl.SSLHandshakeException; import javax.net.ssl.TrustManager; import org.forgerock.i18n.LocalizableMessage; import org.forgerock.i18n.slf4j.LocalizedLogger; import org.opends.server.replication.plugin.EntryHistorical; import org.opends.server.schema.SchemaConstants; @@ -221,6 +218,7 @@ final KeyManager fKeyManager = keyManager; Thread t = new Thread(new Runnable() { @Override public void run() { try { TrustedSocketFactory.setCurrentThreadTrustManager(fTrustManager, @@ -798,28 +796,6 @@ } /** * Tells whether the provided Throwable was caused because of a problem with * a certificate while trying to establish a connection. * @param t the Throwable to analyze. * @return <CODE>true</CODE> if the provided Throwable was caused because of a * problem with a certificate while trying to establish a connection and * <CODE>false</CODE> otherwise. */ public static boolean isCertificateException(Throwable t) { boolean returnValue = false; while (!returnValue && (t != null)) { returnValue = (t instanceof SSLHandshakeException) || (t instanceof GeneralSecurityException); t = t.getCause(); } return returnValue; } /** * Returns the String representation of the first value of an attribute in a * LDAP entry. * @param entry the entry. opendj3-server-dev/src/quicksetup/org/opends/quicksetup/util/Utils.java
@@ -26,14 +26,6 @@ */ package org.opends.quicksetup.util; import static org.forgerock.util.Utils.*; import static org.opends.messages.QuickSetupMessages.*; import static org.opends.server.util.DynamicConstants.*; import static com.forgerock.opendj.util.OperatingSystem.isWindows; import static com.forgerock.opendj.util.OperatingSystem.isUnix; import static com.forgerock.opendj.cli.Utils.OBFUSCATED_VALUE; import static com.forgerock.opendj.cli.Utils.getThrowableMsg; import java.io.*; import java.net.InetAddress; import java.text.SimpleDateFormat; @@ -47,16 +39,19 @@ import javax.net.ssl.HostnameVerifier; import javax.net.ssl.TrustManager; import org.forgerock.i18n.LocalizableMessage; import org.forgerock.i18n.LocalizableMessageBuilder; import org.forgerock.i18n.slf4j.LocalizedLogger; import org.opends.admin.ads.ADSContext; import org.opends.admin.ads.ReplicaDescriptor; import org.opends.admin.ads.ServerDescriptor; import org.opends.admin.ads.SuffixDescriptor; import org.opends.admin.ads.TopologyCacheException; import org.opends.admin.ads.util.ConnectionUtils; import org.forgerock.i18n.LocalizableMessage; import org.forgerock.i18n.LocalizableMessageBuilder; import org.forgerock.i18n.slf4j.LocalizedLogger; import org.opends.quicksetup.*; import org.opends.quicksetup.Constants; import org.opends.quicksetup.Installation; import org.opends.quicksetup.SecurityOptions; import org.opends.quicksetup.UserData; import org.opends.quicksetup.installer.AuthenticationData; import org.opends.quicksetup.installer.DataReplicationOptions; import org.opends.quicksetup.installer.NewSuffixOptions; @@ -65,17 +60,21 @@ import org.opends.server.util.SetupUtils; import org.opends.server.util.StaticUtils; import static com.forgerock.opendj.cli.Utils.*; import static com.forgerock.opendj.util.OperatingSystem.*; import static org.forgerock.util.Utils.*; import static org.opends.messages.QuickSetupMessages.*; import static org.opends.server.util.DynamicConstants.*; /** * This class provides some static convenience methods of different nature. * */ public class Utils { private static final LocalizedLogger logger = LocalizedLogger.getLoggerForThisClass(); private static final int BUFFER_SIZE = 1024; private static final int MAX_LINE_WIDTH = 80; private Utils() @@ -822,7 +821,7 @@ */ public static boolean isCertificateException(Throwable t) { return ConnectionUtils.isCertificateException(t); return com.forgerock.opendj.cli.Utils.isCertificateException(t); } /** opendj3-server-dev/src/server/org/opends/server/tools/dsreplication/DisableReplicationUserData.java
@@ -22,103 +22,23 @@ * * * Copyright 2008-2009 Sun Microsystems, Inc. * Portions Copyright 2014 ForgeRock AS */ package org.opends.server.tools.dsreplication; /** * This class is used to store the information provided by the user to * disable replication. It is required because when we are in interactive * mode the ReplicationCliArgumentParser is not enough. * */ public class DisableReplicationUserData extends ReplicationUserData public class DisableReplicationUserData extends MonoServerReplicationUserData { private String hostName; private int port; private boolean useStartTLS; private boolean useSSL; private String bindDn; private String bindPwd; private boolean disableReplicationServer; private boolean disableAll; /** * Returns the host name of the server. * @return the host name of the server. */ public String getHostName() { return hostName; } /** * Sets the host name of the server. * @param hostName the host name of the server. */ public void setHostName(String hostName) { this.hostName = hostName; } /** * Returns the port of the server. * @return the port of the server. */ public int getPort() { return port; } /** * Sets the port of the server. * @param port the port of the server. */ public void setPort(int port) { this.port = port; } /** * Returns <CODE>true</CODE> if we must use SSL to connect to the server and * <CODE>false</CODE> otherwise. * @return <CODE>true</CODE> if we must use SSL to connect to the server and * <CODE>false</CODE> otherwise. */ boolean useSSL() { return useSSL; } /** * Sets whether we must use SSL to connect to the server or not. * @param useSSL whether we must use SSL to connect to the server or not. */ void setUseSSL(boolean useSSL) { this.useSSL = useSSL; } /** * Returns <CODE>true</CODE> if we must use StartTLS to connect to the server * and <CODE>false</CODE> otherwise. * @return <CODE>true</CODE> if we must use StartTLS to connect to the server * and <CODE>false</CODE> otherwise. */ boolean useStartTLS() { return useStartTLS; } /** * Sets whether we must use StartTLS to connect to the server or not. * @param useStartTLS whether we must use SSL to connect to the server or not. */ void setUseStartTLS(boolean useStartTLS) { this.useStartTLS = useStartTLS; } /** * Returns the bind DN to be used to connect to the server if no Administrator * has been defined. * @return the bind DN to be used to connect to the server if no Administrator opendj3-server-dev/src/server/org/opends/server/tools/dsreplication/ReplicationCliMain.java
Diff too large