| | |
| | | import java.awt.event.WindowEvent; |
| | | |
| | | import javax.naming.Context; |
| | | import javax.naming.directory.SearchControls; |
| | | import javax.naming.NamingException; |
| | | import javax.naming.ldap.InitialLdapContext; |
| | | import javax.swing.JFrame; |
| | | import javax.swing.SwingUtilities; |
| | |
| | | private MessageBuilder startProgressDetails = new MessageBuilder(); |
| | | private UninstallData conf; |
| | | private String replicationServerHostPort; |
| | | private TopologyCache lastLoadedCache; |
| | | |
| | | /** |
| | | * Default constructor. |
| | |
| | | */ |
| | | public UserData createUserData(Launcher launcher) |
| | | throws UserDataException { |
| | | return cliHelper.createUserData(launcher.getArgumentParser(), |
| | | launcher.getArguments(), getTrustManager()); |
| | | return cliHelper.createUserData( |
| | | (UninstallerArgumentParser)launcher.getArgumentParser(), |
| | | launcher.getArguments()); |
| | | |
| | | } |
| | | |
| | | /** |
| | |
| | | } |
| | | |
| | | /** |
| | | * {@inheritDoc} |
| | | */ |
| | | protected ApplicationTrustManager getTrustManager() |
| | | { |
| | | return getUninstallUserData().getTrustManager(); |
| | | } |
| | | |
| | | /** |
| | | * This methods disables this server as a Windows service. |
| | | * |
| | | * @throws ApplicationException if something goes wrong. |
| | |
| | | loginDialog.setVisible(true); |
| | | if (!loginDialog.isCancelled()) |
| | | { |
| | | getUninstallUserData().setAdminUID(loginDialog.getAdministratorUid()); |
| | | getUninstallUserData().setAdminPwd(loginDialog.getAdministratorPwd()); |
| | | getUninstallUserData().setReferencedHostName(loginDialog.getHostName()); |
| | | final InitialLdapContext ctx = loginDialog.getContext(); |
| | | |
| | | try |
| | | { |
| | | getUninstallUserData().setLocalServerUrl( |
| | | (String)ctx.getEnvironment().get(Context.PROVIDER_URL)); |
| | | } |
| | | catch (NamingException ne) |
| | | { |
| | | LOG.log(Level.WARNING, "Could not find local server: "+ne, ne); |
| | | getUninstallUserData().setLocalServerUrl("ldap://localhost:389"); |
| | | } |
| | | replicationServerHostPort = loginDialog.getHostName() + ":" + |
| | | conf.getReplicationServerPort(); |
| | | |
| | |
| | | if (!stopProcessing && (exceptionMsgs.size() > 0)) |
| | | { |
| | | Message confirmationMsg = |
| | | INFO_ERROR_READING_REGISTERED_SERVERS_CONFIRM.get( |
| | | INFO_ERROR_READING_REGISTERED_SERVERS_CONFIRM_UPDATE_REMOTE.get( |
| | | getStringFromCollection(exceptionMsgs, "n")); |
| | | stopProcessing = !qs.displayConfirmation(confirmationMsg, |
| | | INFO_CONFIRMATION_TITLE.get()); |
| | |
| | | if (!stopProcessing) |
| | | { |
| | | // Launch everything |
| | | lastLoadedCache = cache; |
| | | getUninstallUserData().setUpdateRemoteReplication(true); |
| | | getUninstallUserData().setRemoteServers(cache.getServers()); |
| | | getUserData().setStopServer(true); |
| | | qs.launch(); |
| | | qs.setCurrentStep(getNextWizardStep(Step.CONFIRM_UNINSTALL)); |
| | |
| | | getTrustManager().acceptCertificate(chain, authType, host); |
| | | BackgroundTask worker = new BackgroundTask() |
| | | { |
| | | public Object processBackgroundTask()throws TopologyCacheException |
| | | public Object processBackgroundTask() throws TopologyCacheException |
| | | { |
| | | cache.reloadTopology(); |
| | | return cache; |
| | |
| | | } |
| | | |
| | | /** |
| | | * This method updates the replication in the remote servers. It does not |
| | | * thrown any exception and works in a best effort mode. |
| | | * This method updates the replication in the remote servers. It does |
| | | * throw ApplicationException if we are working on the force on error mode. |
| | | * It also tries to delete the server registration entry from the remote ADS |
| | | * servers. |
| | | * @throws ApplicationException if we are not working on force on error mode |
| | | * and there is an error. |
| | | */ |
| | | private void removeRemoteServerReferences() |
| | | private void removeRemoteServerReferences() throws ApplicationException |
| | | { |
| | | Set<ServerDescriptor> servers = lastLoadedCache.getServers(); |
| | | Set<ServerDescriptor> servers = getUninstallUserData().getRemoteServers(); |
| | | Map<ADSContext.ServerProperty, Object> serverADSProperties = null; |
| | | for (ServerDescriptor server : servers) |
| | | { |
| | |
| | | * we want to remove references to the server that we are trying to uninstall. |
| | | * @param serverADSProperties the Map with the ADS properties of the server |
| | | * that we are trying to uninstall. |
| | | * @throws ApplicationException if we are not working on force on error mode |
| | | * and there is an error. |
| | | */ |
| | | private void removeReferences(ServerDescriptor server, |
| | | Map<ADSContext.ServerProperty, Object> serverADSProperties) |
| | | throws ApplicationException |
| | | { |
| | | /* First check if the server must be updated based in the contents of the |
| | | * ServerDescriptor object. */ |
| | |
| | | InitialLdapContext ctx = null; |
| | | try |
| | | { |
| | | String dn = |
| | | ADSContext.getAdministratorDN(loginDialog.getAdministratorUid()); |
| | | String pwd = loginDialog.getAdministratorPwd(); |
| | | String dn = ADSContext.getAdministratorDN( |
| | | getUninstallUserData().getAdminUID()); |
| | | String pwd = getUninstallUserData().getAdminPwd(); |
| | | ctx = getRemoteConnection(server, dn, pwd, getTrustManager()); |
| | | try |
| | | { |
| | | /* |
| | | * Search for the config to check that it is the directory manager. |
| | | */ |
| | | SearchControls searchControls = new SearchControls(); |
| | | searchControls.setCountLimit(1); |
| | | searchControls.setSearchScope( |
| | | SearchControls. OBJECT_SCOPE); |
| | | searchControls.setReturningAttributes(new String[] {"*"}); |
| | | ctx.search("cn=config", "objectclass=*", searchControls); |
| | | } |
| | | catch (Throwable t) |
| | | { |
| | | System.out.println("FUCK: "+t); |
| | | t.printStackTrace(); |
| | | } |
| | | |
| | | // Update replication servers and domains. If the domain |
| | | // is an ADS, then remove it from there. |
| | | removeReferences(ctx, server.getHostPort(true), serverADSProperties); |
| | |
| | | catch (ApplicationException ae) |
| | | { |
| | | errorOnRemoteOccurred = true; |
| | | Message html = getFormattedError(ae, true); |
| | | notifyListeners(html); |
| | | LOG.log(Level.INFO, "Error updating replication references in: "+ |
| | | server.getHostPort(true), ae); |
| | | } |
| | | if (ctx != null) |
| | | { |
| | | try |
| | | |
| | | if (getUninstallUserData().isForceOnError()) |
| | | { |
| | | ctx.close(); |
| | | throw ae; |
| | | } |
| | | catch (Throwable t) |
| | | else |
| | | { |
| | | Message html = getFormattedError(ae, true); |
| | | notifyListeners(html); |
| | | } |
| | | } |
| | | finally |
| | | { |
| | | if (ctx != null) |
| | | { |
| | | try |
| | | { |
| | | ctx.close(); |
| | | } |
| | | catch (Throwable t) |
| | | { |
| | | } |
| | | } |
| | | } |
| | | } |
| | |
| | | // Compare the port of the URL we used. |
| | | try |
| | | { |
| | | String usedUrl = (String) |
| | | loginDialog.getContext().getEnvironment().get(Context.PROVIDER_URL); |
| | | String usedUrl = getUninstallUserData().getLocalServerUrl(); |
| | | boolean isSecure = usedUrl.toLowerCase().startsWith("ldaps"); |
| | | URI uri = new URI(usedUrl); |
| | | int port = uri.getPort(); |