Java Code Examples for javax.naming.CommunicationException#setRootCause()

The following examples show how to use javax.naming.CommunicationException#setRootCause() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: LdapPoolManager.java    From dragonwell8_jdk with GNU General Public License v2.0 4 votes vote down vote up
/**
 * Determines whether pooling is allowed given information on how
 * the connection will be used.
 *
 * Non-configurable rejections:
 * - nonstandard socketFactory has been specified: the pool manager
 *   cannot track input or parameters used by the socket factory and
 *   thus has no way of determining whether two connection requests
 *   are equivalent. Maybe in the future it might add a list of allowed
 *   socket factories to be configured
 * - trace enabled (except when debugging)
 * - for Digest authentication, if a callback handler has been specified:
 *  the pool manager cannot track input collected by the handler
 *  and thus has no way of determining whether two connection requests are
 *  equivalent. Maybe in the future it might add a list of allowed
 *  callback handlers.
 *
 * Configurable tests:
 * - Pooling for the requested protocol (plain or ssl) is supported
 * - Pooling for the requested authentication mechanism is supported
 *
 */
static boolean isPoolingAllowed(String socketFactory, OutputStream trace,
    String authMech, String protocol, Hashtable<?,?> env)
            throws NamingException {

    if (trace != null && !debug

            // Requesting plain protocol but it is not supported
            || (protocol == null && !supportPlainProtocol)

            // Requesting ssl protocol but it is not supported
            || ("ssl".equalsIgnoreCase(protocol) && !supportSslProtocol)) {

        d("Pooling disallowed due to tracing or unsupported pooling of protocol");
        return false;
    }
    // pooling of custom socket factory is possible only if the
    // socket factory interface implements java.util.comparator
    String COMPARATOR = "java.util.Comparator";
    boolean foundSockCmp = false;
    if ((socketFactory != null) &&
         !socketFactory.equals(LdapCtx.DEFAULT_SSL_FACTORY)) {
        try {
            Class<?> socketFactoryClass = Obj.helper.loadClass(socketFactory);
            Class<?>[] interfaces = socketFactoryClass.getInterfaces();
            for (int i = 0; i < interfaces.length; i++) {
                if (interfaces[i].getCanonicalName().equals(COMPARATOR)) {
                    foundSockCmp = true;
                }
            }
        } catch (Exception e) {
            CommunicationException ce =
                new CommunicationException("Loading the socket factory");
            ce.setRootCause(e);
            throw ce;
        }
        if (!foundSockCmp) {
            return false;
        }
    }
    // Cannot use pooling if authMech is not a supported mechs
    // Cannot use pooling if authMech contains multiple mechs
    int p = findPool(authMech);
    if (p < 0 || pools[p] == null) {
        d("authmech not found: ", authMech);

        return false;
    }

    d("using authmech: ", authMech);

    switch (p) {
    case NONE:
    case SIMPLE:
        return true;

    case DIGEST:
        // Provider won't be able to determine connection identity
        // if an alternate callback handler is used
        return (env == null || env.get(SASL_CALLBACK) == null);
    }
    return false;
}
 
Example 2
Source File: LdapPoolManager.java    From TencentKona-8 with GNU General Public License v2.0 4 votes vote down vote up
/**
 * Determines whether pooling is allowed given information on how
 * the connection will be used.
 *
 * Non-configurable rejections:
 * - nonstandard socketFactory has been specified: the pool manager
 *   cannot track input or parameters used by the socket factory and
 *   thus has no way of determining whether two connection requests
 *   are equivalent. Maybe in the future it might add a list of allowed
 *   socket factories to be configured
 * - trace enabled (except when debugging)
 * - for Digest authentication, if a callback handler has been specified:
 *  the pool manager cannot track input collected by the handler
 *  and thus has no way of determining whether two connection requests are
 *  equivalent. Maybe in the future it might add a list of allowed
 *  callback handlers.
 *
 * Configurable tests:
 * - Pooling for the requested protocol (plain or ssl) is supported
 * - Pooling for the requested authentication mechanism is supported
 *
 */
