org.apache.http.nio.conn.ManagedNHttpClientConnection Java Examples
The following examples show how to use
org.apache.http.nio.conn.ManagedNHttpClientConnection.
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: SiteToSiteRestApiClient.java From localization_nifi with Apache License 2.0 | 5 votes |
@Override public void process(final HttpResponse response, final HttpContext httpContext) throws HttpException, IOException { final HttpCoreContext coreContext = HttpCoreContext.adapt(httpContext); final HttpInetConnection conn = coreContext.getConnection(HttpInetConnection.class); if (!conn.isOpen()) { return; } final SSLSession sslSession; if (conn instanceof ManagedHttpClientConnection) { sslSession = ((ManagedHttpClientConnection) conn).getSSLSession(); } else if (conn instanceof ManagedNHttpClientConnection) { sslSession = ((ManagedNHttpClientConnection) conn).getSSLSession(); } else { throw new RuntimeException("Unexpected connection type was used, " + conn); } if (sslSession != null) { final Certificate[] certChain = sslSession.getPeerCertificates(); if (certChain == null || certChain.length == 0) { throw new SSLPeerUnverifiedException("No certificates found"); } try { final X509Certificate cert = CertificateUtils.convertAbstractX509Certificate(certChain[0]); trustedPeerDn = cert.getSubjectDN().getName().trim(); } catch (final CertificateException e) { final String msg = "Could not extract subject DN from SSL session peer certificate"; logger.warn(msg); eventReporter.reportEvent(Severity.WARNING, EVENT_CATEGORY, msg); throw new SSLPeerUnverifiedException(msg); } } }
Example #2
Source File: SiteToSiteRestApiClient.java From nifi with Apache License 2.0 | 5 votes |
@Override public void process(final HttpResponse response, final HttpContext httpContext) throws HttpException, IOException { final HttpCoreContext coreContext = HttpCoreContext.adapt(httpContext); final HttpInetConnection conn = coreContext.getConnection(HttpInetConnection.class); if (!conn.isOpen()) { return; } final SSLSession sslSession; if (conn instanceof ManagedHttpClientConnection) { sslSession = ((ManagedHttpClientConnection) conn).getSSLSession(); } else if (conn instanceof ManagedNHttpClientConnection) { sslSession = ((ManagedNHttpClientConnection) conn).getSSLSession(); } else { throw new RuntimeException("Unexpected connection type was used, " + conn); } if (sslSession != null) { final Certificate[] certChain = sslSession.getPeerCertificates(); if (certChain == null || certChain.length == 0) { throw new SSLPeerUnverifiedException("No certificates found"); } try { final X509Certificate cert = CertificateUtils.convertAbstractX509Certificate(certChain[0]); trustedPeerDn = cert.getSubjectDN().getName().trim(); } catch (final CertificateException e) { final String msg = "Could not extract subject DN from SSL session peer certificate"; logger.warn(msg); eventReporter.reportEvent(Severity.WARNING, EVENT_CATEGORY, msg); throw new SSLPeerUnverifiedException(msg); } } }