javax.naming.CommunicationException#setRootCause ( )源码实例Demo

下面列出了javax.naming.CommunicationException#setRootCause ( ) 实例代码,或者点击链接到github查看源代码,也可以在右侧发表评论。

源代码1 项目: dragonwell8_jdk   文件: LdapPoolManager.java
/**
 * 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;
}
 
源代码2 项目: TencentKona-8   文件: LdapPoolManager.java
/**
 * 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;
}
 
源代码3 项目: jdk8u60   文件: LdapPoolManager.java
/**
 * 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;
}
 
源代码4 项目: openjdk-jdk8u   文件: LdapPoolManager.java
/**
 * 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;
}
 
源代码5 项目: openjdk-jdk8u-backup   文件: LdapPoolManager.java
/**
 * 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;
}
 
源代码6 项目: openjdk-jdk9   文件: LdapPoolManager.java
/**
 * 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;
}
 
源代码7 项目: jdk8u-jdk   文件: LdapPoolManager.java
/**
 * 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;
}
 
源代码8 项目: hottub   文件: LdapPoolManager.java
/**
 * 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;
}
 
源代码9 项目: openjdk-8-source   文件: LdapPoolManager.java
/**
 * 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;
}
 
源代码10 项目: openjdk-8   文件: LdapPoolManager.java
/**
 * 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;
}
 
源代码11 项目: jdk8u_jdk   文件: LdapPoolManager.java
/**
 * 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;
}
 
源代码12 项目: jdk8u-jdk   文件: LdapPoolManager.java
/**
 * 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;
}
 
源代码13 项目: jdk8u-dev-jdk   文件: LdapPoolManager.java
/**
 * 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;
}