ConnectionWrapper: isSSL() => isLdaps(), isStartTLS() => isStartTls()
| | |
| | | @Override |
| | | public void run() { |
| | | try { |
| | | if (conn.isSSL() || conn.isStartTLS()) |
| | | if (conn.isLdaps() || conn.isStartTls()) |
| | | { |
| | | TrustedSocketFactory.setCurrentThreadTrustManager(trustManager, keyManager); |
| | | } |
| | |
| | | /** |
| | | * Returns the LDAP URL for the provided parameters. |
| | | * @param hostPort the host name and LDAP port. |
| | | * @param useSSL whether to use SSL or not. |
| | | * @param useLdaps whether to use LDAPS. |
| | | * @return the LDAP URL for the provided parameters. |
| | | */ |
| | | public static String getLDAPUrl(HostPort hostPort, boolean useSSL) |
| | | public static String getLDAPUrl(HostPort hostPort, boolean useLdaps) |
| | | { |
| | | return getLDAPUrl(hostPort.getHost(), hostPort.getPort(), useSSL); |
| | | return getLDAPUrl(hostPort.getHost(), hostPort.getPort(), useLdaps); |
| | | } |
| | | |
| | | /** |
| | | * Returns the LDAP URL for the provided parameters. |
| | | * @param host the host name. |
| | | * @param port the LDAP port. |
| | | * @param useSSL whether to use SSL or not. |
| | | * @param useLdaps whether to use LDAPS. |
| | | * @return the LDAP URL for the provided parameters. |
| | | */ |
| | | public static String getLDAPUrl(String host, int port, boolean useSSL) |
| | | public static String getLDAPUrl(String host, int port, boolean useLdaps) |
| | | { |
| | | host = Utils.getHostNameForLdapUrl(host); |
| | | return (useSSL ? "ldaps://" : "ldap://") + host + ":" + port; |
| | | return (useLdaps ? "ldaps" : "ldap") + "://" + host + ":" + port; |
| | | } |
| | | |
| | | /** |
| | |
| | | } |
| | | |
| | | /** |
| | | * Returns whether this connection uses SSL. |
| | | * Returns whether this connection uses LDAPS. |
| | | * |
| | | * @return {@code true} if this connection uses SSL {@code false} otherwise. |
| | | * @return {@code true} if this connection uses LDAPS, {@code false} otherwise. |
| | | */ |
| | | public boolean isSSL() |
| | | public boolean isLdaps() |
| | | { |
| | | return getConnectionType() == LDAPS; |
| | | } |
| | |
| | | /** |
| | | * Returns whether this connection uses StartTLS. |
| | | * |
| | | * @return {@code true} if this connection uses StartTLS {@code false} otherwise. |
| | | * @return {@code true} if this connection uses StartTLS, {@code false} otherwise. |
| | | */ |
| | | public boolean isStartTLS() |
| | | public boolean isStartTls() |
| | | { |
| | | return getConnectionType() == START_TLS; |
| | | } |
| | |
| | | |
| | | private InitialLdapContext createAdministrativeContext0() throws NamingException |
| | | { |
| | | final String ldapUrl = getLDAPUrl(getHostPort(), isSSL()); |
| | | final String ldapUrl = getLDAPUrl(getHostPort(), isLdaps()); |
| | | final String bindDnStr = bindDn.toString(); |
| | | switch (connectionType) |
| | | { |
| | |
| | | */ |
| | | LDAPURL findUrlForLocalEntry(BasicNode node) { |
| | | if (node == rootNode) { |
| | | return LDAPConnectionPool.makeLDAPUrl(connConfig.getHostPort(), "", connConfig.isSSL()); |
| | | return LDAPConnectionPool.makeLDAPUrl(connConfig.getHostPort(), "", connConfig.isLdaps()); |
| | | } |
| | | final BasicNode parent = (BasicNode) node.getParent(); |
| | | if (parent != null) |
| | |
| | | final LDAPURL parentUrl = findUrlForDisplayedEntry(parent); |
| | | return LDAPConnectionPool.makeLDAPUrl(parentUrl, node.getDN()); |
| | | } |
| | | return LDAPConnectionPool.makeLDAPUrl(connConfig.getHostPort(), node.getDN(), connConfig.isSSL()); |
| | | return LDAPConnectionPool.makeLDAPUrl(connConfig.getHostPort(), node.getDN(), connConfig.isLdaps()); |
| | | } |
| | | |
| | | |
| | |
| | | */ |
| | | private void disconnectAndRemove(ConnectionRecord cr) |
| | | { |
| | | String key = makeKeyFromRecord(cr); |
| | | connectionTable.remove(key); |
| | | connectionTable.remove(makeKeyFromRecord(cr)); |
| | | cr.conn.close(); |
| | | } |
| | | |
| | |
| | | * @return the key to be used in Maps for the provided connection record. |
| | | */ |
| | | private static String makeKeyFromRecord(ConnectionRecord rec) { |
| | | String protocol = rec.conn.isSSL() ? "LDAPS" : "LDAP"; |
| | | return protocol + ":" + rec.conn.getHostPort(); |
| | | return (rec.conn.isLdaps() ? "LDAPS" : "LDAP") + ":" + rec.conn.getHostPort(); |
| | | } |
| | | |
| | | /** |
| | |
| | | } |
| | | |
| | | private LDAPURL makeLDAPUrl(ConnectionWrapper conn) { |
| | | return makeLDAPUrl(conn.getHostPort(), "", conn.isSSL()); |
| | | return makeLDAPUrl(conn.getHostPort(), "", conn.isLdaps()); |
| | | } |
| | | |
| | | /** |
| | | * Make an url from the specified arguments. |
| | | * @param hostPort the host name and port of the server. |
| | | * @param dn the base DN of the URL. |
| | | * @param isSSL whether the connection uses SSL |
| | | * @param isLdaps whether the connection uses LDAPS |
| | | * @return an LDAP URL from the specified arguments. |
| | | */ |
| | | public static LDAPURL makeLDAPUrl(HostPort hostPort, String dn, boolean isSSL) |
| | | public static LDAPURL makeLDAPUrl(HostPort hostPort, String dn, boolean isLdaps) |
| | | { |
| | | return new LDAPURL( |
| | | isSSL ? "ldaps" : LDAPURL.DEFAULT_SCHEME, |
| | | isLdaps ? "ldaps" : LDAPURL.DEFAULT_SCHEME, |
| | | hostPort.getHost(), |
| | | hostPort.getPort(), |
| | | dn, |
| | |
| | | HostPort hostPort = conn.getHostPort(); |
| | | url.setHost(hostPort.getHost()); |
| | | url.setPort(hostPort.getPort()); |
| | | url.setScheme(conn.isSSL() ? "ldaps" : "ldap"); |
| | | url.setScheme(conn.isLdaps() ? "ldaps" : "ldap"); |
| | | } |
| | | conn = connectionPool.getConnection(url); |
| | | remoteDn = url.getRawBaseDN(); |
| | |
| | | { |
| | | hostName = hostPort.getHost(); |
| | | } |
| | | boolean isSSL = conn.isSSL(); |
| | | boolean isStartTLS = conn.isStartTLS(); |
| | | boolean isLdaps = conn.isLdaps(); |
| | | boolean isStartTls = conn.isStartTls(); |
| | | String bindDN = conn.getBindDn().toString(); |
| | | String bindPwd = conn.getBindPassword(); |
| | | args.add("--hostName"); |
| | |
| | | args.add(bindDN); |
| | | args.add("--bindPassword"); |
| | | args.add(bindPwd); |
| | | if (isSSL || isStartTLS) |
| | | if (isLdaps || isStartTls) |
| | | { |
| | | args.add("--trustAll"); |
| | | } |
| | | if (isSSL && addConnectionTypeParameters) |
| | | if (isLdaps && addConnectionTypeParameters) |
| | | { |
| | | args.add("--useSSL"); |
| | | } |
| | | else if (isStartTLS && addConnectionTypeParameters) |
| | | else if (isStartTls && addConnectionTypeParameters) |
| | | { |
| | | args.add("--useStartTLS"); |
| | | } |