static boolean isPoolingAllowed(String socketFactory, OutputStream trace,
    String authMech, String protocol, Hashtable<?,?> env)
            throws NamingException {

    if (trace != null && !debug

            // Requesting plain protocol but it is not supported
            || (protocol == null && !supportPlainProtocol)

            // Requesting ssl protocol but it is not supported
            || ("ssl".equalsIgnoreCase(protocol) && !supportSslProtocol)) {

        d("Pooling disallowed due to tracing or unsupported pooling of protocol");
        return false;
    }
    // pooling of custom socket factory is possible only if the
    // socket factory interface implements java.util.comparator
    String COMPARATOR = "java.util.Comparator";
    boolean foundSockCmp = false;
    if ((socketFactory != null) &&
         !socketFactory.equals(LdapCtx.DEFAULT_SSL_FACTORY)) {
        try {
            Class<?> socketFactoryClass = Obj.helper.loadClass(socketFactory);
            Class<?>[] interfaces = socketFactoryClass.getInterfaces();
            for (int i = 0; i < interfaces.length; i++) {
                if (interfaces[i].getCanonicalName().equals(COMPARATOR)) {
                    foundSockCmp = true;
                }
            }
        } catch (Exception e) {
            CommunicationException ce =
                new CommunicationException("Loading the socket factory");
            ce.setRootCause(e);
            throw ce;
        }
        if (!foundSockCmp) {
            return false;
        }
    }
    // Cannot use pooling if authMech is not a supported mechs
    // Cannot use pooling if authMech contains multiple mechs
    int p = findPool(authMech);
    if (p < 0 || pools[p] == null) {
        d("authmech not found: ", authMech);

        return false;
    }

    d("using authmech: ", authMech);

    switch (p) {
    case NONE:
    case SIMPLE:
        return true;

    case DIGEST:
        // Provider won't be able to determine connection identity
        // if an alternate callback handler is used
        return (env == null || env.get(SASL_CALLBACK) == null);
    }
    return false;
}
 
Example 3
Source File: LdapPoolManager.java    From jdk8u60 with GNU General Public License v2.0 4 votes vote down vote up
/**
 * Determines whether pooling is allowed given information on how
 * the connection will be used.
 *
 * Non-configurable rejections:
 * - nonstandard socketFactory has been specified: the pool manager
 *   cannot track input or parameters used by the socket factory and
 *   thus has no way of determining whether two connection requests
 *   are equivalent. Maybe in the future it might add a list of allowed
 *   socket factories to be configured
 * - trace enabled (except when debugging)
 * - for Digest authentication, if a callback handler has been specified:
 *  the pool manager cannot track input collected by the handler
 *  and thus has no way of determining whether two connection requests are
 *  equivalent. Maybe in the future it might add a list of allowed
 *  callback handlers.
 *
 * Configurable tests:
 * - Pooling for the requested protocol (plain or ssl) is supported
 * - Pooling for the requested authentication mechanism is supported
 *
 */
static boolean isPoolingAllowed(String socketFactory, OutputStream trace,
    String authMech, String protocol, Hashtable<?,?> env)
            throws NamingException {

    if (trace != null && !debug

            // Requesting plain protocol but it is not supported
            || (protocol == null && !supportPlainProtocol)

            // Requesting ssl protocol but it is not supported
            || ("ssl".equalsIgnoreCase(protocol) && !supportSslProtocol)) {

        d("Pooling disallowed due to tracing or unsupported pooling of protocol");
        return false;
    }
    // pooling of custom socket factory is possible only if the
    // socket factory interface implements java.util.comparator
    String COMPARATOR = "java.util.Comparator";
    boolean foundSockCmp = false;
    if ((socketFactory != null) &&
         !socketFactory.equals(LdapCtx.DEFAULT_SSL_FACTORY)) {
        try {
            Class<?> socketFactoryClass = Obj.helper.loadClass(socketFactory);
            Class<?>[] interfaces = socketFactoryClass.getInterfaces();
            for (int i = 0; i < interfaces.length; i++) {
                if (interfaces[i].getCanonicalName().equals(COMPARATOR)) {
                    foundSockCmp = true;
                }
            }
        } catch (Exception e) {
            CommunicationException ce =
                new CommunicationException("Loading the socket factory");
            ce.setRootCause(e);
            throw ce;
        }
        if (!foundSockCmp) {
            return false;
        }
    }
    // Cannot use pooling if authMech is not a supported mechs
    // Cannot use pooling if authMech contains multiple mechs
    int p = findPool(authMech);
    if (p < 0 || pools[p] == null) {
        d("authmech not found: ", authMech);

        return false;
    }

    d("using authmech: ", authMech);

    switch (p) {
    case NONE:
    case SIMPLE:
        return true;

    case DIGEST:
        // Provider won't be able to determine connection identity
        // if an alternate callback handler is used
        return (env == null || env.get(SASL_CALLBACK) == null);
    }
    return false;
}
 
Example 4
Source File: LdapPoolManager.java    From openjdk-jdk8u with GNU General Public License v2.0 4 votes vote down vote up
/**
 * Determines whether pooling is allowed given information on how
 * the connection will be used.
 *
 * Non-configurable rejections:
 * - nonstandard socketFactory has been specified: the pool manager
 *   cannot track input or parameters used by the socket factory and
 *   thus has no way of determining whether two connection requests
 *   are equivalent. Maybe in the future it might add a list of allowed
 *   socket factories to be configured
 * - trace enabled (except when debugging)
 * - for Digest authentication, if a callback handler has been specified:
 *  the pool manager cannot track input collected by the handler
 *  and thus has no way of determining whether two connection requests are
 *  equivalent. Maybe in the future it might add a list of allowed
 *  callback handlers.
 *
 * Configurable tests:
 * - Pooling for the requested protocol (plain or ssl) is supported
 * - Pooling for the requested authentication mechanism is supported
 *
 */
