类javax.net.ssl.SSLKeyException源码实例Demo

下面列出了怎么用javax.net.ssl.SSLKeyException的API类实例代码及写法,或者点击链接到github查看源代码。

源代码1 项目: openjsse   文件: SSLEngineImpl.java
private static SSLException getTaskThrown(Exception taskThrown) {
    String msg = taskThrown.getMessage();

    if (msg == null) {
        msg = "Delegated task threw Exception or Error";
    }

    if (taskThrown instanceof RuntimeException) {
        throw new RuntimeException(msg, taskThrown);
    } else if (taskThrown instanceof SSLHandshakeException) {
        return (SSLHandshakeException)
            new SSLHandshakeException(msg).initCause(taskThrown);
    } else if (taskThrown instanceof SSLKeyException) {
        return (SSLKeyException)
            new SSLKeyException(msg).initCause(taskThrown);
    } else if (taskThrown instanceof SSLPeerUnverifiedException) {
        return (SSLPeerUnverifiedException)
            new SSLPeerUnverifiedException(msg).initCause(taskThrown);
    } else if (taskThrown instanceof SSLProtocolException) {
        return (SSLProtocolException)
            new SSLProtocolException(msg).initCause(taskThrown);
    } else if (taskThrown instanceof SSLException) {
        return (SSLException)taskThrown;
    } else {
        return new SSLException(msg, taskThrown);
    }
}
 
源代码2 项目: Bytecoder   文件: SSLEngineImpl.java
private static SSLException getTaskThrown(Exception taskThrown) {
    String msg = taskThrown.getMessage();

    if (msg == null) {
        msg = "Delegated task threw Exception or Error";
    }

    if (taskThrown instanceof RuntimeException) {
        throw new RuntimeException(msg, taskThrown);
    } else if (taskThrown instanceof SSLHandshakeException) {
        return (SSLHandshakeException)
            new SSLHandshakeException(msg).initCause(taskThrown);
    } else if (taskThrown instanceof SSLKeyException) {
        return (SSLKeyException)
            new SSLKeyException(msg).initCause(taskThrown);
    } else if (taskThrown instanceof SSLPeerUnverifiedException) {
        return (SSLPeerUnverifiedException)
            new SSLPeerUnverifiedException(msg).initCause(taskThrown);
    } else if (taskThrown instanceof SSLProtocolException) {
        return (SSLProtocolException)
            new SSLProtocolException(msg).initCause(taskThrown);
    } else if (taskThrown instanceof SSLException) {
        return (SSLException)taskThrown;
    } else {
        return new SSLException(msg, taskThrown);
    }
}
 
源代码3 项目: j2objc   文件: SSLKeyExceptionTest.java
/**
 * Test for <code>SSLPeerUnverifiedException(String)</code> constructor Assertion:
 * constructs SSLPeerUnverifiedException with detail message msg. Parameter
 * <code>msg</code> is null.
 */
public void test_Constructor02() {
    String msg = null;
    SSLKeyException skE = new SSLKeyException(msg);
    assertNull("getMessage() must return null.", skE.getMessage());
    assertNull("getCause() must return null", skE.getCause());
}
 
源代码4 项目: java-n-IDE-for-Android   文件: SdkStats.java
public void load(DownloadCache cache, boolean forceHttp, ITaskMonitor monitor) {

        String url = SdkStatsConstants.URL_STATS;

        if (forceHttp) {
            url = url.replaceAll("https://", "http://");  //$NON-NLS-1$ //$NON-NLS-2$
        }

        monitor.setProgressMax(5);
        monitor.setDescription("Fetching %1$s", url);
        monitor.incProgress(1);

        Exception[] exception = new Exception[] { null };
        Boolean[] validatorFound = new Boolean[] { Boolean.FALSE };
        String[] validationError = new String[] { null };
        Document validatedDoc = null;
        String validatedUri = null;

        InputStream xml = fetchXmlUrl(url, cache, monitor.createSubMonitor(1), exception);

        if (xml != null) {
            monitor.setDescription("Validate XML");

            // Explore the XML to find the potential XML schema version
            int version = getXmlSchemaVersion(xml);

            if (version >= 1 && version <= SdkStatsConstants.NS_LATEST_VERSION) {
                // This should be a version we can handle. Try to validate it
                // and report any error as invalid XML syntax,

                String uri = validateXml(xml, url, version, validationError, validatorFound);
                if (uri != null) {
                    // Validation was successful
                    validatedDoc = getDocument(xml, monitor);
                    validatedUri = uri;

                }
            } else if (version > SdkStatsConstants.NS_LATEST_VERSION) {
                // The schema used is more recent than what is supported by this tool.
                // We don't have an upgrade-path support yet, so simply ignore the document.
                closeStream(xml);
                return;
            }
        }

        // If any exception was handled during the URL fetch, display it now.
        if (exception[0] != null) {
            String reason = null;
            if (exception[0] instanceof FileNotFoundException) {
                // FNF has no useful getMessage, so we need to special handle it.
                reason = "File not found";
            } else if (exception[0] instanceof UnknownHostException &&
                    exception[0].getMessage() != null) {
                // This has no useful getMessage yet could really use one
                reason = String.format("Unknown Host %1$s", exception[0].getMessage());
            } else if (exception[0] instanceof SSLKeyException) {
                // That's a common error and we have a pref for it.
                reason = "HTTPS SSL error. You might want to force download through HTTP in the settings.";
            } else if (exception[0].getMessage() != null) {
                reason = exception[0].getMessage();
            } else {
                // We don't know what's wrong. Let's give the exception class at least.
                reason = String.format("Unknown (%1$s)", exception[0].getClass().getName());
            }

            monitor.logError("Failed to fetch URL %1$s, reason: %2$s", url, reason);
        }

        if (validationError[0] != null) {
            monitor.logError("%s", validationError[0]);  //$NON-NLS-1$
        }

        // Stop here if we failed to validate the XML. We don't want to load it.
        if (validatedDoc == null) {
            closeStream(xml);
            return;
        }

        monitor.incProgress(1);

        if (xml != null) {
            monitor.setDescription("Parse XML");
            monitor.incProgress(1);
            parseStatsDocument(validatedDoc, validatedUri, monitor);
        }

        // done
        monitor.incProgress(1);
        closeStream(xml);
    }
 
