| | |
| | | import org.opends.quicksetup.util.Utils; |
| | | import org.opends.server.tools.BackendTypeHelper; |
| | | import org.opends.server.tools.BackendTypeHelper.BackendTypeUIAdapter; |
| | | import org.opends.server.types.HostPort; |
| | | import org.opends.server.util.CertificateManager; |
| | | import org.opends.server.util.DynamicConstants; |
| | | import org.opends.server.util.SetupUtils; |
| | |
| | | AuthenticationData auth = repl.getAuthenticationData(); |
| | | if (isVerbose()) |
| | | { |
| | | notifyListeners(getFormattedWithPoints(INFO_PROGRESS_UNCONFIGURING_ADS_ON_REMOTE.get(getHostDisplay(auth)))); |
| | | notifyListeners(getFormattedWithPoints(INFO_PROGRESS_UNCONFIGURING_ADS_ON_REMOTE.get(auth.getHostPort()))); |
| | | } |
| | | try |
| | | { |
| | |
| | | adsServers.add(getLocalReplicationServer()); |
| | | for (String dn : baseDns) |
| | | { |
| | | replicationServers.put(dn, new HashSet<String>(h)); |
| | | replicationServers.put(dn, h); |
| | | } |
| | | } |
| | | else |
| | |
| | | AuthenticationData repPort = getUserData().getRemoteWithNoReplicationPort().get(server); |
| | | if (repPort != null) |
| | | { |
| | | h.add(server.getHostName() + ":" + repPort.getPort()); |
| | | adsServers.add(server.getHostName() + ":" + repPort.getPort()); |
| | | String serverDisplay = server.getHostName() + ":" + repPort.getPort(); |
| | | h.add(serverDisplay); |
| | | adsServers.add(serverDisplay); |
| | | } |
| | | } |
| | | replicationServers.put(suffix.getDN(), h); |
| | |
| | | ConnectionWrapper connWrapper = null; |
| | | long localTime = -1; |
| | | long localTimeMeasureTime = -1; |
| | | String localServerDisplay = null; |
| | | HostPort localServerDisplay = null; |
| | | try |
| | | { |
| | | connWrapper = createLocalConnection(); |
| | | helper.configureReplication(connWrapper, replicationServers, |
| | | getUserData().getReplicationOptions().getReplicationPort(), |
| | | getUserData().getReplicationOptions().useSecureReplication(), |
| | | getLocalHostPort(), |
| | | getUserData().getHostPort(), |
| | | knownReplicationServerIds, knownServerIds); |
| | | localTimeMeasureTime = System.currentTimeMillis(); |
| | | localTime = Utils.getServerClock(connWrapper.getLdapContext()); |
| | |
| | | |
| | | ReplicaDescriptor replica = suffix.getReplicas().iterator().next(); |
| | | ServerDescriptor server = replica.getServer(); |
| | | String hostPort = getHostPort(server); |
| | | HostPort hostPort = getHostPort(server); |
| | | |
| | | boolean isADS = areDnsEqual(dn, ADSContext.getAdministrationSuffixDN()); |
| | | boolean isSchema = areDnsEqual(dn, Constants.SCHEMA_DN); |
| | |
| | | { |
| | | if (isVerbose()) |
| | | { |
| | | notifyListeners(getFormattedWithPoints(INFO_PROGRESS_CREATING_ADS_ON_REMOTE.get(getHostDisplay(auth)))); |
| | | notifyListeners(getFormattedWithPoints(INFO_PROGRESS_CREATING_ADS_ON_REMOTE.get(auth.getHostPort()))); |
| | | } |
| | | |
| | | adsContext.createAdminData(null); |
| | |
| | | LocalizableMessage msg; |
| | | if (isRemoteServer) |
| | | { |
| | | msg = getMessageForException(ne, getHostDisplay(auth)); |
| | | msg = getMessageForException(ne, auth.getHostPort().toString()); |
| | | } |
| | | else |
| | | { |
| | |
| | | catch (ADSContextException ace) |
| | | { |
| | | throw new ApplicationException(ReturnCode.CONFIGURATION_ERROR, (isRemoteServer ? INFO_REMOTE_ADS_EXCEPTION.get( |
| | | getHostDisplay(auth), ace.getMessageObject()) : INFO_ADS_EXCEPTION.get(ace)), ace); |
| | | auth.getHostPort(), ace.getMessageObject()) : INFO_ADS_EXCEPTION.get(ace)), ace); |
| | | } |
| | | finally |
| | | { |
| | |
| | | |
| | | private ConnectionWrapper createConnection(AuthenticationData auth) throws NamingException |
| | | { |
| | | String ldapUrl = getLdapUrl(auth); |
| | | String ldapUrl = auth.getLdapUrl(); |
| | | String dn = auth.getDn(); |
| | | String pwd = auth.getPwd(); |
| | | |
| | | InitialLdapContext context = null; |
| | | |
| | | InitialLdapContext context; |
| | | if (auth.useSecureConnection()) |
| | | { |
| | | ApplicationTrustManager trustManager = getTrustManager(); |
| | | trustManager.setHost(auth.getHostName()); |
| | | trustManager.setHost(auth.getHostPort().getHost()); |
| | | context = createLdapsContext(ldapUrl, dn, pwd, getConnectTimeout(), null, trustManager, null); |
| | | } |
| | | else |
| | |
| | | { |
| | | type = PreferredConnection.Type.LDAP; |
| | | } |
| | | cnx.add(new PreferredConnection(getLdapUrl(auth), type)); |
| | | cnx.add(new PreferredConnection(auth.getLdapUrl(), type)); |
| | | } |
| | | } |
| | | return cnx; |
| | | } |
| | | |
| | | private String getLdapUrl(AuthenticationData auth) |
| | | { |
| | | if (auth.useSecureConnection()) |
| | | { |
| | | return "ldaps://" + auth.getHostName() + ":" + auth.getPort(); |
| | | } |
| | | return "ldap://" + auth.getHostName() + ":" + auth.getPort(); |
| | | } |
| | | |
| | | private String getHostDisplay(AuthenticationData auth) |
| | | { |
| | | return auth.getHostName() + ":" + auth.getPort(); |
| | | } |
| | | |
| | | private Map<ADSContext.ServerProperty, Object> getNewServerAdsProperties(UserData userData) |
| | | { |
| | | Map<ADSContext.ServerProperty, Object> serverProperties = new HashMap<>(); |
| | |
| | | if (errorMsgs.isEmpty()) |
| | | { |
| | | AuthenticationData auth = new AuthenticationData(); |
| | | auth.setHostName(host); |
| | | if (port != null) |
| | | { |
| | | auth.setPort(port); |
| | | } |
| | | auth.setHostPort(new HostPort(host, port != null ? port : 0)); |
| | | auth.setDn(dn); |
| | | auth.setPwd(pwd); |
| | | auth.setUseSecureConnection(true); |
| | |
| | | getUserData().setEnableWindowsService(b); |
| | | } |
| | | |
| | | /** |
| | | * Returns the number of free disk space in bytes required to install Open DS |
| | | * For the moment we just return 20 Megabytes. TODO we might want to have |
| | | * something dynamic to calculate the required free disk space for the |
| | | * installation. |
| | | * |
| | | * @return the number of free disk space required to install Open DS. |
| | | */ |
| | | private long getRequiredInstallSpace() |
| | | { |
| | | return 20 * 1024 * 1024; |
| | | } |
| | | |
| | | /** Update the UserInstallData with the contents we discover in the ADS. */ |
| | | private Set<TopologyCacheException> updateUserDataWithSuffixesInADS(ADSContext adsContext, |
| | | ApplicationTrustManager trustManager) throws TopologyCacheException |
| | |
| | | * if the replication mechanism cannot find a peer. |
| | | */ |
| | | public void initializeSuffix(InitialLdapContext ctx, int replicaId, String suffixDn, boolean displayProgress, |
| | | String sourceServerDisplay) throws ApplicationException, PeerNotFoundException |
| | | HostPort sourceServerDisplay) throws ApplicationException, PeerNotFoundException |
| | | { |
| | | boolean taskCreated = false; |
| | | int i = 1; |
| | |
| | | return getUserData().getHostName() + ":" + getUserData().getReplicationOptions().getReplicationPort(); |
| | | } |
| | | |
| | | private String getLocalHostPort() |
| | | { |
| | | return getUserData().getHostName() + ":" + getUserData().getServerPort(); |
| | | } |
| | | |
| | | private void resetGenerationId(InitialLdapContext ctx, String suffixDn, String sourceServerDisplay) |
| | | private void resetGenerationId(InitialLdapContext ctx, String suffixDn, HostPort sourceServerDisplay) |
| | | throws ApplicationException |
| | | { |
| | | boolean taskCreated = false; |
| | |
| | | * the ServerDescriptor. |
| | | * @return the host port string representation of the provided server. |
| | | */ |
| | | protected String getHostPort(ServerDescriptor server) |
| | | protected HostPort getHostPort(ServerDescriptor server) |
| | | { |
| | | String hostPort = null; |
| | | HostPort hostPort = null; |
| | | |
| | | for (PreferredConnection connection : getPreferredConnections()) |
| | | { |