static boolean isPoolingAllowed(String socketFactory, OutputStream trace,
    String authMech, String protocol, Hashtable<?,?> env)
            throws NamingException {

    if (trace != null && !debug

            // Requesting plain protocol but it is not supported
            || (protocol == null && !supportPlainProtocol)

            // Requesting ssl protocol but it is not supported
            || ("ssl".equalsIgnoreCase(protocol) && !supportSslProtocol)) {

        d("Pooling disallowed due to tracing or unsupported pooling of protocol");
        return false;
    }
    // pooling of custom socket factory is possible only if the
    // socket factory interface implements java.util.comparator
    String COMPARATOR = "java.util.Comparator";
    boolean foundSockCmp = false;
    if ((socketFactory != null) &&
         !socketFactory.equals(LdapCtx.DEFAULT_SSL_FACTORY)) {
        try {
            Class<?> socketFactoryClass = Obj.helper.loadClass(socketFactory);
            Class<?>[] interfaces = socketFactoryClass.getInterfaces();
            for (int i = 0; i < interfaces.length; i++) {
                if (interfaces[i].getCanonicalName().equals(COMPARATOR)) {
                    foundSockCmp = true;
                }
            }
        } catch (Exception e) {
            CommunicationException ce =
                new CommunicationException("Loading the socket factory");
            ce.setRootCause(e);
            throw ce;
        }
        if (!foundSockCmp) {
            return false;
        }
    }
    // Cannot use pooling if authMech is not a supported mechs
    // Cannot use pooling if authMech contains multiple mechs
    int p = findPool(authMech);
    if (p < 0 || pools[p] == null) {
        d("authmech not found: ", authMech);

        return false;
    }

    d("using authmech: ", authMech);

    switch (p) {
    case NONE:
    case SIMPLE:
        return true;

    case DIGEST:
        // Provider won't be able to determine connection identity
        // if an alternate callback handler is used
        return (env == null || env.get(SASL_CALLBACK) == null);
    }
    return false;
}
 
Example 5
Source File: LdapPoolManager.java    From openjdk-jdk8u-backup with GNU General Public License v2.0 4 votes vote down vote up
/**
 * Determines whether pooling is allowed given information on how
 * the connection will be used.
 *
 * Non-configurable rejections:
 * - nonstandard socketFactory has been specified: the pool manager
 *   cannot track input or parameters used by the socket factory and
 *   thus has no way of determining whether two connection requests
 *   are equivalent. Maybe in the future it might add a list of allowed
 *   socket factories to be configured
 * - trace enabled (except when debugging)
 * - for Digest authentication, if a callback handler has been specified:
 *  the pool manager cannot track input collected by the handler
 *  and thus has no way of determining whether two connection requests are
 *  equivalent. Maybe in the future it might add a list of allowed
 *  callback handlers.
 *
 * Configurable tests:
 * - Pooling for the requested protocol (plain or ssl) is supported
 * - Pooling for the requested authentication mechanism is supported
 *
 */
static boolean isPoolingAllowed(String socketFactory, OutputStream trace,
    String authMech, String protocol, Hashtable<?,?> env)
            throws NamingException {

    if (trace != null && !debug

            // Requesting plain protocol but it is not supported
            || (protocol == null && !supportPlainProtocol)

            // Requesting ssl protocol but it is not supported
            || ("ssl".equalsIgnoreCase(protocol) && !supportSslProtocol)) {

        d("Pooling disallowed due to tracing or unsupported pooling of protocol");
        return false;
    }
    // pooling of custom socket factory is possible only if the
    // socket factory interface implements java.util.comparator
    String COMPARATOR = "java.util.Comparator";
    boolean foundSockCmp = false;
    if ((socketFactory != null) &&
         !socketFactory.equals(LdapCtx.DEFAULT_SSL_FACTORY)) {
        try {
            Class<?> socketFactoryClass = Obj.helper.loadClass(socketFactory);
            Class<?>[] interfaces = socketFactoryClass.getInterfaces();
            for (int i = 0; i < interfaces.length; i++) {
                if (interfaces[i].getCanonicalName().equals(COMPARATOR)) {
                    foundSockCmp = true;
                }
            }
        } catch (Exception e) {
            CommunicationException ce =
                new CommunicationException("Loading the socket factory");
            ce.setRootCause(e);
            throw ce;
        }
        if (!foundSockCmp) {
            return false;
        }
    }
    // Cannot use pooling if authMech is not a supported mechs
    // Cannot use pooling if authMech contains multiple mechs
    int p = findPool(authMech);
    if (p < 0 || pools[p] == null) {
        d("authmech not found: ", authMech);

        return false;
    }

    d("using authmech: ", authMech);

    switch (p) {
    case NONE:
    case SIMPLE:
        return true;

    case DIGEST:
        // Provider won't be able to determine connection identity
        // if an alternate callback handler is used
        return (env == null || env.get(SASL_CALLBACK) == null);
    }
    return false;
}
 
