Fix an issue with connection timeouts in CLI. The timeout is now configurable on CLI with the --connectTimeout option (expressed in milliseconds), the default is 30 000 milliseconds.
This solves Issue 4196.
1 files deleted
42 files modified
| | |
| | | * CDDL HEADER END |
| | | * |
| | | * |
| | | * Copyright 2008-2009 Sun Microsystems, Inc. |
| | | * Copyright 2008-2010 Sun Microsystems, Inc. |
| | | */ |
| | | |
| | | package org.opends.admin.ads; |
| | |
| | | { |
| | | private ADSContext adsContext; |
| | | private ApplicationTrustManager trustManager; |
| | | private int timeout; |
| | | private String dn; |
| | | private String pwd; |
| | | private Set<ServerDescriptor> servers = new HashSet<ServerDescriptor>(); |
| | |
| | | * @param trustManager the ApplicationTrustManager that must be used to trust |
| | | * certificates when we create connections to the registered servers to read |
| | | * their configuration. |
| | | * @param timeout the timeout to establish the connection in milliseconds. |
| | | * Use {@code 0} to express no timeout. |
| | | */ |
| | | public TopologyCache(ADSContext adsContext, |
| | | ApplicationTrustManager trustManager) |
| | | ApplicationTrustManager trustManager, |
| | | int timeout) |
| | | { |
| | | this.adsContext = adsContext; |
| | | this.trustManager = trustManager; |
| | | this.timeout = timeout; |
| | | dn = ConnectionUtils.getBindDN(adsContext.getDirContext()); |
| | | pwd = ConnectionUtils.getBindPassword(adsContext.getDirContext()); |
| | | } |
| | |
| | | } |
| | | |
| | | /** |
| | | * Returns the timeout to establish the connection in milliseconds. |
| | | * @return the timeout to establish the connection in milliseconds. Returns |
| | | * {@code 0} to express no timeout. |
| | | */ |
| | | public int getConnectTimeout() |
| | | { |
| | | return timeout; |
| | | } |
| | | |
| | | /** |
| | | * Reads the replication monitoring. |
| | | * @throws NamingException if an error occurs reading the replication |
| | | * monitoring. |
| | |
| | | { |
| | | return new ServerLoader(serverProperties, dn, pwd, |
| | | trustManager == null ? null : trustManager.createCopy(), |
| | | timeout, |
| | | getPreferredConnections(), getFilter()); |
| | | } |
| | | |
| | |
| | | ServerLoader loader = |
| | | getServerLoader(replicationServer.getAdsProperties()); |
| | | ctx = loader.createContext(); |
| | | NamingEnumeration monitorEntries = ctx.search(jndiName, filter, ctls); |
| | | NamingEnumeration<SearchResult> monitorEntries = |
| | | ctx.search(jndiName, filter, ctls); |
| | | |
| | | while(monitorEntries.hasMore()) |
| | | { |
| | | SearchResult sr = (SearchResult)monitorEntries.next(); |
| | | SearchResult sr = monitorEntries.next(); |
| | | |
| | | String dn = ConnectionUtils.getFirstValue(sr, "domain-name"); |
| | | int replicaId = -1; |
| | |
| | | * Clones the provided InitialLdapContext and returns a connection using |
| | | * the same parameters. |
| | | * @param ctx hte connection to be cloned. |
| | | * @param timeout the timeout to establish the connection. |
| | | * @param timeout the timeout to establish the connection in milliseconds. |
| | | * Use {@code 0} to express no timeout. |
| | | * @param trustManager the trust manager to be used to connect. |
| | | * @param keyManager the key manager to be used to connect. |
| | | * @return the new InitialLdapContext connected to the server. |
| | |
| | | * @param ldapUrl the ldap URL of the server. |
| | | * @param dn the dn to be used. |
| | | * @param pwd the password to be used. |
| | | * @param timeout the timeout to establish the connection in milliseconds. |
| | | * Use {@code 0} to express no timeout. |
| | | * @return <CODE>true</CODE> if we can connect and read the configuration and |
| | | * <CODE>false</CODE> otherwise. |
| | | */ |
| | | public static boolean canConnectAsAdministrativeUser(String ldapUrl, |
| | | String dn, String pwd) |
| | | String dn, String pwd, int timeout) |
| | | { |
| | | boolean canConnectAsAdministrativeUser = false; |
| | | try |
| | |
| | | InitialLdapContext ctx; |
| | | if (ldapUrl.toLowerCase().startsWith("ldap:")) |
| | | { |
| | | ctx = createLdapContext(ldapUrl, dn, pwd, getDefaultLDAPTimeout(), |
| | | ctx = createLdapContext(ldapUrl, dn, pwd, timeout, |
| | | null); |
| | | } |
| | | else |
| | | { |
| | | ctx = createLdapsContext(ldapUrl, dn, pwd, getDefaultLDAPTimeout(), |
| | | ctx = createLdapsContext(ldapUrl, dn, pwd, timeout, |
| | | null, null, null); |
| | | } |
| | | |
| | |
| | | * @param t the Thread to be used to create the InitialLdapContext. |
| | | * @param pair an Object[] array that contains the InitialLdapContext and the |
| | | * Throwable if any occurred. |
| | | * @param timeout the timeout. If we do not get to create the connection |
| | | * before the timeout a CommunicationException will be thrown. |
| | | * @param timeout the timeout in milliseconds. If we do not get to create the |
| | | * connection before the timeout a CommunicationException will be thrown. |
| | | * @return the created InitialLdapContext |
| | | * @throws NamingException if something goes wrong during the creation. |
| | | */ |
| | |
| | | * CDDL HEADER END |
| | | * |
| | | * |
| | | * Copyright 2008 Sun Microsystems, Inc. |
| | | * Copyright 2008-2010 Sun Microsystems, Inc. |
| | | */ |
| | | |
| | | package org.opends.admin.ads.util; |
| | |
| | | private TopologyCacheException lastException; |
| | | private ServerDescriptor serverDescriptor; |
| | | private ApplicationTrustManager trustManager; |
| | | private int timeout; |
| | | private String dn; |
| | | private String pwd; |
| | | private LinkedHashSet<PreferredConnection> preferredLDAPURLs; |
| | |
| | | * @param pwd the password that we must use to bind to the server. |
| | | * @param trustManager the ApplicationTrustManager to be used when we try |
| | | * to connect to the server. |
| | | * @param timeout the timeout to establish the connection in milliseconds. |
| | | * Use {@code 0} to express no timeout. |
| | | * @param preferredLDAPURLs the list of preferred LDAP URLs that we want |
| | | * to use to connect to the server. They will be used only if they correspond |
| | | * to the URLs that we found in the the server properties. |
| | |
| | | */ |
| | | public ServerLoader(Map<ServerProperty,Object> serverProperties, |
| | | String dn, String pwd, ApplicationTrustManager trustManager, |
| | | int timeout, |
| | | LinkedHashSet<PreferredConnection> preferredLDAPURLs, |
| | | TopologyCacheFilter filter) |
| | | { |
| | |
| | | this.dn = dn; |
| | | this.pwd = pwd; |
| | | this.trustManager = trustManager; |
| | | this.timeout = timeout; |
| | | this.preferredLDAPURLs = |
| | | new LinkedHashSet<PreferredConnection>(preferredLDAPURLs); |
| | | this.filter = filter; |
| | |
| | | { |
| | | case LDAPS: |
| | | ctx = ConnectionUtils.createLdapsContext(lastLdapUrl, dn, pwd, |
| | | ConnectionUtils.getDefaultLDAPTimeout(), null, trustManager, |
| | | timeout, null, trustManager, |
| | | null); |
| | | break; |
| | | case START_TLS: |
| | | ctx = ConnectionUtils.createStartTLSContext(lastLdapUrl, dn, pwd, |
| | | ConnectionUtils.getDefaultLDAPTimeout(), null, trustManager, |
| | | timeout, null, trustManager, |
| | | null, null); |
| | | break; |
| | | default: |
| | | ctx = ConnectionUtils.createLdapContext(lastLdapUrl, dn, pwd, |
| | | ConnectionUtils.getDefaultLDAPTimeout(), null); |
| | | timeout, null); |
| | | } |
| | | } |
| | | } |
| | |
| | | { |
| | | info.setTrustManager(new BlindApplicationTrustManager()); |
| | | } |
| | | info.setConnectTimeout(argParser.getConnectTimeout()); |
| | | } |
| | | |
| | | /** |
| | |
| | | * CDDL HEADER END |
| | | * |
| | | * |
| | | * Copyright 2009 Sun Microsystems, Inc. |
| | | * Copyright 2009-2010 Sun Microsystems, Inc. |
| | | */ |
| | | |
| | | package org.opends.guitools.controlpanel; |
| | | |
| | | import static org.opends.messages.ToolMessages.*; |
| | | import static org.opends.server.tools.ToolConstants.OPTION_LONG_BINDDN; |
| | | import static org.opends.server.tools.ToolConstants.OPTION_LONG_BINDPWD; |
| | | import static org.opends.server.tools.ToolConstants.OPTION_LONG_BINDPWD_FILE; |
| | | import static org.opends.server.tools.ToolConstants.OPTION_LONG_HELP; |
| | | import static org.opends.server.tools.ToolConstants.OPTION_LONG_HOST; |
| | | import static org.opends.server.tools.ToolConstants.OPTION_LONG_PORT; |
| | | import static org.opends.server.tools.ToolConstants.OPTION_LONG_TRUSTALL; |
| | | import static org.opends.server.tools.ToolConstants.OPTION_SHORT_BINDDN; |
| | | import static org.opends.server.tools.ToolConstants.OPTION_SHORT_BINDPWD; |
| | | import static org.opends.server.tools.ToolConstants.OPTION_SHORT_BINDPWD_FILE; |
| | | import static org.opends.server.tools.ToolConstants.OPTION_SHORT_HELP; |
| | | import static org.opends.server.tools.ToolConstants.OPTION_SHORT_HOST; |
| | | import static org.opends.server.tools.ToolConstants.OPTION_SHORT_PORT; |
| | | import static org.opends.server.tools.ToolConstants.OPTION_SHORT_TRUSTALL; |
| | | import static org.opends.server.tools.ToolConstants.*; |
| | | |
| | | import java.util.LinkedHashSet; |
| | | |
| | | import org.opends.admin.ads.util.ConnectionUtils; |
| | | import org.opends.messages.Message; |
| | | import org.opends.quicksetup.Constants; |
| | | import org.opends.quicksetup.UserData; |
| | |
| | | */ |
| | | private BooleanArgument trustAllArg = null; |
| | | |
| | | /** |
| | | * Argument to specify the connect timeout. |
| | | */ |
| | | private IntegerArgument connectTimeoutArg = null; |
| | | |
| | | private BooleanArgument showUsageArg; |
| | | |
| | | /** |
| | |
| | | portArg = new IntegerArgument("port", OPTION_SHORT_PORT, OPTION_LONG_PORT, |
| | | false, false, true, INFO_PORT_PLACEHOLDER.get(), |
| | | getDefaultAdministrationPort(), null, |
| | | true, 1, true, 65535, |
| | | INFO_DESCRIPTION_ADMIN_PORT.get()); |
| | | portArg.setPropertyName(OPTION_LONG_PORT); |
| | | addArgument(portArg); |
| | |
| | | trustAllArg.setPropertyName(OPTION_LONG_TRUSTALL); |
| | | addArgument(trustAllArg); |
| | | |
| | | int defaultTimeout = ConnectionUtils.getDefaultLDAPTimeout(); |
| | | connectTimeoutArg = new IntegerArgument(OPTION_LONG_CONNECT_TIMEOUT, |
| | | null, OPTION_LONG_CONNECT_TIMEOUT, |
| | | false, false, true, INFO_TIMEOUT_PLACEHOLDER.get(), |
| | | defaultTimeout, null, |
| | | true, 0, false, Integer.MAX_VALUE, |
| | | INFO_DESCRIPTION_CONNECTION_TIMEOUT.get()); |
| | | connectTimeoutArg.setPropertyName(OPTION_LONG_CONNECT_TIMEOUT); |
| | | addArgument(connectTimeoutArg); |
| | | |
| | | showUsageArg = new BooleanArgument("help", OPTION_SHORT_HELP, |
| | | OPTION_LONG_HELP, |
| | | INFO_DESCRIPTION_USAGE.get()); |
| | |
| | | return trustAllArg.isPresent(); |
| | | } |
| | | |
| | | /** |
| | | * Returns the timeout to be used to connect in milliseconds. The method |
| | | * must be called after parsing the arguments. |
| | | * @return the timeout to be used to connect in milliseconds. Returns |
| | | * {@code 0} if there is no timeout. |
| | | * @throw {@code IllegalStateException} if the method is called before |
| | | * parsing the arguments. |
| | | */ |
| | | public int getConnectTimeout() |
| | | { |
| | | try |
| | | { |
| | | return connectTimeoutArg.getIntValue(); |
| | | } |
| | | catch (ArgumentException ae) |
| | | { |
| | | throw new IllegalStateException("Argument parser is not parsed: "+ae, ae); |
| | | } |
| | | } |
| | | |
| | | } |
| | |
| | | |
| | | private Control[] requestControls = new Control[] {}; |
| | | private ApplicationTrustManager trustManager; |
| | | private int connectTimeout = ConnectionUtils.getDefaultLDAPTimeout(); |
| | | |
| | | /** |
| | | * Returns <CODE>true</CODE> if the connection passed is registered in the |
| | |
| | | if (isSecureLDAPUrl(ldapUrl)) |
| | | { |
| | | ctx = ConnectionUtils.createLdapsContext(ldapUrl.toString(), ar.dn, |
| | | ar.password, ConnectionUtils.getDefaultLDAPTimeout(), null, |
| | | ar.password, getConnectTimeout(), null, |
| | | getTrustManager() , getKeyManager()); |
| | | } |
| | | else |
| | | { |
| | | ctx = ConnectionUtils.createLdapContext(ldapUrl.toString(), ar.dn, |
| | | ar.password, ConnectionUtils.getDefaultLDAPTimeout(), null); |
| | | ar.password, getConnectTimeout(), null); |
| | | } |
| | | return ctx; |
| | | } |
| | |
| | | return trustManager; |
| | | } |
| | | |
| | | /** |
| | | * Returns the timeout to establish the connection in milliseconds. |
| | | * @return the timeout to establish the connection in milliseconds. |
| | | */ |
| | | public int getConnectTimeout() |
| | | { |
| | | return connectTimeout; |
| | | } |
| | | |
| | | /** |
| | | * Sets the timeout to establish the connection in milliseconds. |
| | | * Use {@code 0} to express no timeout. |
| | | * @param connectTimeout the timeout to establish the connection in |
| | | * milliseconds. |
| | | * Use {@code 0} to express no timeout. |
| | | */ |
| | | public void setConnectTimeout(int connectTimeout) |
| | | { |
| | | this.connectTimeout = connectTimeout; |
| | | } |
| | | |
| | | private KeyManager getKeyManager() |
| | | { |
| | | // TODO: we should get it from ControlPanelInfo |
| | |
| | | private boolean stopPooling; |
| | | private boolean pooling; |
| | | private ApplicationTrustManager trustManager; |
| | | private int connectTimeout = ConnectionUtils.getDefaultLDAPTimeout(); |
| | | private ConnectionProtocolPolicy connectionPolicy = |
| | | ConnectionProtocolPolicy.USE_MOST_SECURE_AVAILABLE; |
| | | private String ldapURL; |
| | |
| | | { |
| | | InitialLdapContext cloneLdc = |
| | | ConnectionUtils.cloneInitialLdapContext(userDataCtx, |
| | | ConnectionUtils.getDefaultLDAPTimeout(), |
| | | getConnectTimeout(), |
| | | getTrustManager(), null); |
| | | connectionPool.registerConnection(cloneLdc); |
| | | } |
| | |
| | | ctx = Utils.createLdapsContext(lastRemoteAdministrationURL, |
| | | lastWorkingBindDN, |
| | | lastWorkingBindPwd, |
| | | Utils.getDefaultLDAPTimeout(), null, |
| | | getConnectTimeout(), null, |
| | | getTrustManager()); |
| | | } |
| | | } |
| | |
| | | } |
| | | |
| | | /** |
| | | * Returns the timeout to establish the connection in milliseconds. |
| | | * @return the timeout to establish the connection in milliseconds. |
| | | */ |
| | | public int getConnectTimeout() |
| | | { |
| | | return connectTimeout; |
| | | } |
| | | |
| | | /** |
| | | * Sets the timeout to establish the connection in milliseconds. |
| | | * Use {@code 0} to express no timeout. |
| | | * @param connectTimeout the timeout to establish the connection in |
| | | * milliseconds. |
| | | * Use {@code 0} to express no timeout. |
| | | */ |
| | | public void setConnectTimeout(int connectTimeout) |
| | | { |
| | | this.connectTimeout = connectTimeout; |
| | | connectionPool.setConnectTimeout(connectTimeout); |
| | | } |
| | | |
| | | /** |
| | | * Returns the connection policy to be used by this ControlPanelInfo (and in |
| | | * general by the control panel). |
| | | * @return the connection policy to be used by this ControlPanelInfo. |
| | |
| | | * CDDL HEADER END |
| | | * |
| | | * |
| | | * Copyright 2008-2009 Sun Microsystems, Inc. |
| | | * Copyright 2008-2010 Sun Microsystems, Inc. |
| | | */ |
| | | |
| | | package org.opends.guitools.controlpanel.task; |
| | |
| | | try |
| | | { |
| | | ctx1 = ConnectionUtils.cloneInitialLdapContext(ctx, |
| | | ConnectionUtils.getDefaultLDAPTimeout(), |
| | | getInfo().getConnectTimeout(), |
| | | getInfo().getTrustManager(), null); |
| | | Control[] ctls = { |
| | | new BasicControl(ServerConstants.OID_SUBTREE_DELETE_CONTROL)}; |
| | |
| | | new Integer(port.getText().trim()), true); |
| | | ctx = Utils.createLdapsContext(usedUrl, dn.getText(), |
| | | String.valueOf(pwd.getPassword()), |
| | | Utils.getDefaultLDAPTimeout(), null, |
| | | getInfo().getConnectTimeout(), null, |
| | | getInfo().getTrustManager()); |
| | | checkVersion(ctx); |
| | | } |
| | |
| | | ERR_COULD_NOT_FIND_VALID_LDAPURL.get()); |
| | | } |
| | | ctx = Utils.createLdapsContext(usedUrl, |
| | | bindDN, pwd, Utils.getDefaultLDAPTimeout(), null, |
| | | bindDN, pwd, controlInfo.getConnectTimeout(), null, |
| | | controlInfo.getTrustManager()); |
| | | |
| | | /* |
| | |
| | | ERR_COULD_NOT_FIND_VALID_LDAPURL.get()); |
| | | } |
| | | ctx = Utils.createStartTLSContext(usedUrl, |
| | | bindDN, pwd, Utils.getDefaultLDAPTimeout(), null, |
| | | bindDN, pwd, controlInfo.getConnectTimeout(), null, |
| | | controlInfo.getTrustManager(), null); |
| | | } |
| | | else if (controlInfo.connectUsingLDAPS()) |
| | |
| | | ERR_COULD_NOT_FIND_VALID_LDAPURL.get()); |
| | | } |
| | | ctx = Utils.createLdapsContext(usedUrl, |
| | | bindDN, pwd, Utils.getDefaultLDAPTimeout(), null, |
| | | bindDN, pwd, controlInfo.getConnectTimeout(), null, |
| | | controlInfo.getTrustManager()); |
| | | } |
| | | else |
| | |
| | | ERR_COULD_NOT_FIND_VALID_LDAPURL.get()); |
| | | } |
| | | ctx = Utils.createLdapContext(usedUrl, |
| | | bindDN, pwd, Utils.getDefaultLDAPTimeout(), null); |
| | | bindDN, pwd, controlInfo.getConnectTimeout(), null); |
| | | } |
| | | |
| | | checkCanReadConfig(ctx); |
| | |
| | | * CDDL HEADER END |
| | | * |
| | | * |
| | | * Copyright 2006-2009 Sun Microsystems, Inc. |
| | | * Copyright 2006-2010 Sun Microsystems, Inc. |
| | | */ |
| | | |
| | | package org.opends.guitools.uninstaller; |
| | |
| | | userData.setForceOnError(args.isForceOnError()); |
| | | userData.setTrustManager(args.getTrustManager()); |
| | | |
| | | userData.setConnectTimeout(getConnectTimeout()); |
| | | |
| | | /* |
| | | * Step 2: check that the provided parameters are compatible. |
| | | */ |
| | |
| | | } |
| | | info = ControlPanelInfo.getInstance(); |
| | | info.setTrustManager(userData.getTrustManager()); |
| | | info.setConnectTimeout(getConnectTimeout()); |
| | | info.regenerateDescriptor(); |
| | | info.setConnectionPolicy(ConnectionProtocolPolicy.USE_ADMIN); |
| | | |
| | |
| | | try |
| | | { |
| | | info.setTrustManager(userData.getTrustManager()); |
| | | |
| | | info.setConnectTimeout(getConnectTimeout()); |
| | | String host = "localhost"; |
| | | int port = 389; |
| | | String adminUid = userData.getAdminUID(); |
| | |
| | | LOG.log(Level.SEVERE, "Error parsing url: "+adminConnectorUrl); |
| | | } |
| | | ctx = createAdministrativeContext(host, port, useSSL, useStartTLS, dn, |
| | | pwd, userData.getTrustManager()); |
| | | pwd, getConnectTimeout(), |
| | | userData.getTrustManager()); |
| | | |
| | | ADSContext adsContext = new ADSContext(ctx); |
| | | if (interactive && (userData.getTrustManager() == null)) |
| | |
| | | } |
| | | LOG.log(Level.INFO, "Reloading topology"); |
| | | TopologyCache cache = new TopologyCache(adsContext, |
| | | userData.getTrustManager()); |
| | | userData.getTrustManager(), getConnectTimeout()); |
| | | cache.getFilter().setSearchMonitoringInformation(false); |
| | | cache.reloadTopology(); |
| | | |
| | |
| | | super.println(msg); |
| | | LOG.log(Level.WARNING, msg.toString()); |
| | | } |
| | | |
| | | /** |
| | | * Returns the timeout to be used to connect in milliseconds. The method |
| | | * must be called after parsing the arguments. |
| | | * @return the timeout to be used to connect in milliseconds. Returns |
| | | * {@code 0} if there is no timeout. |
| | | * @throw {@code IllegalStateException} if the method is called before |
| | | * parsing the arguments. |
| | | */ |
| | | private int getConnectTimeout() |
| | | { |
| | | try |
| | | { |
| | | return parser.getSecureArgsList().connectTimeoutArg.getIntValue(); |
| | | } |
| | | catch (ArgumentException ae) |
| | | { |
| | | throw new IllegalStateException("Argument parser is not parsed: "+ae, |
| | | ae); |
| | | } |
| | | } |
| | | } |
| | |
| | | if (loginDialog == null) |
| | | { |
| | | loginDialog = new LoginDialog(qs.getDialog().getFrame(), |
| | | getTrustManager()); |
| | | getTrustManager(), getConnectTimeout()); |
| | | loginDialog.pack(); |
| | | } |
| | | Utilities.centerOnComponent(loginDialog, qs.getDialog().getFrame()); |
| | |
| | | LOG.log(Level.INFO, "Loading Topology Cache in askForAuthentication"); |
| | | ADSContext adsContext = new ADSContext(ctx); |
| | | TopologyCache cache = new TopologyCache(adsContext, |
| | | getTrustManager()); |
| | | getTrustManager(), getConnectTimeout()); |
| | | cache.getFilter().setSearchMonitoringInformation(false); |
| | | cache.reloadTopology(); |
| | | return cache; |
| | |
| | | getUninstallUserData().getAdminUID()); |
| | | String pwd = getUninstallUserData().getAdminPwd(); |
| | | ctx = getRemoteConnection(server, dn, pwd, getTrustManager(), |
| | | getConnectTimeout(), |
| | | new LinkedHashSet<PreferredConnection>()); |
| | | |
| | | // Update replication servers and domains. If the domain |
| | |
| | | } |
| | | return isServerToUninstall; |
| | | } |
| | | |
| | | /** |
| | | * Returns the timeout to be used to connect in milliseconds. |
| | | * @return the timeout to be used to connect in milliseconds. Returns |
| | | * {@code 0} if there is no timeout. |
| | | */ |
| | | private int getConnectTimeout() |
| | | { |
| | | return getUserData().getConnectTimeout(); |
| | | } |
| | | } |
| | | |
| | |
| | | * CDDL HEADER END |
| | | * |
| | | * |
| | | * Copyright 2008 Sun Microsystems, Inc. |
| | | * Copyright 2008-2010 Sun Microsystems, Inc. |
| | | */ |
| | | |
| | | package org.opends.guitools.uninstaller; |
| | |
| | | secureArgsList.adminUidArg.setHidden(false); |
| | | defaultArgs.remove(secureArgsList.hostNameArg); |
| | | defaultArgs.remove(secureArgsList.portArg); |
| | | UserData uData = new UserData(); |
| | | referencedHostNameArg = new StringArgument("referencedHostName", |
| | | ToolConstants.OPTION_SHORT_HOST, |
| | | OPTION_LONG_REFERENCED_HOST_NAME, false, false, true, |
| | | INFO_HOST_PLACEHOLDER.get(), |
| | | uData.getHostName(), OPTION_LONG_REFERENCED_HOST_NAME, |
| | | UserData.getDefaultHostName(), OPTION_LONG_REFERENCED_HOST_NAME, |
| | | INFO_DESCRIPTION_REFERENCED_HOST.get()); |
| | | defaultArgs.add(referencedHostNameArg); |
| | | |
| | |
| | | private boolean isCancelled = true; |
| | | |
| | | private ApplicationTrustManager trustManager; |
| | | private int timeout; |
| | | |
| | | private InitialLdapContext ctx; |
| | | |
| | |
| | | * @param parent the parent frame for this dialog. |
| | | * @param trustManager the trust manager to be used for the secure |
| | | * connections. |
| | | * @param timeout the timeout to establish the connection in milliseconds. |
| | | * Use {@code 0} to express no timeout. |
| | | */ |
| | | public LoginDialog(JFrame parent, ApplicationTrustManager trustManager) |
| | | public LoginDialog(JFrame parent, ApplicationTrustManager trustManager, |
| | | int timeout) |
| | | { |
| | | super(parent); |
| | | setTitle(INFO_LOGIN_DIALOG_TITLE.get().toString()); |
| | |
| | | throw new IllegalArgumentException("The trustmanager cannot be null."); |
| | | } |
| | | this.trustManager = trustManager; |
| | | this.timeout = timeout; |
| | | /* |
| | | * TODO: find a way to calculate this dynamically. This is done to avoid |
| | | * all the text in a single line. |
| | |
| | | gbc.weightx = 1.0; |
| | | gbc.insets.left = UIFactory.LEFT_INSET_PRIMARY_FIELD; |
| | | gbc.gridwidth = GridBagConstraints.REMAINDER; |
| | | UserData uData = new UserData(); |
| | | tfHostName = UIFactory.makeJTextField(Message.raw(uData.getHostName()), |
| | | tfHostName = UIFactory.makeJTextField( |
| | | Message.raw(UserData.getDefaultHostName()), |
| | | INFO_UNINSTALL_LOGIN_HOST_NAME_TOOLTIP.get(), |
| | | UIFactory.HOST_FIELD_SIZE, UIFactory.TextStyle.TEXTFIELD); |
| | | p2.add(tfHostName, gbc); |
| | |
| | | { |
| | | ControlPanelInfo info = ControlPanelInfo.getInstance(); |
| | | info.setTrustManager(getTrustManager()); |
| | | info.setConnectTimeout(timeout); |
| | | info.regenerateDescriptor(); |
| | | ConfigFromFile conf = new ConfigFromFile(); |
| | | conf.readConfiguration(); |
| | |
| | | { |
| | | LoginDialog dlg = new LoginDialog( |
| | | org.opends.guitools.controlpanel.util.Utilities.createFrame(), |
| | | new ApplicationTrustManager(null)); |
| | | new ApplicationTrustManager(null), |
| | | 5000); |
| | | dlg.pack(); |
| | | dlg.setVisible(true); |
| | | } catch (Exception ex) |
| | |
| | | Error code starting Windows Service: %d |
| | | INFO_DESCRIPTION_DBTEST_STATS_ONLY_1710=Do not display the JE data, \ |
| | | just statistics |
| | | INFO_TIMEOUT_PLACEHOLDER_1711={timeout} |
| | | INFO_DESCRIPTION_CONNECTION_TIMEOUT_1712=Maximum length of time (in \ |
| | | milliseconds) that can be taken to establish a connection |
| | |
| | | * connection. |
| | | * @param dn the dn to be used to authenticate. |
| | | * @param pwd the pwd to be used to authenticate. |
| | | * @param timeout the timeout to establish the connection in milliseconds. |
| | | * Use {@code 0} to express no timeout. |
| | | * @param cnx the ordered list of preferred connections to connect to the |
| | | * server. |
| | | * @return the InitialLdapContext to the remote server. |
| | |
| | | */ |
| | | protected InitialLdapContext getRemoteConnection(ServerDescriptor server, |
| | | String dn, String pwd, ApplicationTrustManager trustManager, |
| | | int timeout, |
| | | LinkedHashSet<PreferredConnection> cnx) |
| | | throws ApplicationException |
| | | { |
| | |
| | | filter.setSearchMonitoringInformation(false); |
| | | filter.setSearchBaseDNInformation(false); |
| | | ServerLoader loader = new ServerLoader(adsProperties, dn, pwd, |
| | | trustManager, cnx, filter); |
| | | trustManager, timeout, cnx, filter); |
| | | |
| | | InitialLdapContext ctx = null; |
| | | try |
| | |
| | | |
| | | import org.opends.admin.ads.ServerDescriptor; |
| | | import org.opends.admin.ads.SuffixDescriptor; |
| | | import org.opends.admin.ads.util.ConnectionUtils; |
| | | import org.opends.quicksetup.installer.AuthenticationData; |
| | | import org.opends.quicksetup.installer.DataReplicationOptions; |
| | | import org.opends.quicksetup.installer.NewSuffixOptions; |
| | |
| | | |
| | | private static String defaultHostName; |
| | | |
| | | private int connectTimeout = ConnectionUtils.getDefaultLDAPTimeout(); |
| | | |
| | | /** |
| | | * The script name to be used to get and set the java arguments for the |
| | | * server runtime. |
| | |
| | | "upgrade", "verify-index", "dbtest" |
| | | }; |
| | | } |
| | | |
| | | /** |
| | | * Sets the timeout to be used to establish a connection. |
| | | * @param connectTimeout the timeout to be used to establish a connection. |
| | | */ |
| | | public void setConnectTimeout(int connectTimeout) |
| | | { |
| | | this.connectTimeout = connectTimeout; |
| | | } |
| | | |
| | | /** |
| | | * Returns the timeout to be used to connect in milliseconds. |
| | | * @return the timeout to be used to connect in milliseconds. Returns |
| | | * {@code 0} if there is no timeout. |
| | | */ |
| | | public int getConnectTimeout() |
| | | { |
| | | return connectTimeout; |
| | | } |
| | | } |
| | |
| | | public UserData createUserData() { |
| | | UserData ud = new UserData(); |
| | | ud.setServerLocation(getDefaultServerLocation()); |
| | | initializeUserDataWithUserArguments(ud, getUserArguments()); |
| | | return ud; |
| | | } |
| | | |
| | | private void initializeUserDataWithUserArguments(UserData ud, |
| | | String[] userArguments) |
| | | { |
| | | for (int i=0; i<userArguments.length; i++) |
| | | { |
| | | if (userArguments[i].equalsIgnoreCase("--connectTimeout")) |
| | | { |
| | | if (i < userArguments.length - 1) |
| | | { |
| | | String sTimeout = userArguments[i+1]; |
| | | try |
| | | { |
| | | ud.setConnectTimeout(new Integer(sTimeout)); |
| | | } |
| | | catch (Throwable t) |
| | | { |
| | | LOG.log(Level.WARNING, "Error getting connect timeout: "+t, t); |
| | | } |
| | | } |
| | | break; |
| | | } |
| | | } |
| | | } |
| | | |
| | | /** |
| | | * {@inheritDoc} |
| | | */ |
| | |
| | | ApplicationTrustManager trustManager = getTrustManager(); |
| | | trustManager.setHost(auth.getHostName()); |
| | | ctx = createLdapsContext(ldapUrl, dn, pwd, |
| | | getDefaultLDAPTimeout(), null, trustManager); |
| | | getConnectTimeout(), null, trustManager); |
| | | } |
| | | else |
| | | { |
| | | ctx = createLdapContext(ldapUrl, dn, pwd, |
| | | getDefaultLDAPTimeout(), null); |
| | | getConnectTimeout(), null); |
| | | } |
| | | |
| | | ADSContext adsContext = new ADSContext(ctx); |
| | |
| | | ApplicationTrustManager trustManager = getTrustManager(); |
| | | trustManager.setHost(auth.getHostName()); |
| | | remoteCtx = createLdapsContext(ldapUrl, dn, pwd, |
| | | getDefaultLDAPTimeout(), null, trustManager); |
| | | getConnectTimeout(), null, trustManager); |
| | | } |
| | | else |
| | | { |
| | | remoteCtx = createLdapContext(ldapUrl, dn, pwd, |
| | | getDefaultLDAPTimeout(), null); |
| | | getConnectTimeout(), null); |
| | | } |
| | | adsContext = new ADSContext(remoteCtx); // adsContext owns remoteCtx |
| | | |
| | |
| | | try |
| | | { |
| | | ctx = createLdapsContext(ldapUrl, dn, pwd, |
| | | getDefaultLDAPTimeout(), null, trustManager); |
| | | getConnectTimeout(), null, trustManager); |
| | | } |
| | | catch (Throwable t) |
| | | { |
| | |
| | | dn = ADSContext.getAdministratorDN(dn); |
| | | effectiveDn[0] = dn; |
| | | ctx = createLdapsContext(ldapUrl, dn, pwd, |
| | | getDefaultLDAPTimeout(), null, trustManager); |
| | | getConnectTimeout(), null, trustManager); |
| | | } |
| | | else |
| | | { |
| | |
| | | { |
| | | type = SuffixesToReplicateOptions.Type.NEW_SUFFIX_IN_TOPOLOGY; |
| | | } |
| | | lastLoadedCache = new TopologyCache(adsContext, trustManager); |
| | | lastLoadedCache = new TopologyCache(adsContext, trustManager, |
| | | getConnectTimeout()); |
| | | LinkedHashSet<PreferredConnection> cnx = |
| | | new LinkedHashSet<PreferredConnection>(); |
| | | cnx.add(PreferredConnection.getPreferredConnection( |
| | |
| | | String dn = getUserData().getDirectoryManagerDn(); |
| | | String pwd = getUserData().getDirectoryManagerPwd(); |
| | | return createLdapsContext(ldapUrl, dn, pwd, |
| | | getDefaultLDAPTimeout(), null, null); |
| | | getConnectTimeout(), null, null); |
| | | } |
| | | |
| | | /** |
| | |
| | | } |
| | | server.setAdsProperties(adsProperties); |
| | | } |
| | | return getRemoteConnection(server, auth.getDn(), auth.getPwd(), |
| | | trustManager, cnx); |
| | | return getRemoteConnection(server, auth.getDn(), auth.getPwd(), |
| | | trustManager, getConnectTimeout(), cnx); |
| | | } |
| | | |
| | | /** |
| | |
| | | lastImportProgress = parsedMessage; |
| | | } |
| | | } |
| | | |
| | | /** |
| | | * Returns the timeout to be used to connect in milliseconds. |
| | | * @return the timeout to be used to connect in milliseconds. Returns |
| | | * {@code 0} if there is no timeout. |
| | | */ |
| | | protected int getConnectTimeout() |
| | | { |
| | | return getUserData().getConnectTimeout(); |
| | | } |
| | | } |
| | | |
| | | /** |
| | |
| | | writer.close(); |
| | | |
| | | String destinationFile; |
| | | String libDir = Utils.getPath(Utils. |
| | | getInstancePathFromInstallPath(installPath), |
| | | String libDir = Utils.getPath(installPath, |
| | | Installation.LIBRARIES_PATH_RELATIVE); |
| | | if (Utils.isWindows()) |
| | | { |
| | |
| | | /** The QuickSetupDialog in control. */ |
| | | private QuickSetupDialog qs; |
| | | |
| | | private String[] args = {}; |
| | | |
| | | /** |
| | | * Constructs an instance of an application. Subclasses |
| | | * of this application must have a default constructor. |
| | |
| | | public void setQuickSetupDialog(QuickSetupDialog dialog) { |
| | | this.qs = dialog; |
| | | } |
| | | |
| | | /** |
| | | * Sets the arguments passed in the command-line to launch the application. |
| | | * @param args the arguments passed in the command-line to launch the |
| | | * application. |
| | | */ |
| | | public void setUserArguments(String[] args) |
| | | { |
| | | this.args = args; |
| | | } |
| | | |
| | | /** |
| | | * Returns the arguments passed in the command-line to launch the application. |
| | | * @return the arguments passed in the command-line to launch the application. |
| | | */ |
| | | public String[] getUserArguments() |
| | | { |
| | | return args; |
| | | } |
| | | } |
| | |
| | | application = Application.create(); |
| | | application.setProgressMessageFormatter(formatter); |
| | | application.setCurrentInstallStatus(installStatus); |
| | | |
| | | if (args != null) |
| | | { |
| | | application.setUserArguments(args); |
| | | } |
| | | else |
| | | { |
| | | application.setUserArguments(new String[]{}); |
| | | } |
| | | try |
| | | { |
| | | initLookAndFeel(); |
| | |
| | | * CDDL HEADER END |
| | | * |
| | | * |
| | | * Copyright 2008-2009 Sun Microsystems, Inc. |
| | | * Copyright 2008-2010 Sun Microsystems, Inc. |
| | | */ |
| | | |
| | | package org.opends.quicksetup.util; |
| | |
| | | { |
| | | ctx = Utils.createLdapsContext( |
| | | ldapUrl, |
| | | userDn, userPw, ConnectionUtils.getDefaultLDAPTimeout(), |
| | | userDn, userPw, application.getUserData().getConnectTimeout(), |
| | | null, null); |
| | | connected = true; |
| | | } |
| | |
| | | * @param ldapUrl the ldap URL of the server. |
| | | * @param dn the dn to be used. |
| | | * @param pwd the password to be used. |
| | | * @param timeout the timeout to establish the connection in milliseconds. |
| | | * Use {@code 0} to express no timeout. |
| | | * @return <CODE>true</CODE> if we can connect and read the configuration and |
| | | * <CODE>false</CODE> otherwise. |
| | | */ |
| | | public static boolean canConnectAsAdministrativeUser(String ldapUrl, |
| | | String dn, String pwd) |
| | | String dn, String pwd, int timeout) |
| | | { |
| | | return ConnectionUtils.canConnectAsAdministrativeUser(ldapUrl, dn, pwd); |
| | | return ConnectionUtils.canConnectAsAdministrativeUser(ldapUrl, dn, pwd, |
| | | timeout); |
| | | } |
| | | |
| | | /** |
| | |
| | | return msg; |
| | | } |
| | | |
| | | /** |
| | | * Returns the default LDAP timeout in milliseconds when we try to connect to |
| | | * a server. |
| | | * @return the default LDAP timeout in milliseconds when we try to connect to |
| | | * a server. |
| | | */ |
| | | public static int getDefaultLDAPTimeout() |
| | | { |
| | | return ConnectionUtils.getDefaultLDAPTimeout(); |
| | | } |
| | | |
| | | |
| | | /** |
| | | * Returns the path of the installation of the directory server. Note that |
| | |
| | | |
| | | import org.opends.admin.ads.util.ApplicationKeyManager; |
| | | import org.opends.admin.ads.util.ApplicationTrustManager; |
| | | import org.opends.admin.ads.util.ConnectionUtils; |
| | | import org.opends.quicksetup.Constants; |
| | | import org.opends.server.admin.AdministrationConnector; |
| | | import org.opends.server.admin.server.ServerManagementContext; |
| | |
| | | public StringArgument saslOptionArg = null; |
| | | |
| | | /** |
| | | * Argument to specify the connection timeout. |
| | | */ |
| | | public IntegerArgument connectTimeoutArg = null; |
| | | |
| | | /** |
| | | * Private container for global arguments. |
| | | */ |
| | | private LinkedHashSet<Argument> argList = null; |
| | |
| | | portArg = new IntegerArgument("port", OPTION_SHORT_PORT, OPTION_LONG_PORT, |
| | | false, false, true, INFO_PORT_PLACEHOLDER.get(), |
| | | AdministrationConnector.DEFAULT_ADMINISTRATION_CONNECTOR_PORT, null, |
| | | true, 1, true, 65535, |
| | | portDescription); |
| | | portArg.setPropertyName(OPTION_LONG_PORT); |
| | | argList.add(portArg); |
| | |
| | | certNicknameArg.setPropertyName(OPTION_LONG_CERT_NICKNAME); |
| | | argList.add(certNicknameArg); |
| | | |
| | | int defaultTimeout = ConnectionUtils.getDefaultLDAPTimeout(); |
| | | connectTimeoutArg = new IntegerArgument(OPTION_LONG_CONNECT_TIMEOUT, |
| | | null, OPTION_LONG_CONNECT_TIMEOUT, |
| | | false, false, true, INFO_TIMEOUT_PLACEHOLDER.get(), |
| | | defaultTimeout, null, |
| | | true, 0, false, Integer.MAX_VALUE, |
| | | INFO_DESCRIPTION_CONNECTION_TIMEOUT.get()); |
| | | connectTimeoutArg.setPropertyName(OPTION_LONG_CONNECT_TIMEOUT); |
| | | argList.add(connectTimeoutArg); |
| | | |
| | | return argList; |
| | | } |
| | | |
| | |
| | | * CDDL HEADER END |
| | | * |
| | | * |
| | | * Copyright 2007-2009 Sun Microsystems, Inc. |
| | | * Copyright 2007-2010 Sun Microsystems, Inc. |
| | | */ |
| | | |
| | | package org.opends.server.admin.client.cli; |
| | |
| | | { |
| | | return secureArgsList.getKeyManager() ; |
| | | } |
| | | |
| | | /** |
| | | * Returns the timeout to be used to connect in milliseconds. The method |
| | | * must be called after parsing the arguments. |
| | | * @return the timeout to be used to connect in milliseconds. Returns |
| | | * {@code 0} if there is no timeout. |
| | | * @throw {@code IllegalStateException} if the method is called before |
| | | * parsing the arguments. |
| | | */ |
| | | public int getConnectTimeout() |
| | | { |
| | | try |
| | | { |
| | | return secureArgsList.connectTimeoutArg.getIntValue(); |
| | | } |
| | | catch (ArgumentException ae) |
| | | { |
| | | throw new IllegalStateException("Argument parser is not parsed: "+ae, ae); |
| | | } |
| | | } |
| | | } |
| | |
| | | uData.setConfigurationFile(argParser.configFileArg.getValue()); |
| | | uData.setQuiet(isQuiet()); |
| | | uData.setVerbose(isVerbose()); |
| | | uData.setConnectTimeout(getConnectTimeout()); |
| | | // Check the validity of the directory manager DNs |
| | | String dmDN = argParser.directoryManagerDNArg.getValue(); |
| | | |
| | |
| | | uData.setConfigurationFile(argParser.configFileArg.getValue()); |
| | | uData.setQuiet(isQuiet()); |
| | | uData.setVerbose(isVerbose()); |
| | | uData.setConnectTimeout(getConnectTimeout()); |
| | | |
| | | promptIfRequiredForDirectoryManager(uData); |
| | | promptIfRequiredForPortData(uData); |
| | |
| | | } |
| | | return hostName; |
| | | } |
| | | |
| | | /** |
| | | * Returns the timeout to be used to connect in milliseconds. The method |
| | | * must be called after parsing the arguments. |
| | | * @return the timeout to be used to connect in milliseconds. Returns |
| | | * {@code 0} if there is no timeout. |
| | | */ |
| | | private int getConnectTimeout() |
| | | { |
| | | return argParser.getConnectTimeout(); |
| | | } |
| | | } |
| | |
| | | import java.util.logging.Level; |
| | | import java.util.logging.Logger; |
| | | |
| | | import org.opends.admin.ads.util.ConnectionUtils; |
| | | import org.opends.messages.Message; |
| | | import org.opends.quicksetup.Constants; |
| | | import org.opends.quicksetup.Installation; |
| | |
| | | StringArgument keyStorePasswordArg; |
| | | StringArgument certNicknameArg; |
| | | StringArgument progNameArg; |
| | | IntegerArgument connectTimeoutArg = null; |
| | | |
| | | private static final Logger LOG = Logger.getLogger( |
| | | InstallDSArgumentParser.class.getName()); |
| | |
| | | INFO_INSTALLDS_DESCRIPTION_CERT_NICKNAME.get()); |
| | | addDefaultArgument(certNicknameArg); |
| | | |
| | | int defaultTimeout = ConnectionUtils.getDefaultLDAPTimeout(); |
| | | connectTimeoutArg = new IntegerArgument(OPTION_LONG_CONNECT_TIMEOUT, |
| | | null, OPTION_LONG_CONNECT_TIMEOUT, |
| | | false, false, true, INFO_TIMEOUT_PLACEHOLDER.get(), |
| | | defaultTimeout, null, |
| | | true, 1, true, 65535, |
| | | INFO_DESCRIPTION_CONNECTION_TIMEOUT.get()); |
| | | connectTimeoutArg.setPropertyName(OPTION_LONG_CONNECT_TIMEOUT); |
| | | connectTimeoutArg.setHidden(true); |
| | | addArgument(connectTimeoutArg); |
| | | |
| | | showUsageArg = new BooleanArgument( |
| | | OPTION_LONG_HELP.toLowerCase(), OPTION_SHORT_HELP, |
| | | OPTION_LONG_HELP, |
| | |
| | | String configDir = Utils.getPath(root, Installation.CONFIG_PATH_RELATIVE); |
| | | return Utils.getPath(configDir, Installation.CURRENT_CONFIG_FILE_NAME); |
| | | } |
| | | |
| | | /** |
| | | * Returns the timeout to be used to connect in milliseconds. The method |
| | | * must be called after parsing the arguments. |
| | | * @return the timeout to be used to connect in milliseconds. Returns |
| | | * {@code 0} if there is no timeout. |
| | | * @throw {@code IllegalStateException} if the method is called before |
| | | * parsing the arguments. |
| | | */ |
| | | public int getConnectTimeout() |
| | | { |
| | | try |
| | | { |
| | | return connectTimeoutArg.getIntValue(); |
| | | } |
| | | catch (ArgumentException ae) |
| | | { |
| | | throw new IllegalStateException("Argument parser is not parsed: "+ae, ae); |
| | | } |
| | | } |
| | | } |
| | |
| | | * CDDL HEADER END |
| | | * |
| | | * |
| | | * Copyright 2006-2009 Sun Microsystems, Inc. |
| | | * Copyright 2006-2010 Sun Microsystems, Inc. |
| | | */ |
| | | package org.opends.server.tools; |
| | | import org.opends.admin.ads.util.ConnectionUtils; |
| | | import org.opends.messages.Message; |
| | | |
| | | import java.io.BufferedReader; |
| | |
| | | import static org.opends.server.util.ServerConstants.*; |
| | | import static org.opends.server.util.StaticUtils.*; |
| | | import static org.opends.server.tools.ToolConstants.*; |
| | | |
| | | import org.opends.server.controls.LDAPAssertionRequestControl; |
| | | |
| | | |
| | |
| | | StringArgument saslOptions = null; |
| | | StringArgument trustStorePath = null; |
| | | StringArgument trustStorePassword = null; |
| | | IntegerArgument connectTimeout = null; |
| | | BooleanArgument scriptFriendlyArgument = null; |
| | | StringArgument propertiesFileArgument = null; |
| | | BooleanArgument noPropertiesFileArgument = null; |
| | |
| | | version.setPropertyName(OPTION_LONG_PROTOCOL_VERSION); |
| | | argParser.addArgument(version); |
| | | |
| | | int defaultTimeout = ConnectionUtils.getDefaultLDAPTimeout(); |
| | | connectTimeout = new IntegerArgument(OPTION_LONG_CONNECT_TIMEOUT, |
| | | null, OPTION_LONG_CONNECT_TIMEOUT, |
| | | false, false, true, INFO_TIMEOUT_PLACEHOLDER.get(), |
| | | defaultTimeout, null, |
| | | true, 0, false, Integer.MAX_VALUE, |
| | | INFO_DESCRIPTION_CONNECTION_TIMEOUT.get()); |
| | | connectTimeout.setPropertyName(OPTION_LONG_CONNECT_TIMEOUT); |
| | | argParser.addArgument(connectTimeout); |
| | | |
| | | encodingStr = new StringArgument("encoding", 'i', "encoding", |
| | | false, false, |
| | | true, INFO_ENCODING_PLACEHOLDER.get(), |
| | |
| | | AtomicInteger nextMessageID = new AtomicInteger(1); |
| | | connection = new LDAPConnection(hostNameValue, portNumber, |
| | | connectionOptions, out, err); |
| | | connection.connectToHost(bindDNValue, bindPasswordValue, nextMessageID); |
| | | |
| | | int timeout = connectTimeout.getIntValue(); |
| | | connection.connectToHost(bindDNValue, bindPasswordValue, nextMessageID, |
| | | timeout); |
| | | |
| | | |
| | | ldapCompare = new LDAPCompare(nextMessageID, out, err); |
| | |
| | | * CDDL HEADER END |
| | | * |
| | | * |
| | | * Copyright 2009 Sun Microsystems, Inc. |
| | | * Copyright 2009-2010 Sun Microsystems, Inc. |
| | | */ |
| | | package org.opends.server.tools; |
| | | import org.opends.messages.Message; |
| | |
| | | AtomicInteger nextMessageID) |
| | | throws LDAPConnectionException |
| | | { |
| | | connectToHost(bindDN, bindPassword, nextMessageID, 0); |
| | | } |
| | | |
| | | /** |
| | | * Connects to the directory server instance running on specified hostname |
| | | * and port number. |
| | | * |
| | | * @param bindDN The DN to bind with. |
| | | * @param bindPassword The password to bind with. |
| | | * @param nextMessageID The message ID counter that should be used for |
| | | * operations performed while establishing the |
| | | * connection. |
| | | * @param timeout The timeout to connect to the specified host. The |
| | | * timeout is the timeout at the socket level in |
| | | * milliseconds. If the timeout value is {@code 0}, |
| | | * no timeout is used. |
| | | * |
| | | * @throws LDAPConnectionException If a problem occurs while attempting to |
| | | * establish the connection to the server. |
| | | */ |
| | | public void connectToHost(String bindDN, String bindPassword, |
| | | AtomicInteger nextMessageID, int timeout) |
| | | throws LDAPConnectionException |
| | | { |
| | | Socket socket; |
| | | Socket startTLSSocket = null; |
| | | int resultCode; |
| | |
| | | { |
| | | socket.setSoLinger(true, 1); |
| | | socket.setReuseAddress(true); |
| | | if (timeout > 0) |
| | | { |
| | | socket.setSoTimeout(timeout); |
| | | } |
| | | } catch(IOException e) |
| | | { |
| | | if (debugEnabled()) |
| | |
| | | * CDDL HEADER END |
| | | * |
| | | * |
| | | * Copyright 2006-2009 Sun Microsystems, Inc. |
| | | * Copyright 2006-2010 Sun Microsystems, Inc. |
| | | */ |
| | | package org.opends.server.tools; |
| | | import org.opends.admin.ads.util.ConnectionUtils; |
| | | import org.opends.messages.Message; |
| | | |
| | | import java.io.BufferedReader; |
| | |
| | | StringArgument saslOptions = null; |
| | | StringArgument trustStorePath = null; |
| | | StringArgument trustStorePassword = null; |
| | | IntegerArgument connectTimeout = null; |
| | | StringArgument propertiesFileArgument = null; |
| | | BooleanArgument noPropertiesFileArgument = null; |
| | | |
| | |
| | | version.setPropertyName(OPTION_LONG_PROTOCOL_VERSION); |
| | | argParser.addArgument(version); |
| | | |
| | | int defaultTimeout = ConnectionUtils.getDefaultLDAPTimeout(); |
| | | connectTimeout = new IntegerArgument(OPTION_LONG_CONNECT_TIMEOUT, |
| | | null, OPTION_LONG_CONNECT_TIMEOUT, |
| | | false, false, true, INFO_TIMEOUT_PLACEHOLDER.get(), |
| | | defaultTimeout, null, |
| | | true, 0, false, Integer.MAX_VALUE, |
| | | INFO_DESCRIPTION_CONNECTION_TIMEOUT.get()); |
| | | connectTimeout.setPropertyName(OPTION_LONG_CONNECT_TIMEOUT); |
| | | argParser.addArgument(connectTimeout); |
| | | |
| | | encodingStr = new StringArgument("encoding", 'i', |
| | | OPTION_LONG_ENCODING, false, |
| | | false, true, |
| | |
| | | AtomicInteger nextMessageID = new AtomicInteger(1); |
| | | connection = new LDAPConnection(hostNameValue, portNumber, |
| | | connectionOptions, out, err); |
| | | connection.connectToHost(bindDNValue, bindPasswordValue, nextMessageID); |
| | | int timeout = connectTimeout.getIntValue(); |
| | | connection.connectToHost(bindDNValue, bindPasswordValue, nextMessageID, |
| | | timeout); |
| | | |
| | | ldapDelete = new LDAPDelete(nextMessageID, out, err); |
| | | if(fileNameValue == null && dnStrings.isEmpty()) |
| | |
| | | * CDDL HEADER END |
| | | * |
| | | * |
| | | * Copyright 2006-2009 Sun Microsystems, Inc. |
| | | * Copyright 2006-2010 Sun Microsystems, Inc. |
| | | */ |
| | | package org.opends.server.tools; |
| | | import org.opends.admin.ads.util.ConnectionUtils; |
| | | import org.opends.messages.Message; |
| | | |
| | | import java.io.FileInputStream; |
| | |
| | | import static org.opends.server.util.ServerConstants.*; |
| | | import static org.opends.server.util.StaticUtils.*; |
| | | import static org.opends.server.tools.ToolConstants.*; |
| | | |
| | | import org.opends.server.controls.*; |
| | | import org.opends.server.plugins.ChangeNumberControlPlugin; |
| | | |
| | |
| | | FileBasedArgument bindPasswordFile = null; |
| | | FileBasedArgument keyStorePasswordFile = null; |
| | | FileBasedArgument trustStorePasswordFile = null; |
| | | IntegerArgument connectTimeout = null; |
| | | IntegerArgument port = null; |
| | | IntegerArgument version = null; |
| | | StringArgument assertionFilter = null; |
| | |
| | | version.setPropertyName(OPTION_LONG_PROTOCOL_VERSION); |
| | | argParser.addArgument(version); |
| | | |
| | | int defaultTimeout = ConnectionUtils.getDefaultLDAPTimeout(); |
| | | connectTimeout = new IntegerArgument(OPTION_LONG_CONNECT_TIMEOUT, |
| | | null, OPTION_LONG_CONNECT_TIMEOUT, |
| | | false, false, true, INFO_TIMEOUT_PLACEHOLDER.get(), |
| | | defaultTimeout, null, |
| | | true, 0, false, Integer.MAX_VALUE, |
| | | INFO_DESCRIPTION_CONNECTION_TIMEOUT.get()); |
| | | connectTimeout.setPropertyName(OPTION_LONG_CONNECT_TIMEOUT); |
| | | argParser.addArgument(connectTimeout); |
| | | |
| | | encodingStr = new StringArgument("encoding", 'i', "encoding", |
| | | false, false, |
| | | true, INFO_ENCODING_PLACEHOLDER.get(), |
| | |
| | | AtomicInteger nextMessageID = new AtomicInteger(1); |
| | | connection = new LDAPConnection(hostNameValue, portNumber, |
| | | connectionOptions, out, err); |
| | | connection.connectToHost(bindDNValue, bindPasswordValue, nextMessageID); |
| | | int timeout = connectTimeout.getIntValue(); |
| | | connection.connectToHost(bindDNValue, bindPasswordValue, nextMessageID, |
| | | timeout); |
| | | |
| | | ldapModify = new LDAPModify(fileNameValue, nextMessageID, out, err); |
| | | ldapModify.readAndExecute(connection, fileNameValue, modifyOptions); |
| | |
| | | * CDDL HEADER END |
| | | * |
| | | * |
| | | * Copyright 2006-2009 Sun Microsystems, Inc. |
| | | * Copyright 2006-2010 Sun Microsystems, Inc. |
| | | */ |
| | | package org.opends.server.tools; |
| | | import org.opends.admin.ads.util.ConnectionUtils; |
| | | import org.opends.messages.Message; |
| | | |
| | | |
| | |
| | | StringArgument sslKeyStorePIN; |
| | | StringArgument sslTrustStore; |
| | | StringArgument sslTrustStorePIN; |
| | | IntegerArgument connectTimeout; |
| | | StringArgument propertiesFileArgument; |
| | | BooleanArgument noPropertiesFileArgument; |
| | | |
| | |
| | | controlStr.setPropertyName("control"); |
| | | argParser.addArgument(controlStr); |
| | | |
| | | int defaultTimeout = ConnectionUtils.getDefaultLDAPTimeout(); |
| | | connectTimeout = new IntegerArgument(OPTION_LONG_CONNECT_TIMEOUT, |
| | | null, OPTION_LONG_CONNECT_TIMEOUT, |
| | | false, false, true, INFO_TIMEOUT_PLACEHOLDER.get(), |
| | | defaultTimeout, null, |
| | | true, 0, false, Integer.MAX_VALUE, |
| | | INFO_DESCRIPTION_CONNECTION_TIMEOUT.get()); |
| | | connectTimeout.setPropertyName(OPTION_LONG_CONNECT_TIMEOUT); |
| | | argParser.addArgument(connectTimeout); |
| | | |
| | | |
| | | showUsage = new BooleanArgument("help", OPTION_SHORT_HELP, |
| | | OPTION_LONG_HELP, |
| | |
| | | |
| | | try |
| | | { |
| | | connection.connectToHost(dn, pw, nextMessageID); |
| | | int timeout = connectTimeout.getIntValue(); |
| | | connection.connectToHost(dn, pw, nextMessageID, timeout); |
| | | } |
| | | catch (LDAPConnectionException lce) |
| | | { |
| | |
| | | err.println(wrapText(message, MAX_LINE_WIDTH)); |
| | | return lce.getResultCode(); |
| | | } |
| | | catch (ArgumentException e) |
| | | { |
| | | // This should not occur because the arguments are already parsed. |
| | | // It is a bug |
| | | e.printStackTrace(); |
| | | throw new IllegalStateException("Unexpected error: "+e, e); |
| | | } |
| | | |
| | | LDAPReader reader = connection.getLDAPReader(); |
| | | LDAPWriter writer = connection.getLDAPWriter(); |
| | |
| | | * CDDL HEADER END |
| | | * |
| | | * |
| | | * Copyright 2006-2009 Sun Microsystems, Inc. |
| | | * Copyright 2006-2010 Sun Microsystems, Inc. |
| | | */ |
| | | package org.opends.server.tools; |
| | | import org.opends.admin.ads.util.ConnectionUtils; |
| | | import org.opends.messages.Message; |
| | | |
| | | import java.io.BufferedReader; |
| | |
| | | StringArgument sortOrder = null; |
| | | StringArgument trustStorePath = null; |
| | | StringArgument trustStorePassword = null; |
| | | IntegerArgument connectTimeout = null; |
| | | StringArgument vlvDescriptor = null; |
| | | StringArgument effectiveRightsUser = null; |
| | | StringArgument effectiveRightsAttrs = null; |
| | |
| | | version.setPropertyName(OPTION_LONG_PROTOCOL_VERSION); |
| | | argParser.addArgument(version); |
| | | |
| | | int defaultTimeout = ConnectionUtils.getDefaultLDAPTimeout(); |
| | | connectTimeout = new IntegerArgument(OPTION_LONG_CONNECT_TIMEOUT, |
| | | null, OPTION_LONG_CONNECT_TIMEOUT, |
| | | false, false, true, INFO_TIMEOUT_PLACEHOLDER.get(), |
| | | defaultTimeout, null, |
| | | true, 0, false, Integer.MAX_VALUE, |
| | | INFO_DESCRIPTION_CONNECTION_TIMEOUT.get()); |
| | | connectTimeout.setPropertyName(OPTION_LONG_CONNECT_TIMEOUT); |
| | | argParser.addArgument(connectTimeout); |
| | | |
| | | encodingStr = new StringArgument("encoding", 'i', "encoding", false, |
| | | false, true, |
| | | INFO_ENCODING_PLACEHOLDER.get(), null, |
| | |
| | | AtomicInteger nextMessageID = new AtomicInteger(1); |
| | | connection = new LDAPConnection(hostNameValue, portNumber, |
| | | connectionOptions, out, err); |
| | | connection.connectToHost(bindDNValue, bindPasswordValue, nextMessageID); |
| | | int timeout = connectTimeout.getIntValue(); |
| | | connection.connectToHost(bindDNValue, bindPasswordValue, nextMessageID, |
| | | timeout); |
| | | |
| | | |
| | | int matchingEntries = 0; |
| | | if (simplePageSize.isPresent()) |
| | |
| | | * CDDL HEADER END |
| | | * |
| | | * |
| | | * Copyright 2006-2009 Sun Microsystems, Inc. |
| | | * Copyright 2006-2010 Sun Microsystems, Inc. |
| | | */ |
| | | package org.opends.server.tools; |
| | | |
| | |
| | | "ldapVersion"; |
| | | |
| | | /** |
| | | * The value for the long option connect timeout attribute. |
| | | */ |
| | | public static final String OPTION_LONG_CONNECT_TIMEOUT = |
| | | "connectTimeout"; |
| | | |
| | | /** |
| | | * The value for the long option version. |
| | | */ |
| | | public static final char OPTION_SHORT_PRODUCT_VERSION = 'V'; |
| | |
| | | * CDDL HEADER END |
| | | * |
| | | * |
| | | * Copyright 2007-2009 Sun Microsystems, Inc. |
| | | * Copyright 2007-2010 Sun Microsystems, Inc. |
| | | */ |
| | | package org.opends.server.tools.dsconfig; |
| | | |
| | |
| | | try |
| | | { |
| | | ctx = ConnectionUtils.createLdapsContext(ldapsUrl, bindDN, |
| | | bindPassword, ConnectionUtils.getDefaultLDAPTimeout(), null, |
| | | bindPassword, ci.getConnectTimeout(), null, |
| | | trustManager, keyManager); |
| | | ctx.reconnect(null); |
| | | conn = JNDIDirContextAdaptor.adapt(ctx); |
| | |
| | | * CDDL HEADER END |
| | | * |
| | | * |
| | | * Copyright 2007-2009 Sun Microsystems, Inc. |
| | | * Copyright 2007-2010 Sun Microsystems, Inc. |
| | | */ |
| | | |
| | | package org.opends.server.tools.dsreplication; |
| | |
| | | InitialLdapContext ctx = createAdministrativeContext( |
| | | uData.getHostName1(), uData.getPort1(), useSSL, |
| | | useStartTLS, ADSContext.getAdministratorDN(adminUid), |
| | | adminPwd, getTrustManager()); |
| | | adminPwd, getConnectTimeout(), getTrustManager()); |
| | | uData.setBindDn1(ADSContext.getAdministratorDN(adminUid)); |
| | | uData.setPwd1(adminPwd); |
| | | ctx.close(); |
| | |
| | | InitialLdapContext ctx = createAdministrativeContext( |
| | | uData.getHostName2(), uData.getPort2(), useSSL, |
| | | useStartTLS, ADSContext.getAdministratorDN(adminUid), |
| | | adminPwd, getTrustManager()); |
| | | adminPwd, getConnectTimeout(), getTrustManager()); |
| | | uData.setBindDn2(ADSContext.getAdministratorDN(adminUid)); |
| | | uData.setPwd2(adminPwd); |
| | | ctx.close(); |
| | |
| | | // LDAPConnectionConsoleInteraction object might have changed. |
| | | |
| | | TopologyCache cache = new TopologyCache(adsContext, |
| | | getTrustManager()); |
| | | getTrustManager(), getConnectTimeout()); |
| | | cache.getFilter().setSearchMonitoringInformation(false); |
| | | cache.getFilter().setSearchBaseDNInformation(false); |
| | | cache.setPreferredConnections( |
| | |
| | | { |
| | | ctx[0] = createAdministrativeContext(host, port, isSSL, |
| | | isStartTLS, ADSContext.getAdministratorDN(adminUid), |
| | | adminPwd, getTrustManager()); |
| | | adminPwd, getConnectTimeout(), getTrustManager()); |
| | | adsContext = new ADSContext(ctx[0]); |
| | | cache = new TopologyCache(adsContext, getTrustManager()); |
| | | cache = new TopologyCache(adsContext, getTrustManager(), |
| | | getConnectTimeout()); |
| | | cache.getFilter().setSearchMonitoringInformation(false); |
| | | cache.getFilter().setSearchBaseDNInformation(false); |
| | | cache.setPreferredConnections( |
| | |
| | | { |
| | | ctx1 = createAdministrativeContext(host1, port1, useSSL, |
| | | useStartTLS, uData.getBindDn1(), uData.getPwd1(), |
| | | getTrustManager()); |
| | | getConnectTimeout(), getTrustManager()); |
| | | } |
| | | catch (NamingException ne) |
| | | { |
| | |
| | | { |
| | | ctx2 = createAdministrativeContext(host2, port2, useSSL, |
| | | useStartTLS, uData.getBindDn2(), uData.getPwd2(), |
| | | getTrustManager()); |
| | | getConnectTimeout(), getTrustManager()); |
| | | } |
| | | catch (NamingException ne) |
| | | { |
| | |
| | | try |
| | | { |
| | | ctx = createAdministrativeContext(uData.getHostName(), uData.getPort(), |
| | | useSSL, useStartTLS, bindDn, uData.getAdminPwd(), |
| | | useSSL, useStartTLS, bindDn, uData.getAdminPwd(), getConnectTimeout(), |
| | | getTrustManager()); |
| | | } |
| | | catch (NamingException ne) |
| | |
| | | ctx = createAdministrativeContext(uData.getHostName(), uData.getPort(), |
| | | useSSL, useStartTLS, |
| | | ADSContext.getAdministratorDN(uData.getAdminUid()), |
| | | uData.getAdminPwd(), getTrustManager()); |
| | | uData.getAdminPwd(), getConnectTimeout(), getTrustManager()); |
| | | } |
| | | catch (NamingException ne) |
| | | { |
| | |
| | | uData.getPortSource(), useSSL, |
| | | useStartTLS, |
| | | ADSContext.getAdministratorDN(uData.getAdminUid()), |
| | | uData.getAdminPwd(), getTrustManager()); |
| | | uData.getAdminPwd(), getConnectTimeout(), getTrustManager()); |
| | | } |
| | | catch (NamingException ne) |
| | | { |
| | |
| | | uData.getPortDestination(), useSSL, |
| | | useStartTLS, |
| | | ADSContext.getAdministratorDN(uData.getAdminUid()), |
| | | uData.getAdminPwd(), getTrustManager()); |
| | | uData.getAdminPwd(), getConnectTimeout(), getTrustManager()); |
| | | } |
| | | catch (NamingException ne) |
| | | { |
| | |
| | | ctx = createAdministrativeContext(uData.getHostName(), uData.getPort(), |
| | | useSSL, useStartTLS, |
| | | ADSContext.getAdministratorDN(uData.getAdminUid()), |
| | | uData.getAdminPwd(), getTrustManager()); |
| | | uData.getAdminPwd(), getConnectTimeout(), getTrustManager()); |
| | | } |
| | | catch (NamingException ne) |
| | | { |
| | |
| | | ctx = createAdministrativeContext(uData.getHostName(), uData.getPort(), |
| | | useSSL, useStartTLS, |
| | | ADSContext.getAdministratorDN(uData.getAdminUid()), |
| | | uData.getAdminPwd(), getTrustManager()); |
| | | uData.getAdminPwd(), getConnectTimeout(), getTrustManager()); |
| | | } |
| | | catch (NamingException ne) |
| | | { |
| | |
| | | ctx = createAdministrativeContext(uData.getHostName(), uData.getPort(), |
| | | useSSL, useStartTLS, |
| | | ADSContext.getAdministratorDN(uData.getAdminUid()), |
| | | uData.getAdminPwd(), getTrustManager()); |
| | | uData.getAdminPwd(), getConnectTimeout(), getTrustManager()); |
| | | } |
| | | catch (NamingException ne) |
| | | { |
| | |
| | | cnx.addAll(PreferredConnection.getPreferredConnections(ctx2)); |
| | | if (adsCtx1.hasAdminData()) |
| | | { |
| | | TopologyCache cache = new TopologyCache(adsCtx1, getTrustManager()); |
| | | TopologyCache cache = new TopologyCache(adsCtx1, getTrustManager(), |
| | | getConnectTimeout()); |
| | | cache.setPreferredConnections(cnx); |
| | | cache.getFilter().setSearchMonitoringInformation(false); |
| | | for (String dn : uData.getBaseDNs()) |
| | |
| | | |
| | | if (adsCtx2.hasAdminData()) |
| | | { |
| | | TopologyCache cache = new TopologyCache(adsCtx2, getTrustManager()); |
| | | TopologyCache cache = new TopologyCache(adsCtx2, getTrustManager(), |
| | | getConnectTimeout()); |
| | | cache.setPreferredConnections(cnx); |
| | | cache.getFilter().setSearchMonitoringInformation(false); |
| | | for (String dn : uData.getBaseDNs()) |
| | |
| | | cnx.addAll(PreferredConnection.getPreferredConnections(ctx2)); |
| | | if (adsCtx1.hasAdminData()) |
| | | { |
| | | cache1 = new TopologyCache(adsCtx1, getTrustManager()); |
| | | cache1 = new TopologyCache(adsCtx1, getTrustManager(), |
| | | getConnectTimeout()); |
| | | cache1.setPreferredConnections(cnx); |
| | | cache1.getFilter().setSearchMonitoringInformation(false); |
| | | for (String dn : uData.getBaseDNs()) |
| | |
| | | |
| | | if (adsCtx2.hasAdminData()) |
| | | { |
| | | cache2 = new TopologyCache(adsCtx2, getTrustManager()); |
| | | cache2 = new TopologyCache(adsCtx2, getTrustManager(), |
| | | getConnectTimeout()); |
| | | cache2.setPreferredConnections(cnx); |
| | | cache2.getFilter().setSearchMonitoringInformation(false); |
| | | for (String dn : uData.getBaseDNs()) |
| | |
| | | { |
| | | if (adsCtx.hasAdminData() && tryToUpdateRemote) |
| | | { |
| | | cache = new TopologyCache(adsCtx, getTrustManager()); |
| | | cache = new TopologyCache(adsCtx, getTrustManager(), |
| | | getConnectTimeout()); |
| | | cache.setPreferredConnections( |
| | | PreferredConnection.getPreferredConnections(ctx)); |
| | | cache.getFilter().setSearchMonitoringInformation(false); |
| | |
| | | TopologyCache cache = null; |
| | | try |
| | | { |
| | | cache = new TopologyCache(adsCtx, getTrustManager()); |
| | | cache = new TopologyCache(adsCtx, getTrustManager(), |
| | | getConnectTimeout()); |
| | | cache.setPreferredConnections( |
| | | PreferredConnection.getPreferredConnections(ctx)); |
| | | for (String dn : uData.getBaseDNs()) |
| | |
| | | filter.setSearchMonitoringInformation(false); |
| | | filter.setSearchBaseDNInformation(false); |
| | | ServerLoader loader = new ServerLoader(server.getAdsProperties(), bindDn, |
| | | pwd, getTrustManager(), cnx, filter); |
| | | pwd, getTrustManager(), getConnectTimeout(), cnx, filter); |
| | | InitialLdapContext ctx = null; |
| | | String lastBaseDN = null; |
| | | String hostPort = null; |
| | |
| | | ADSContext adsContext = new ADSContext(ctx1); |
| | | if (adsContext.hasAdminData()) |
| | | { |
| | | cache1 = new TopologyCache(adsContext, getTrustManager()); |
| | | cache1 = new TopologyCache(adsContext, getTrustManager(), |
| | | getConnectTimeout()); |
| | | cache1.getFilter().setSearchMonitoringInformation(false); |
| | | cache1.setPreferredConnections( |
| | | PreferredConnection.getPreferredConnections(ctx1)); |
| | |
| | | ADSContext adsContext = new ADSContext(ctx2); |
| | | if (adsContext.hasAdminData()) |
| | | { |
| | | cache2 = new TopologyCache(adsContext, getTrustManager()); |
| | | cache2 = new TopologyCache(adsContext, getTrustManager(), |
| | | getConnectTimeout()); |
| | | cache2.getFilter().setSearchMonitoringInformation(false); |
| | | cache2.setPreferredConnections( |
| | | PreferredConnection.getPreferredConnections(ctx2)); |
| | |
| | | if (adsCtx1.hasAdminData()) |
| | | { |
| | | TopologyCache cache = new TopologyCache(adsCtx1, |
| | | getTrustManager()); |
| | | getTrustManager(), getConnectTimeout()); |
| | | cache.getFilter().setSearchMonitoringInformation(false); |
| | | for (String dn : uData.getBaseDNs()) |
| | | { |
| | |
| | | if (adsCtx2.hasAdminData()) |
| | | { |
| | | TopologyCache cache = new TopologyCache(adsCtx2, |
| | | getTrustManager()); |
| | | getTrustManager(), getConnectTimeout()); |
| | | cache.getFilter().setSearchMonitoringInformation(false); |
| | | cache.reloadTopology(); |
| | | for (String dn : uData.getBaseDNs()) |
| | |
| | | adsCtx2.getDirContext())); |
| | | // Check that there are no errors. We do not allow to do the merge with |
| | | // errors. |
| | | TopologyCache cache1 = new TopologyCache(adsCtx1, getTrustManager()); |
| | | TopologyCache cache1 = new TopologyCache(adsCtx1, getTrustManager(), |
| | | getConnectTimeout()); |
| | | cache1.setPreferredConnections(cnx); |
| | | cache1.getFilter().setSearchBaseDNInformation(false); |
| | | try |
| | |
| | | ERR_REPLICATION_READING_ADS.get(te.getMessageObject()), |
| | | ERROR_UPDATING_ADS, te); |
| | | } |
| | | TopologyCache cache2 = new TopologyCache(adsCtx2, getTrustManager()); |
| | | TopologyCache cache2 = new TopologyCache(adsCtx2, getTrustManager(), |
| | | getConnectTimeout()); |
| | | cache2.setPreferredConnections(cnx); |
| | | cache2.getFilter().setSearchBaseDNInformation(false); |
| | | try |
| | |
| | | filter.setSearchMonitoringInformation(false); |
| | | filter.setSearchBaseDNInformation(false); |
| | | ServerLoader loader = new ServerLoader(server.getAdsProperties(), |
| | | dn, pwd, getTrustManager(), cache.getPreferredConnections(), |
| | | filter); |
| | | dn, pwd, getTrustManager(), getConnectTimeout(), |
| | | cache.getPreferredConnections(), filter); |
| | | return loader.createContext(); |
| | | } |
| | | |
| | |
| | | } |
| | | return false; |
| | | } |
| | | |
| | | /** |
| | | * Returns the timeout to be used to connect in milliseconds. The method |
| | | * must be called after parsing the arguments. |
| | | * @return the timeout to be used to connect in milliseconds. Returns |
| | | * {@code 0} if there is no timeout. |
| | | */ |
| | | private int getConnectTimeout() |
| | | { |
| | | return argParser.getConnectTimeout(); |
| | | } |
| | | } |
| | | |
| | | |
| | |
| | | } else { |
| | | ControlPanelInfo controlInfo = ControlPanelInfo.getInstance(); |
| | | controlInfo.setTrustManager(getTrustManager()); |
| | | controlInfo.setConnectTimeout(argParser.getConnectTimeout()); |
| | | controlInfo.regenerateDescriptor(); |
| | | boolean authProvided = false; |
| | | if (controlInfo.getServerDescriptor().getStatus() == |
| | |
| | | * CDDL HEADER END |
| | | * |
| | | * |
| | | * Copyright 2007-2009 Sun Microsystems, Inc. |
| | | * Copyright 2007-2010 Sun Microsystems, Inc. |
| | | */ |
| | | |
| | | package org.opends.server.tools.tasks; |
| | |
| | | import java.util.EnumSet; |
| | | import java.util.Collections; |
| | | import java.io.IOException; |
| | | import javax.net.ssl.SSLException; |
| | | |
| | | /** |
| | | * Base class for tools that are capable of operating either by running |
| | |
| | | null, null, INFO_DESCRIPTION_TASK_DEPENDENCY_ID.get()); |
| | | argParser.addArgument(dependencyArg, taskGroup); |
| | | |
| | | Set fdaValSet = EnumSet.allOf(FailedDependencyAction.class); |
| | | Set<FailedDependencyAction> fdaValSet = |
| | | EnumSet.allOf(FailedDependencyAction.class); |
| | | failedDependencyActionArg = new StringArgument( |
| | | OPTION_LONG_FAILED_DEPENDENCY_ACTION, |
| | | OPTION_SHORT_FAILED_DEPENDENCY_ACTION, |
| | |
| | | |
| | | String fda = failedDependencyActionArg.getValue(); |
| | | if (null == FailedDependencyAction.fromString(fda)) { |
| | | Set fdaValSet = EnumSet.allOf(FailedDependencyAction.class); |
| | | Set<FailedDependencyAction> fdaValSet = |
| | | EnumSet.allOf(FailedDependencyAction.class); |
| | | throw new ArgumentException(ERR_TASKTOOL_INVALID_FDA.get(fda, |
| | | StaticUtils.collectionToString(fdaValSet, ","))); |
| | | } |
| | |
| | | ret = 0; |
| | | } catch (LDAPConnectionException e) { |
| | | Message message = null; |
| | | if ((e.getCause() != null) && (e.getCause().getCause() != null) && |
| | | e.getCause().getCause() instanceof SSLException) { |
| | | if (isWrongPortException(e, |
| | | new Integer(argParser.getArguments().getPort()))) |
| | | { |
| | | message = ERR_TASK_LDAP_FAILED_TO_CONNECT_WRONG_PORT.get( |
| | | argParser.getArguments().getHostName(), |
| | | argParser.getArguments().getPort()); |
| | |
| | | } |
| | | return returnValue; |
| | | } |
| | | |
| | | /** |
| | | * Returns {@code true} if the provided exception was caused by trying to |
| | | * connect to the wrong port and {@code false} otherwise. |
| | | * @param t the exception to be analyzed. |
| | | * @param port the port to which we tried to connect. |
| | | * @return {@code true} if the provided exception was caused by trying to |
| | | * connect to the wrong port and {@code false} otherwise. |
| | | */ |
| | | private boolean isWrongPortException(Throwable t, int port) |
| | | { |
| | | boolean isWrongPortException = false; |
| | | boolean isDefaultClearPort = (port - 389) % 1000 == 0; |
| | | while (t != null && isDefaultClearPort) |
| | | { |
| | | isWrongPortException = t instanceof java.net.SocketTimeoutException; |
| | | if (!isWrongPortException) |
| | | { |
| | | t = t.getCause(); |
| | | } |
| | | else |
| | | { |
| | | break; |
| | | } |
| | | } |
| | | return isWrongPortException; |
| | | } |
| | | } |
| | |
| | | * CDDL HEADER END |
| | | * |
| | | * |
| | | * Copyright 2006-2009 Sun Microsystems, Inc. |
| | | * Copyright 2006-2010 Sun Microsystems, Inc. |
| | | */ |
| | | package org.opends.server.util.args; |
| | | import org.opends.messages.Message; |
| | |
| | | OPTION_LONG_REPORT_AUTHZ_ID.equals(longId) || |
| | | OPTION_LONG_USE_PW_POLICY_CTL.equals(longId) || |
| | | OPTION_LONG_USE_SASL_EXTERNAL.equals(longId) || |
| | | OPTION_LONG_PROTOCOL_VERSION.equals(longId); |
| | | OPTION_LONG_PROTOCOL_VERSION.equals(longId) || |
| | | OPTION_LONG_CONNECT_TIMEOUT.equals(longId); |
| | | } |
| | | return ldap; |
| | | } |
| | |
| | | * CDDL HEADER END |
| | | * |
| | | * |
| | | * Copyright 2008 Sun Microsystems, Inc. |
| | | * Copyright 2008-2010 Sun Microsystems, Inc. |
| | | */ |
| | | |
| | | package org.opends.server.util.args; |
| | |
| | | connectionOptions.addSASLProperty(option); |
| | | } |
| | | } |
| | | |
| | | int timeout = args.connectTimeoutArg.getIntValue(); |
| | | |
| | | return connect( |
| | | args.hostNameArg.getValue(), |
| | | args.portArg.getIntValue(), |
| | | args.bindDnArg.getValue(), |
| | | getPasswordValue(args.bindPasswordArg, args.bindPasswordFileArg), |
| | | connectionOptions, out, err); |
| | | connectionOptions, timeout, out, err); |
| | | } |
| | | |
| | | /** |
| | |
| | | ui.getPortNumber(), |
| | | ui.getBindDN(), |
| | | ui.getBindPassword(), |
| | | ui.populateLDAPOptions(options), out, err); |
| | | ui.populateLDAPOptions(options), |
| | | ui.getConnectTimeout(), |
| | | out, err); |
| | | } catch (OpenDsException e) { |
| | | if ((e.getCause() != null) && (e.getCause().getCause() != null) && |
| | | e.getCause().getCause() instanceof SSLException) { |
| | |
| | | PrintStream err) |
| | | throws LDAPConnectionException |
| | | { |
| | | return connect(host, port, bindDN, bindPw, options, 0, out, err); |
| | | } |
| | | |
| | | |
| | | /** |
| | | * Creates a connection from information provided. |
| | | * |
| | | * @param host of the server |
| | | * @param port of the server |
| | | * @param bindDN with which to connect |
| | | * @param bindPw with which to connect |
| | | * @param options with which to connect |
| | | * @param timeout the timeout to establish the connection in milliseconds. |
| | | * Use {@code 0} to express no timeout |
| | | * @param out stream to write messages |
| | | * @param err stream to write messages |
| | | * @return LDAPConnection created by this class from parsed arguments |
| | | * @throws LDAPConnectionException if there was a problem connecting |
| | | * to the server indicated by the input arguments |
| | | */ |
| | | public LDAPConnection connect(String host, int port, |
| | | String bindDN, String bindPw, |
| | | LDAPConnectionOptions options, |
| | | int timeout, |
| | | PrintStream out, |
| | | PrintStream err) |
| | | throws LDAPConnectionException |
| | | { |
| | | // Attempt to connect and authenticate to the Directory Server. |
| | | AtomicInteger nextMessageID = new AtomicInteger(1); |
| | | |
| | | LDAPConnection connection = new LDAPConnection( |
| | | host, port, options, out, err); |
| | | |
| | | connection.connectToHost(bindDN, bindPw, nextMessageID); |
| | | connection.connectToHost(bindDN, bindPw, nextMessageID, timeout); |
| | | |
| | | return connection; |
| | | } |
| | |
| | | * @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. |
| | | */ |
| | | protected InitialLdapContext createAdministrativeContext(String host, |
| | | int port, boolean useSSL, boolean useStartTLS, String bindDn, String pwd, |
| | | ApplicationTrustManager trustManager) |
| | | int connectTimeout, ApplicationTrustManager trustManager) |
| | | throws NamingException |
| | | { |
| | | InitialLdapContext ctx; |
| | |
| | | if (useSSL) |
| | | { |
| | | ctx = Utils.createLdapsContext(ldapUrl, bindDn, pwd, |
| | | Utils.getDefaultLDAPTimeout(), null, trustManager); |
| | | connectTimeout, null, trustManager); |
| | | } |
| | | else if (useStartTLS) |
| | | { |
| | | ctx = Utils.createStartTLSContext(ldapUrl, bindDn, pwd, |
| | | Utils.getDefaultLDAPTimeout(), null, trustManager, |
| | | connectTimeout, null, trustManager, |
| | | null); |
| | | } |
| | | else |
| | | { |
| | | ctx = Utils.createLdapContext(ldapUrl, bindDn, pwd, |
| | | Utils.getDefaultLDAPTimeout(), null); |
| | | connectTimeout, null); |
| | | } |
| | | if (!ConnectionUtils.connectedAsAdministrativeUser(ctx)) |
| | | { |
| | |
| | | try |
| | | { |
| | | ctx = ConnectionUtils.createLdapsContext(ldapsUrl, bindDN, |
| | | bindPassword, ConnectionUtils.getDefaultLDAPTimeout(), null, |
| | | bindPassword, ci.getConnectTimeout(), null, |
| | | trustManager, keyManager); |
| | | ctx.reconnect(null); |
| | | break; |
| | |
| | | * CDDL HEADER END |
| | | * |
| | | * |
| | | * Copyright 2008-2009 Sun Microsystems, Inc. |
| | | * Copyright 2008-2010 Sun Microsystems, Inc. |
| | | */ |
| | | |
| | | package org.opends.server.util.cli; |
| | |
| | | |
| | | private String truststorePassword; |
| | | |
| | | // The timeout to be used to connect |
| | | private int connectTimeout; |
| | | |
| | | private Message heading = INFO_LDAP_CONN_HEADING_CONNECTION_PARAMETERS.get(); |
| | | |
| | | // A copy of the secureArgList for convenience. |
| | |
| | | copySecureArgsList.bindPasswordArg); |
| | | } |
| | | } |
| | | connectTimeout = secureArgsList.connectTimeoutArg.getIntValue(); |
| | | } |
| | | |
| | | /** |
| | |
| | | } |
| | | |
| | | /** |
| | | * Returns the timeout to be used to connect with the server. |
| | | * @return the timeout to be used to connect with the server. |
| | | */ |
| | | public int getConnectTimeout() |
| | | { |
| | | return connectTimeout; |
| | | } |
| | | |
| | | /** |
| | | * Indicate if the certificate chain can be trusted. |
| | | * |
| | | * @param chain The certificate chain to validate |