| | |
| | | package org.opends.guitools.uninstaller; |
| | | |
| | | import static org.forgerock.util.Utils.*; |
| | | import static org.opends.admin.ads.util.ConnectionUtils.*; |
| | | import static org.opends.admin.ads.util.PreferredConnection.Type.*; |
| | | import static org.opends.messages.AdminToolMessages.*; |
| | | import static org.opends.messages.QuickSetupMessages.*; |
| | |
| | | import java.util.Set; |
| | | |
| | | import javax.naming.NamingException; |
| | | import javax.naming.NoPermissionException; |
| | | import javax.naming.ldap.InitialLdapContext; |
| | | import javax.net.ssl.TrustManager; |
| | | |
| | | import org.forgerock.i18n.LocalizableMessage; |
| | |
| | | import org.opends.admin.ads.TopologyCache; |
| | | import org.opends.admin.ads.TopologyCacheException; |
| | | import org.opends.admin.ads.util.ApplicationTrustManager; |
| | | import org.opends.admin.ads.util.ConnectionUtils; |
| | | import org.opends.admin.ads.util.ConnectionWrapper; |
| | | import org.opends.admin.ads.util.PreferredConnection.Type; |
| | | import org.opends.guitools.controlpanel.datamodel.ConnectionProtocolPolicy; |
| | |
| | | * @param args |
| | | * the ArgumentParser with the allowed arguments of the command line. |
| | | * The code assumes that the arguments have already been parsed. |
| | | * @param rawArguments |
| | | * the arguments provided in the command line. |
| | | * @return the UserData object with what the user wants to uninstall and null |
| | | * if the user cancels the uninstallation. |
| | | * @throws UserDataException |
| | |
| | | * If there is an error processing data in non-interactive mode and |
| | | * an error must be thrown (not in force on error mode). |
| | | */ |
| | | public UninstallUserData createUserData(UninstallerArgumentParser args, String[] rawArguments) |
| | | public UninstallUserData createUserData(UninstallerArgumentParser args) |
| | | throws UserDataException, ClientException |
| | | { |
| | | parser = args; |
| | |
| | | @Override |
| | | public void cancel() |
| | | { |
| | | // no-op |
| | | } |
| | | @Override |
| | | public void run() |
| | | { |
| | | // no-op |
| | | } |
| | | }; |
| | | application.setProgressMessageFormatter( |
| | |
| | | } |
| | | |
| | | /** |
| | | * Returns an InitialLdapContext using the provided parameters. We try to |
| | | * guarantee that the connection is able to read the configuration. |
| | | * |
| | | * @param host |
| | | * the host name. |
| | | * @param port |
| | | * the port to connect. |
| | | * @param useSSL |
| | | * whether to use SSL or not. |
| | | * @param useStartTLS |
| | | * whether to use StartTLS or not. |
| | | * @param bindDn |
| | | * the bind dn to be used. |
| | | * @param pwd |
| | | * the password. |
| | | * @param connectTimeout |
| | | * the timeout in milliseconds to connect to the server. |
| | | * @param trustManager |
| | | * the trust manager. |
| | | * @return an InitialLdapContext connected. |
| | | * @throws NamingException |
| | | * if there was an error establishing the connection. |
| | | */ |
| | | private InitialLdapContext createAdministrativeContext(String host, |
| | | int port, boolean useSSL, boolean useStartTLS, String bindDn, String pwd, |
| | | int connectTimeout, ApplicationTrustManager trustManager) |
| | | throws NamingException |
| | | { |
| | | InitialLdapContext ctx; |
| | | String ldapUrl = ConnectionUtils.getLDAPUrl(host, port, useSSL); |
| | | if (useSSL) |
| | | { |
| | | ctx = createLdapsContext(ldapUrl, bindDn, pwd, connectTimeout, null, trustManager, null); |
| | | } |
| | | else if (useStartTLS) |
| | | { |
| | | ctx = |
| | | Utils.createStartTLSContext(ldapUrl, bindDn, pwd, connectTimeout, |
| | | null, trustManager, null); |
| | | } |
| | | else |
| | | { |
| | | ctx = createLdapContext(ldapUrl, bindDn, pwd, connectTimeout, null); |
| | | } |
| | | if (!ConnectionUtils.connectedAsAdministrativeUser(ctx)) |
| | | { |
| | | throw new NoPermissionException(ERR_NOT_ADMINISTRATIVE_USER.get() |
| | | .toString()); |
| | | } |
| | | return ctx; |
| | | } |
| | | |
| | | /** |
| | | * Updates the contents of the UninstallUserData while trying to connect to |
| | | * the remote servers. It returns <CODE>true</CODE> if we could connect to the |
| | | * remote servers and all the presented certificates were accepted and |