Example 6
Source File: LdapPoolManager.java    From openjdk-jdk9 with GNU General Public License v2.0 4 votes vote down vote up
/**
 * Determines whether pooling is allowed given information on how
 * the connection will be used.
 *
 * Non-configurable rejections:
 * - nonstandard socketFactory has been specified: the pool manager
 *   cannot track input or parameters used by the socket factory and
 *   thus has no way of determining whether two connection requests
 *   are equivalent. Maybe in the future it might add a list of allowed
 *   socket factories to be configured
 * - trace enabled (except when debugging)
 * - for Digest authentication, if a callback handler has been specified:
 *  the pool manager cannot track input collected by the handler
 *  and thus has no way of determining whether two connection requests are
 *  equivalent. Maybe in the future it might add a list of allowed
 *  callback handlers.
 *
 * Configurable tests:
 * - Pooling for the requested protocol (plain or ssl) is supported
 * - Pooling for the requested authentication mechanism is supported
 *
 */
static boolean isPoolingAllowed(String socketFactory, OutputStream trace,
    String authMech, String protocol, Hashtable<?,?> env)
            throws NamingException {

    if (trace != null && !debug

            // Requesting plain protocol but it is not supported
            || (protocol == null && !supportPlainProtocol)

            // Requesting ssl protocol but it is not supported
            || ("ssl".equalsIgnoreCase(protocol) && !supportSslProtocol)) {

        d("Pooling disallowed due to tracing or unsupported pooling of protocol");
        return false;
    }
    // pooling of custom socket factory is possible only if the
    // socket factory interface implements java.util.comparator
    String COMPARATOR = "java.util.Comparator";
    boolean foundSockCmp = false;
    if ((socketFactory != null) &&
         !socketFactory.equals(LdapCtx.DEFAULT_SSL_FACTORY)) {
        try {
            Class<?> socketFactoryClass = Obj.helper.loadClass(socketFactory);
            Class<?>[] interfaces = socketFactoryClass.getInterfaces();
            for (int i = 0; i < interfaces.length; i++) {
                if (interfaces[i].getCanonicalName().equals(COMPARATOR)) {
                    foundSockCmp = true;
                }
            }
        } catch (Exception e) {
            CommunicationException ce =
                new CommunicationException("Loading the socket factory");
            ce.setRootCause(e);
            throw ce;
        }
        if (!foundSockCmp) {
            return false;
        }
    }
    // Cannot use pooling if authMech is not a supported mechs
    // Cannot use pooling if authMech contains multiple mechs
    int p = findPool(authMech);
    if (p < 0 || pools[p] == null) {
        d("authmech not found: ", authMech);

        return false;
    }

    d("using authmech: ", authMech);

    switch (p) {
    case NONE:
    case SIMPLE:
        return true;

    case DIGEST:
        // Provider won't be able to determine connection identity
        // if an alternate callback handler is used
        return (env == null || env.get(SASL_CALLBACK) == null);
    }
    return false;
}
 
Example 7
Source File: LdapPoolManager.java    From jdk8u-jdk with GNU General Public License v2.0 4 votes vote down vote up
/**
 * Determines whether pooling is allowed given information on how
 * the connection will be used.
 *
 * Non-configurable rejections:
 * - nonstandard socketFactory has been specified: the pool manager
 *   cannot track input or parameters used by the socket factory and
 *   thus has no way of determining whether two connection requests
 *   are equivalent. Maybe in the future it might add a list of allowed
 *   socket factories to be configured
 * - trace enabled (except when debugging)
 * - for Digest authentication, if a callback handler has been specified:
 *  the pool manager cannot track input collected by the handler
 *  and thus has no way of determining whether two connection requests are
 *  equivalent. Maybe in the future it might add a list of allowed
 *  callback handlers.
 *
 * Configurable tests:
 * - Pooling for the requested protocol (plain or ssl) is supported
 * - Pooling for the requested authentication mechanism is supported
 *
 */
