Example usage for java.security KeyManagementException toString

List of usage examples for java.security KeyManagementException toString

Introduction

In this page you can find the example usage for java.security KeyManagementException toString.

Prototype

public String toString() 

Source Link

Document

Returns a short description of this throwable.

Usage

From source file:br.com.ararati.operacoes.SocketFactory.java

private SSLContext createSSLContext() {
    try {/*from ww  w  .  j  ava 2s  . co m*/
        KeyManager[] keyManagers = createKeyManagers();
        TrustManager[] trustManagers = createTrustManagers();
        SSLContext sslContext = SSLContext.getInstance("TLS");
        sslContext.init(keyManagers, trustManagers, null);

        return sslContext;
    } catch (KeyManagementException e) {
        error(e.toString());
    } catch (KeyStoreException e) {
        error(e.toString());
    } catch (NoSuchAlgorithmException e) {
        error(e.toString());
    } catch (CertificateException e) {
        error(e.toString());
    } catch (IOException e) {
        error(e.toString());
    }
    return null;
}

From source file:com.vsct.dt.hesperides.feedback.FeedbacksAggregate.java

private CloseableHttpClient getHttpClient() {

    CloseableHttpClient httpClient;//from w w  w. ja  va2s.co m

    try {

        SSLContext sslContext = new SSLContextBuilder().loadTrustMaterial(null, (certificate, authType) -> true)
                .build();

        if (!this.proxyConfiguration.getProxyUrl().isEmpty()) {
            String proxyUrl = this.proxyConfiguration.getProxyUrl().split(":")[0];
            Integer proxyPort = Integer.valueOf(this.proxyConfiguration.getProxyUrl().split(":")[1]);

            HttpHost proxy = new HttpHost(proxyUrl, proxyPort);

            LOGGER.debug("Access with proxy : " + proxyUrl + ":" + proxyPort);
            httpClient = HttpClients.custom().setSSLContext(sslContext)
                    .setSSLHostnameVerifier(new NoopHostnameVerifier()).setProxy(proxy).build();
        } else {
            LOGGER.debug("Access without proxy");
            httpClient = HttpClients.custom().setSSLContext(sslContext)
                    .setSSLHostnameVerifier(new NoopHostnameVerifier()).build();
        }

    } catch (KeyManagementException e) {
        throw new RuntimeException("KeyManagementException :" + e.toString());
    } catch (NoSuchAlgorithmException e) {
        throw new RuntimeException("NoSuchAlgorithmException :" + e.toString());
    } catch (KeyStoreException e) {
        throw new RuntimeException("KeyStoreException :" + e.toString());
    }
    return httpClient;
}