源代码5 项目: javaide   文件: SdkStats.java
public void load(DownloadCache cache, boolean forceHttp, ITaskMonitor monitor) {

        String url = SdkStatsConstants.URL_STATS;

        if (forceHttp) {
            url = url.replaceAll("https://", "http://");  //$NON-NLS-1$ //$NON-NLS-2$
        }

        monitor.setProgressMax(5);
        monitor.setDescription("Fetching %1$s", url);
        monitor.incProgress(1);

        Exception[] exception = new Exception[] { null };
        Boolean[] validatorFound = new Boolean[] { Boolean.FALSE };
        String[] validationError = new String[] { null };
        Document validatedDoc = null;
        String validatedUri = null;

        InputStream xml = fetchXmlUrl(url, cache, monitor.createSubMonitor(1), exception);

        if (xml != null) {
            monitor.setDescription("Validate XML");

            // Explore the XML to find the potential XML schema version
            int version = getXmlSchemaVersion(xml);

            if (version >= 1 && version <= SdkStatsConstants.NS_LATEST_VERSION) {
                // This should be a version we can handle. Try to validate it
                // and report any error as invalid XML syntax,

                String uri = validateXml(xml, url, version, validationError, validatorFound);
                if (uri != null) {
                    // Validation was successful
                    validatedDoc = getDocument(xml, monitor);
                    validatedUri = uri;

                }
            } else if (version > SdkStatsConstants.NS_LATEST_VERSION) {
                // The schema used is more recent than what is supported by this tool.
                // We don't have an upgrade-path support yet, so simply ignore the document.
                closeStream(xml);
                return;
            }
        }

        // If any exception was handled during the URL fetch, display it now.
        if (exception[0] != null) {
            String reason = null;
            if (exception[0] instanceof FileNotFoundException) {
                // FNF has no useful getMessage, so we need to special handle it.
                reason = "File not found";
            } else if (exception[0] instanceof UnknownHostException &&
                    exception[0].getMessage() != null) {
                // This has no useful getMessage yet could really use one
                reason = String.format("Unknown Host %1$s", exception[0].getMessage());
            } else if (exception[0] instanceof SSLKeyException) {
                // That's a common error and we have a pref for it.
                reason = "HTTPS SSL error. You might want to force download through HTTP in the settings.";
            } else if (exception[0].getMessage() != null) {
                reason = exception[0].getMessage();
            } else {
                // We don't know what's wrong. Let's give the exception class at least.
                reason = String.format("Unknown (%1$s)", exception[0].getClass().getName());
            }

            monitor.logError("Failed to fetch URL %1$s, reason: %2$s", url, reason);
        }

        if (validationError[0] != null) {
            monitor.logError("%s", validationError[0]);  //$NON-NLS-1$
        }

        // Stop here if we failed to validate the XML. We don't want to load it.
        if (validatedDoc == null) {
            closeStream(xml);
            return;
        }

        monitor.incProgress(1);

        if (xml != null) {
            monitor.setDescription("Parse XML");
            monitor.incProgress(1);
            parseStatsDocument(validatedDoc, validatedUri, monitor);
        }

        // done
        monitor.incProgress(1);
        closeStream(xml);
    }
 
 类所在包