static boolean isPoolingAllowed(String socketFactory, OutputStream trace,
    String authMech, String protocol, Hashtable<?,?> env)
            throws NamingException {

    if (trace != null && !debug

            // Requesting plain protocol but it is not supported
            || (protocol == null && !supportPlainProtocol)

            // Requesting ssl protocol but it is not supported
            || ("ssl".equalsIgnoreCase(protocol) && !supportSslProtocol)) {

        d("Pooling disallowed due to tracing or unsupported pooling of protocol");
        return false;
    }
    // pooling of custom socket factory is possible only if the
    // socket factory interface implements java.util.comparator
    String COMPARATOR = "java.util.Comparator";
    boolean foundSockCmp = false;
    if ((socketFactory != null) &&
         !socketFactory.equals(LdapCtx.DEFAULT_SSL_FACTORY)) {
        try {
            Class<?> socketFactoryClass = Obj.helper.loadClass(socketFactory);
            Class<?>[] interfaces = socketFactoryClass.getInterfaces();
            for (int i = 0; i < interfaces.length; i++) {
                if (interfaces[i].getCanonicalName().equals(COMPARATOR)) {
                    foundSockCmp = true;
                }
            }
        } catch (Exception e) {
            CommunicationException ce =
                new CommunicationException("Loading the socket factory");
            ce.setRootCause(e);
            throw ce;
        }
        if (!foundSockCmp) {
            return false;
        }
    }
    // Cannot use pooling if authMech is not a supported mechs
    // Cannot use pooling if authMech contains multiple mechs
    int p = findPool(authMech);
    if (p < 0 || pools[p] == null) {
        d("authmech not found: ", authMech);

        return false;
    }

    d("using authmech: ", authMech);

    switch (p) {
    case NONE:
    case SIMPLE:
        return true;

    case DIGEST:
        // Provider won't be able to determine connection identity
        // if an alternate callback handler is used
        return (env == null || env.get(SASL_CALLBACK) == null);
    }
    return false;
}
 
Example 8
Source File: LdapPoolManager.java    From hottub with GNU General Public License v2.0 4 votes vote down vote up
/**
 * Determines whether pooling is allowed given information on how
 * the connection will be used.
 *
 * Non-configurable rejections:
 * - nonstandard socketFactory has been specified: the pool manager
 *   cannot track input or parameters used by the socket factory and
 *   thus has no way of determining whether two connection requests
 *   are equivalent. Maybe in the future it might add a list of allowed
 *   socket factories to be configured
 * - trace enabled (except when debugging)
 * - for Digest authentication, if a callback handler has been specified:
 *  the pool manager cannot track input collected by the handler
 *  and thus has no way of determining whether two connection requests are
 *  equivalent. Maybe in the future it might add a list of allowed
 *  callback handlers.
 *
 * Configurable tests:
 * - Pooling for the requested protocol (plain or ssl) is supported
 * - Pooling for the requested authentication mechanism is supported
 *
 */
static boolean isPoolingAllowed(String socketFactory, OutputStream trace,
    String authMech, String protocol, Hashtable<?,?> env)
            throws NamingException {

    if (trace != null && !debug

            // Requesting plain protocol but it is not supported
            || (protocol == null && !supportPlainProtocol)

            // Requesting ssl protocol but it is not supported
            || ("ssl".equalsIgnoreCase(protocol) && !supportSslProtocol)) {

        d("Pooling disallowed due to tracing or unsupported pooling of protocol");
        return false;
    }
    // pooling of custom socket factory is possible only if the
    // socket factory interface implements java.util.comparator
    String COMPARATOR = "java.util.Comparator";
    boolean foundSockCmp = false;
    if ((socketFactory != null) &&
         !socketFactory.equals(LdapCtx.DEFAULT_SSL_FACTORY)) {
        try {
            Class<?> socketFactoryClass = Obj.helper.loadClass(socketFactory);
            Class<?>[] interfaces = socketFactoryClass.getInterfaces();
            for (int i = 0; i < interfaces.length; i++) {
                if (interfaces[i].getCanonicalName().equals(COMPARATOR)) {
                    foundSockCmp = true;
                }
            }
        } catch (Exception e) {
            CommunicationException ce =
                new CommunicationException("Loading the socket factory");
            ce.setRootCause(e);
            throw ce;
        }
        if (!foundSockCmp) {
            return false;
        }
    }
    // Cannot use pooling if authMech is not a supported mechs
    // Cannot use pooling if authMech contains multiple mechs
    int p = findPool(authMech);
    if (p < 0 || pools[p] == null) {
        d("authmech not found: ", authMech);

        return false;
    }

    d("using authmech: ", authMech);

    switch (p) {
    case NONE:
    case SIMPLE:
        return true;

    case DIGEST:
        // Provider won't be able to determine connection identity
        // if an alternate callback handler is used
        return (env == null || env.get(SASL_CALLBACK) == null);
    }
    return false;
}
 
Example 9
Source File: LdapPoolManager.java    From openjdk-8-source with GNU General Public License v2.0 4 votes vote down vote up
/**
 * Determines whether pooling is allowed given information on how
 * the connection will be used.
 *
 * Non-configurable rejections:
 * - nonstandard socketFactory has been specified: the pool manager
 *   cannot track input or parameters used by the socket factory and
 *   thus has no way of determining whether two connection requests
 *   are equivalent. Maybe in the future it might add a list of allowed
 *   socket factories to be configured
 * - trace enabled (except when debugging)
 * - for Digest authentication, if a callback handler has been specified:
 *  the pool manager cannot track input collected by the handler
 *  and thus has no way of determining whether two connection requests are
 *  equivalent. Maybe in the future it might add a list of allowed
 *  callback handlers.
 *
 * Configurable tests:
 * - Pooling for the requested protocol (plain or ssl) is supported
 * - Pooling for the requested authentication mechanism is supported
 *
 */
static boolean isPoolingAllowed(String socketFactory, OutputStream trace,
    String authMech, String protocol, Hashtable<?,?> env)
            throws NamingException {

    if (trace != null && !debug

            // Requesting plain protocol but it is not supported
            || (protocol == null && !supportPlainProtocol)

            // Requesting ssl protocol but it is not supported
            || ("ssl".equalsIgnoreCase(protocol) && !supportSslProtocol)) {

        d("Pooling disallowed due to tracing or unsupported pooling of protocol");
        return false;
    }
    // pooling of custom socket factory is possible only if the
    // socket factory interface implements java.util.comparator
    String COMPARATOR = "java.util.Comparator";
    boolean foundSockCmp = false;
    if ((socketFactory != null) &&
         !socketFactory.equals(LdapCtx.DEFAULT_SSL_FACTORY)) {
        try {
            Class<?> socketFactoryClass = Obj.helper.loadClass(socketFactory);
            Class<?>[] interfaces = socketFactoryClass.getInterfaces();
            for (int i = 0; i < interfaces.length; i++) {
                if (interfaces[i].getCanonicalName().equals(COMPARATOR)) {
                    foundSockCmp = true;
                }
            }
        } catch (Exception e) {
            CommunicationException ce =
                new CommunicationException("Loading the socket factory");
            ce.setRootCause(e);
            throw ce;
        }
        if (!foundSockCmp) {
            return false;
        }
    }
    // Cannot use pooling if authMech is not a supported mechs
    // Cannot use pooling if authMech contains multiple mechs
    int p = findPool(authMech);
    if (p < 0 || pools[p] == null) {
        d("authmech not found: ", authMech);

        return false;
    }

    d("using authmech: ", authMech);

    switch (p) {
    case NONE:
    case SIMPLE:
        return true;

    case DIGEST:
        // Provider won't be able to determine connection identity
        // if an alternate callback handler is used
        return (env == null || env.get(SASL_CALLBACK) == null);
    }
    return false;
}
 
Example 10
Source File: LdapPoolManager.java    From openjdk-8 with GNU General Public License v2.0 4 votes vote down vote up
/**
 * Determines whether pooling is allowed given information on how
 * the connection will be used.
 *
 * Non-configurable rejections:
 * - nonstandard socketFactory has been specified: the pool manager
 *   cannot track input or parameters used by the socket factory and
 *   thus has no way of determining whether two connection requests
 *   are equivalent. Maybe in the future it might add a list of allowed
 *   socket factories to be configured
 * - trace enabled (except when debugging)
 * - for Digest authentication, if a callback handler has been specified:
 *  the pool manager cannot track input collected by the handler
 *  and thus has no way of determining whether two connection requests are
 *  equivalent. Maybe in the future it might add a list of allowed
 *  callback handlers.
 *
 * Configurable tests:
 * - Pooling for the requested protocol (plain or ssl) is supported
 * - Pooling for the requested authentication mechanism is supported
 *
 */
static boolean isPoolingAllowed(String socketFactory, OutputStream trace,
    String authMech, String protocol, Hashtable<?,?> env)
            throws NamingException {

    if (trace != null && !debug

            // Requesting plain protocol but it is not supported
            || (protocol == null && !supportPlainProtocol)

            // Requesting ssl protocol but it is not supported
            || ("ssl".equalsIgnoreCase(protocol) && !supportSslProtocol)) {

        d("Pooling disallowed due to tracing or unsupported pooling of protocol");
        return false;
    }
    // pooling of custom socket factory is possible only if the
    // socket factory interface implements java.util.comparator
    String COMPARATOR = "java.util.Comparator";
    boolean foundSockCmp = false;
    if ((socketFactory != null) &&
         !socketFactory.equals(LdapCtx.DEFAULT_SSL_FACTORY)) {
        try {
            Class<?> socketFactoryClass = Obj.helper.loadClass(socketFactory);
            Class<?>[] interfaces = socketFactoryClass.getInterfaces();
            for (int i = 0; i < interfaces.length; i++) {
                if (interfaces[i].getCanonicalName().equals(COMPARATOR)) {
                    foundSockCmp = true;
                }
            }
        } catch (Exception e) {
            CommunicationException ce =
                new CommunicationException("Loading the socket factory");
            ce.setRootCause(e);
            throw ce;
        }
        if (!foundSockCmp) {
            return false;
        }
    }
    // Cannot use pooling if authMech is not a supported mechs
    // Cannot use pooling if authMech contains multiple mechs
    int p = findPool(authMech);
    if (p < 0 || pools[p] == null) {
        d("authmech not found: ", authMech);

        return false;
    }

    d("using authmech: ", authMech);

    switch (p) {
    case NONE:
    case SIMPLE:
        return true;

    case DIGEST:
        // Provider won't be able to determine connection identity
        // if an alternate callback handler is used
        return (env == null || env.get(SASL_CALLBACK) == null);
    }
    return false;
}
 
Example 11
Source File: LdapPoolManager.java    From jdk8u_jdk with GNU General Public License v2.0 4 votes vote down vote up
/**
 * Determines whether pooling is allowed given information on how
 * the connection will be used.
 *
 * Non-configurable rejections:
 * - nonstandard socketFactory has been specified: the pool manager
 *   cannot track input or parameters used by the socket factory and
 *   thus has no way of determining whether two connection requests
 *   are equivalent. Maybe in the future it might add a list of allowed
 *   socket factories to be configured
 * - trace enabled (except when debugging)
 * - for Digest authentication, if a callback handler has been specified:
 *  the pool manager cannot track input collected by the handler
 *  and thus has no way of determining whether two connection requests are
 *  equivalent. Maybe in the future it might add a list of allowed
 *  callback handlers.
 *
 * Configurable tests:
 * - Pooling for the requested protocol (plain or ssl) is supported
 * - Pooling for the requested authentication mechanism is supported
 *
 */
static boolean isPoolingAllowed(String socketFactory, OutputStream trace,
    String authMech, String protocol, Hashtable<?,?> env)
            throws NamingException {

    if (trace != null && !debug

            // Requesting plain protocol but it is not supported
            || (protocol == null && !supportPlainProtocol)

            // Requesting ssl protocol but it is not supported
            || ("ssl".equalsIgnoreCase(protocol) && !supportSslProtocol)) {

        d("Pooling disallowed due to tracing or unsupported pooling of protocol");
        return false;
    }
    // pooling of custom socket factory is possible only if the
    // socket factory interface implements java.util.comparator
    String COMPARATOR = "java.util.Comparator";
    boolean foundSockCmp = false;
    if ((socketFactory != null) &&
         !socketFactory.equals(LdapCtx.DEFAULT_SSL_FACTORY)) {
        try {
            Class<?> socketFactoryClass = Obj.helper.loadClass(socketFactory);
            Class<?>[] interfaces = socketFactoryClass.getInterfaces();
            for (int i = 0; i < interfaces.length; i++) {
                if (interfaces[i].getCanonicalName().equals(COMPARATOR)) {
                    foundSockCmp = true;
                }
            }
        } catch (Exception e) {
            CommunicationException ce =
                new CommunicationException("Loading the socket factory");
            ce.setRootCause(e);
            throw ce;
        }
        if (!foundSockCmp) {
            return false;
        }
    }
    // Cannot use pooling if authMech is not a supported mechs
    // Cannot use pooling if authMech contains multiple mechs
    int p = findPool(authMech);
    if (p < 0 || pools[p] == null) {
        d("authmech not found: ", authMech);

        return false;
    }

    d("using authmech: ", authMech);

    switch (p) {
    case NONE:
    case SIMPLE:
        return true;

    case DIGEST:
        // Provider won't be able to determine connection identity
        // if an alternate callback handler is used
        return (env == null || env.get(SASL_CALLBACK) == null);
    }
    return false;
}
 
Example 12
Source File: LdapPoolManager.java    From jdk8u-jdk with GNU General Public License v2.0 4 votes vote down vote up
/**
 * Determines whether pooling is allowed given information on how
 * the connection will be used.
 *
 * Non-configurable rejections:
 * - nonstandard socketFactory has been specified: the pool manager
 *   cannot track input or parameters used by the socket factory and
 *   thus has no way of determining whether two connection requests
 *   are equivalent. Maybe in the future it might add a list of allowed
 *   socket factories to be configured
 * - trace enabled (except when debugging)
 * - for Digest authentication, if a callback handler has been specified:
 *  the pool manager cannot track input collected by the handler
 *  and thus has no way of determining whether two connection requests are
 *  equivalent. Maybe in the future it might add a list of allowed
 *  callback handlers.
 *
 * Configurable tests:
 * - Pooling for the requested protocol (plain or ssl) is supported
 * - Pooling for the requested authentication mechanism is supported
 *
 */
static boolean isPoolingAllowed(String socketFactory, OutputStream trace,
    String authMech, String protocol, Hashtable<?,?> env)
            throws NamingException {

    if (trace != null && !debug

            // Requesting plain protocol but it is not supported
            || (protocol == null && !supportPlainProtocol)

            // Requesting ssl protocol but it is not supported
            || ("ssl".equalsIgnoreCase(protocol) && !supportSslProtocol)) {

        d("Pooling disallowed due to tracing or unsupported pooling of protocol");
        return false;
    }
    // pooling of custom socket factory is possible only if the
    // socket factory interface implements java.util.comparator
    String COMPARATOR = "java.util.Comparator";
    boolean foundSockCmp = false;
    if ((socketFactory != null) &&
         !socketFactory.equals(LdapCtx.DEFAULT_SSL_FACTORY)) {
        try {
            Class<?> socketFactoryClass = Obj.helper.loadClass(socketFactory);
            Class<?>[] interfaces = socketFactoryClass.getInterfaces();
            for (int i = 0; i < interfaces.length; i++) {
                if (interfaces[i].getCanonicalName().equals(COMPARATOR)) {
                    foundSockCmp = true;
                }
            }
        } catch (Exception e) {
            CommunicationException ce =
                new CommunicationException("Loading the socket factory");
            ce.setRootCause(e);
            throw ce;
        }
        if (!foundSockCmp) {
            return false;
        }
    }
    // Cannot use pooling if authMech is not a supported mechs
    // Cannot use pooling if authMech contains multiple mechs
    int p = findPool(authMech);
    if (p < 0 || pools[p] == null) {
        d("authmech not found: ", authMech);

        return false;
    }

    d("using authmech: ", authMech);

    switch (p) {
    case NONE:
    case SIMPLE:
        return true;

    case DIGEST:
        // Provider won't be able to determine connection identity
        // if an alternate callback handler is used
        return (env == null || env.get(SASL_CALLBACK) == null);
    }
    return false;
}
 
Example 13
Source File: LdapPoolManager.java    From jdk8u-dev-jdk with GNU General Public License v2.0 4 votes vote down vote up
/**
 * Determines whether pooling is allowed given information on how
 * the connection will be used.
 *
 * Non-configurable rejections:
 * - nonstandard socketFactory has been specified: the pool manager
 *   cannot track input or parameters used by the socket factory and
 *   thus has no way of determining whether two connection requests
 *   are equivalent. Maybe in the future it might add a list of allowed
 *   socket factories to be configured
 * - trace enabled (except when debugging)
 * - for Digest authentication, if a callback handler has been specified:
 *  the pool manager cannot track input collected by the handler
 *  and thus has no way of determining whether two connection requests are
 *  equivalent. Maybe in the future it might add a list of allowed
 *  callback handlers.
 *
 * Configurable tests:
 * - Pooling for the requested protocol (plain or ssl) is supported
 * - Pooling for the requested authentication mechanism is supported
 *
 */
static boolean isPoolingAllowed(String socketFactory, OutputStream trace,
    String authMech, String protocol, Hashtable<?,?> env)
            throws NamingException {

    if (trace != null && !debug

            // Requesting plain protocol but it is not supported
            || (protocol == null && !supportPlainProtocol)

            // Requesting ssl protocol but it is not supported
            || ("ssl".equalsIgnoreCase(protocol) && !supportSslProtocol)) {

        d("Pooling disallowed due to tracing or unsupported pooling of protocol");
        return false;
    }
    // pooling of custom socket factory is possible only if the
    // socket factory interface implements java.util.comparator
    String COMPARATOR = "java.util.Comparator";
    boolean foundSockCmp = false;
    if ((socketFactory != null) &&
         !socketFactory.equals(LdapCtx.DEFAULT_SSL_FACTORY)) {
        try {
            Class<?> socketFactoryClass = Obj.helper.loadClass(socketFactory);
            Class<?>[] interfaces = socketFactoryClass.getInterfaces();
            for (int i = 0; i < interfaces.length; i++) {
                if (interfaces[i].getCanonicalName().equals(COMPARATOR)) {
                    foundSockCmp = true;
                }
            }
        } catch (Exception e) {
            CommunicationException ce =
                new CommunicationException("Loading the socket factory");
            ce.setRootCause(e);
            throw ce;
        }
        if (!foundSockCmp) {
            return false;
        }
    }
    // Cannot use pooling if authMech is not a supported mechs
    // Cannot use pooling if authMech contains multiple mechs
    int p = findPool(authMech);
    if (p < 0 || pools[p] == null) {
        d("authmech not found: ", authMech);

        return false;
    }

    d("using authmech: ", authMech);

    switch (p) {
    case NONE:
    case SIMPLE:
        return true;

    case DIGEST:
        // Provider won't be able to determine connection identity
        // if an alternate callback handler is used
        return (env == null || env.get(SASL_CALLBACK) == null);
    }
    return false;
}