You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@hc.apache.org by ol...@apache.org on 2016/12/13 19:27:31 UTC
svn commit: r1774083 - in /httpcomponents/httpcore/trunk:
httpcore5-h2/src/main/java/org/apache/hc/core5/http2/impl/nio/
httpcore5-h2/src/main/java/org/apache/hc/core5/http2/ssl/
httpcore5-testing/src/main/java/org/apache/hc/core5/testing/nio/ httpcore...
Author: olegk
Date: Tue Dec 13 19:27:31 2016
New Revision: 1774083
URL: http://svn.apache.org/viewvc?rev=1774083&view=rev
Log:
HTTP/1.1 connections to provide an optional interface to upgrade their transport security and communication protocol
Added:
httpcomponents/httpcore/trunk/httpcore5/src/main/java/org/apache/hc/core5/http/impl/nio/UpgradeableHttpConnection.java
- copied, changed from r1774082, httpcomponents/httpcore/trunk/httpcore5/src/main/java/org/apache/hc/core5/reactor/ssl/TlsCapable.java
httpcomponents/httpcore/trunk/httpcore5/src/main/java/org/apache/hc/core5/http/nio/HttpContextAware.java
- copied, changed from r1774082, httpcomponents/httpcore/trunk/httpcore5/src/main/java/org/apache/hc/core5/reactor/ssl/TlsCapable.java
httpcomponents/httpcore/trunk/httpcore5/src/main/java/org/apache/hc/core5/reactor/ssl/TransportSecurityLayer.java (contents, props changed)
- copied, changed from r1774082, httpcomponents/httpcore/trunk/httpcore5/src/main/java/org/apache/hc/core5/reactor/ssl/TlsCapable.java
Removed:
httpcomponents/httpcore/trunk/httpcore5/src/main/java/org/apache/hc/core5/reactor/ssl/TlsCapable.java
Modified:
httpcomponents/httpcore/trunk/httpcore5-h2/src/main/java/org/apache/hc/core5/http2/impl/nio/ClientHttp2StreamHandler.java
httpcomponents/httpcore/trunk/httpcore5-h2/src/main/java/org/apache/hc/core5/http2/impl/nio/ClientPushHttp2StreamHandler.java
httpcomponents/httpcore/trunk/httpcore5-h2/src/main/java/org/apache/hc/core5/http2/impl/nio/ServerHttp2StreamHandler.java
httpcomponents/httpcore/trunk/httpcore5-h2/src/main/java/org/apache/hc/core5/http2/impl/nio/ServerHttpProtocolNegotiatorFactory.java
httpcomponents/httpcore/trunk/httpcore5-h2/src/main/java/org/apache/hc/core5/http2/ssl/H2ClientTlsStrategy.java
httpcomponents/httpcore/trunk/httpcore5-h2/src/main/java/org/apache/hc/core5/http2/ssl/H2ServerTlsStrategy.java
httpcomponents/httpcore/trunk/httpcore5-testing/src/main/java/org/apache/hc/core5/testing/nio/LoggingIOSession.java
httpcomponents/httpcore/trunk/httpcore5-testing/src/main/java/org/apache/hc/core5/testing/nio/http/InternalClientHttp1EventHandlerFactory.java
httpcomponents/httpcore/trunk/httpcore5-testing/src/main/java/org/apache/hc/core5/testing/nio/http/InternalServerHttp1EventHandlerFactory.java
httpcomponents/httpcore/trunk/httpcore5-testing/src/main/java/org/apache/hc/core5/testing/nio/http2/InternalClientHttp2EventHandlerFactory.java
httpcomponents/httpcore/trunk/httpcore5-testing/src/main/java/org/apache/hc/core5/testing/nio/http2/InternalServerHttp2EventHandlerFactory.java
httpcomponents/httpcore/trunk/httpcore5-testing/src/test/java/org/apache/hc/core5/testing/nio/http/EchoHandler.java
httpcomponents/httpcore/trunk/httpcore5-testing/src/test/java/org/apache/hc/core5/testing/nio/http/Http1IntegrationTest.java
httpcomponents/httpcore/trunk/httpcore5-testing/src/test/java/org/apache/hc/core5/testing/nio/http2/Http2IntegrationTest.java
httpcomponents/httpcore/trunk/httpcore5/src/examples/org/apache/hc/core5/http/examples/AsyncReverseProxyExample.java
httpcomponents/httpcore/trunk/httpcore5/src/main/java/org/apache/hc/core5/http/impl/nio/AbstractClassicServerExchangeHandler.java
httpcomponents/httpcore/trunk/httpcore5/src/main/java/org/apache/hc/core5/http/impl/nio/AbstractHttp1StreamDuplexer.java
httpcomponents/httpcore/trunk/httpcore5/src/main/java/org/apache/hc/core5/http/impl/nio/ClientHttp1StreamHandler.java
httpcomponents/httpcore/trunk/httpcore5/src/main/java/org/apache/hc/core5/http/impl/nio/ServerHttp1IOEventHandlerFactory.java
httpcomponents/httpcore/trunk/httpcore5/src/main/java/org/apache/hc/core5/http/impl/nio/ServerHttp1StreamHandler.java
httpcomponents/httpcore/trunk/httpcore5/src/main/java/org/apache/hc/core5/http/impl/nio/bootstrap/HttpAsyncRequester.java
httpcomponents/httpcore/trunk/httpcore5/src/main/java/org/apache/hc/core5/http/nio/AsyncServerExchangeHandler.java
httpcomponents/httpcore/trunk/httpcore5/src/main/java/org/apache/hc/core5/http/nio/ssl/BasicClientTlsStrategy.java
httpcomponents/httpcore/trunk/httpcore5/src/main/java/org/apache/hc/core5/http/nio/ssl/BasicServerTlsStrategy.java
httpcomponents/httpcore/trunk/httpcore5/src/main/java/org/apache/hc/core5/http/nio/ssl/TlsStrategy.java
httpcomponents/httpcore/trunk/httpcore5/src/main/java/org/apache/hc/core5/http/nio/support/AbstractServerExchangeHandler.java
httpcomponents/httpcore/trunk/httpcore5/src/main/java/org/apache/hc/core5/http/nio/support/ImmediateResponseExchangeHandler.java
httpcomponents/httpcore/trunk/httpcore5/src/main/java/org/apache/hc/core5/reactor/ManagedIOSession.java
Modified: httpcomponents/httpcore/trunk/httpcore5-h2/src/main/java/org/apache/hc/core5/http2/impl/nio/ClientHttp2StreamHandler.java
URL: http://svn.apache.org/viewvc/httpcomponents/httpcore/trunk/httpcore5-h2/src/main/java/org/apache/hc/core5/http2/impl/nio/ClientHttp2StreamHandler.java?rev=1774083&r1=1774082&r2=1774083&view=diff
==============================================================================
--- httpcomponents/httpcore/trunk/httpcore5-h2/src/main/java/org/apache/hc/core5/http2/impl/nio/ClientHttp2StreamHandler.java (original)
+++ httpcomponents/httpcore/trunk/httpcore5-h2/src/main/java/org/apache/hc/core5/http2/impl/nio/ClientHttp2StreamHandler.java Tue Dec 13 19:27:31 2016
@@ -45,6 +45,7 @@ import org.apache.hc.core5.http.impl.Bas
import org.apache.hc.core5.http.impl.LazyEntityDetails;
import org.apache.hc.core5.http.impl.nio.MessageState;
import org.apache.hc.core5.http.nio.AsyncClientExchangeHandler;
+import org.apache.hc.core5.http.nio.HttpContextAware;
import org.apache.hc.core5.http.nio.DataStreamChannel;
import org.apache.hc.core5.http.nio.RequestChannel;
import org.apache.hc.core5.http.protocol.HttpContext;
@@ -131,6 +132,11 @@ class ClientHttp2StreamHandler implement
context.setProtocolVersion(HttpVersion.HTTP_2);
context.setAttribute(HttpCoreContext.HTTP_REQUEST, request);
context.setAttribute(HttpCoreContext.HTTP_CONNECTION, connection);
+
+ if (exchangeHandler instanceof HttpContextAware) {
+ ((HttpContextAware) exchangeHandler).setContext(context);
+ }
+
httpProcessor.process(request, entityDetails, context);
connMetrics.incrementRequestCount();
Modified: httpcomponents/httpcore/trunk/httpcore5-h2/src/main/java/org/apache/hc/core5/http2/impl/nio/ClientPushHttp2StreamHandler.java
URL: http://svn.apache.org/viewvc/httpcomponents/httpcore/trunk/httpcore5-h2/src/main/java/org/apache/hc/core5/http2/impl/nio/ClientPushHttp2StreamHandler.java?rev=1774083&r1=1774082&r2=1774083&view=diff
==============================================================================
--- httpcomponents/httpcore/trunk/httpcore5-h2/src/main/java/org/apache/hc/core5/http2/impl/nio/ClientPushHttp2StreamHandler.java (original)
+++ httpcomponents/httpcore/trunk/httpcore5-h2/src/main/java/org/apache/hc/core5/http2/impl/nio/ClientPushHttp2StreamHandler.java Tue Dec 13 19:27:31 2016
@@ -42,6 +42,7 @@ import org.apache.hc.core5.http.Protocol
import org.apache.hc.core5.http.impl.BasicHttpConnectionMetrics;
import org.apache.hc.core5.http.impl.LazyEntityDetails;
import org.apache.hc.core5.http.impl.nio.MessageState;
+import org.apache.hc.core5.http.nio.HttpContextAware;
import org.apache.hc.core5.http.nio.AsyncPushConsumer;
import org.apache.hc.core5.http.nio.HandlerFactory;
import org.apache.hc.core5.http.protocol.HttpCoreContext;
@@ -114,6 +115,11 @@ class ClientPushHttp2StreamHandler imple
context.setProtocolVersion(HttpVersion.HTTP_2);
context.setAttribute(HttpCoreContext.HTTP_REQUEST, request);
context.setAttribute(HttpCoreContext.HTTP_CONNECTION, connection);
+
+ if (exchangeHandler instanceof HttpContextAware) {
+ ((HttpContextAware) exchangeHandler).setContext(context);
+ }
+
httpProcessor.process(request, null, context);
connMetrics.incrementRequestCount();
Modified: httpcomponents/httpcore/trunk/httpcore5-h2/src/main/java/org/apache/hc/core5/http2/impl/nio/ServerHttp2StreamHandler.java
URL: http://svn.apache.org/viewvc/httpcomponents/httpcore/trunk/httpcore5-h2/src/main/java/org/apache/hc/core5/http2/impl/nio/ServerHttp2StreamHandler.java?rev=1774083&r1=1774082&r2=1774083&view=diff
==============================================================================
--- httpcomponents/httpcore/trunk/httpcore5-h2/src/main/java/org/apache/hc/core5/http2/impl/nio/ServerHttp2StreamHandler.java (original)
+++ httpcomponents/httpcore/trunk/httpcore5-h2/src/main/java/org/apache/hc/core5/http2/impl/nio/ServerHttp2StreamHandler.java Tue Dec 13 19:27:31 2016
@@ -43,6 +43,7 @@ import org.apache.hc.core5.http.Protocol
import org.apache.hc.core5.http.impl.BasicHttpConnectionMetrics;
import org.apache.hc.core5.http.impl.LazyEntityDetails;
import org.apache.hc.core5.http.impl.nio.MessageState;
+import org.apache.hc.core5.http.nio.HttpContextAware;
import org.apache.hc.core5.http.nio.AsyncPushProducer;
import org.apache.hc.core5.http.nio.AsyncServerExchangeHandler;
import org.apache.hc.core5.http.nio.DataStreamChannel;
@@ -197,7 +198,10 @@ public class ServerHttp2StreamHandler im
context.setProtocolVersion(HttpVersion.HTTP_2);
context.setAttribute(HttpCoreContext.HTTP_REQUEST, request);
context.setAttribute(HttpCoreContext.HTTP_CONNECTION, connection);
- exchangeHandler.setContext(context);
+
+ if (exchangeHandler instanceof HttpContextAware) {
+ ((HttpContextAware) exchangeHandler).setContext(context);
+ }
httpProcessor.process(request, requestEntityDetails, context);
connMetrics.incrementRequestCount();
Modified: httpcomponents/httpcore/trunk/httpcore5-h2/src/main/java/org/apache/hc/core5/http2/impl/nio/ServerHttpProtocolNegotiatorFactory.java
URL: http://svn.apache.org/viewvc/httpcomponents/httpcore/trunk/httpcore5-h2/src/main/java/org/apache/hc/core5/http2/impl/nio/ServerHttpProtocolNegotiatorFactory.java?rev=1774083&r1=1774082&r2=1774083&view=diff
==============================================================================
--- httpcomponents/httpcore/trunk/httpcore5-h2/src/main/java/org/apache/hc/core5/http2/impl/nio/ServerHttpProtocolNegotiatorFactory.java (original)
+++ httpcomponents/httpcore/trunk/httpcore5-h2/src/main/java/org/apache/hc/core5/http2/impl/nio/ServerHttpProtocolNegotiatorFactory.java Tue Dec 13 19:27:31 2016
@@ -40,7 +40,7 @@ import org.apache.hc.core5.http.protocol
import org.apache.hc.core5.http2.config.H2Config;
import org.apache.hc.core5.reactor.IOEventHandlerFactory;
import org.apache.hc.core5.reactor.IOSession;
-import org.apache.hc.core5.reactor.ssl.TlsCapable;
+import org.apache.hc.core5.reactor.ssl.TransportSecurityLayer;
import org.apache.hc.core5.util.Args;
/**
@@ -85,9 +85,9 @@ public class ServerHttpProtocolNegotiato
@Override
public ServerHttpProtocolNegotiator createHandler(final IOSession ioSession) {
- if (tlsStrategy != null && ioSession instanceof TlsCapable) {
+ if (tlsStrategy != null && ioSession instanceof TransportSecurityLayer) {
tlsStrategy.upgrade(
- (TlsCapable) ioSession,
+ (TransportSecurityLayer) ioSession,
null,
ioSession.getLocalAddress(),
ioSession.getRemoteAddress());
Modified: httpcomponents/httpcore/trunk/httpcore5-h2/src/main/java/org/apache/hc/core5/http2/ssl/H2ClientTlsStrategy.java
URL: http://svn.apache.org/viewvc/httpcomponents/httpcore/trunk/httpcore5-h2/src/main/java/org/apache/hc/core5/http2/ssl/H2ClientTlsStrategy.java?rev=1774083&r1=1774082&r2=1774083&view=diff
==============================================================================
--- httpcomponents/httpcore/trunk/httpcore5-h2/src/main/java/org/apache/hc/core5/http2/ssl/H2ClientTlsStrategy.java (original)
+++ httpcomponents/httpcore/trunk/httpcore5-h2/src/main/java/org/apache/hc/core5/http2/ssl/H2ClientTlsStrategy.java Tue Dec 13 19:27:31 2016
@@ -35,7 +35,7 @@ import org.apache.hc.core5.http.nio.ssl.
import org.apache.hc.core5.reactor.ssl.SSLBufferManagement;
import org.apache.hc.core5.reactor.ssl.SSLSessionInitializer;
import org.apache.hc.core5.reactor.ssl.SSLSessionVerifier;
-import org.apache.hc.core5.reactor.ssl.TlsCapable;
+import org.apache.hc.core5.reactor.ssl.TransportSecurityLayer;
import org.apache.hc.core5.ssl.SSLContexts;
import org.apache.hc.core5.util.Args;
@@ -86,13 +86,13 @@ public class H2ClientTlsStrategy impleme
@Override
public void upgrade(
- final TlsCapable tlsCapable,
+ final TransportSecurityLayer tlsSession,
final String scheme,
final SocketAddress localAddress,
final SocketAddress remoteAddress,
final String... parameters) {
if ("https".equalsIgnoreCase(scheme)) {
- tlsCapable.startTls(sslContext, sslBufferManagement,
+ tlsSession.start(sslContext, sslBufferManagement,
H2TlsSupport.decorateInitializer(initializer), verifier);
}
}
Modified: httpcomponents/httpcore/trunk/httpcore5-h2/src/main/java/org/apache/hc/core5/http2/ssl/H2ServerTlsStrategy.java
URL: http://svn.apache.org/viewvc/httpcomponents/httpcore/trunk/httpcore5-h2/src/main/java/org/apache/hc/core5/http2/ssl/H2ServerTlsStrategy.java?rev=1774083&r1=1774082&r2=1774083&view=diff
==============================================================================
--- httpcomponents/httpcore/trunk/httpcore5-h2/src/main/java/org/apache/hc/core5/http2/ssl/H2ServerTlsStrategy.java (original)
+++ httpcomponents/httpcore/trunk/httpcore5-h2/src/main/java/org/apache/hc/core5/http2/ssl/H2ServerTlsStrategy.java Tue Dec 13 19:27:31 2016
@@ -36,7 +36,7 @@ import org.apache.hc.core5.http.nio.ssl.
import org.apache.hc.core5.reactor.ssl.SSLBufferManagement;
import org.apache.hc.core5.reactor.ssl.SSLSessionInitializer;
import org.apache.hc.core5.reactor.ssl.SSLSessionVerifier;
-import org.apache.hc.core5.reactor.ssl.TlsCapable;
+import org.apache.hc.core5.reactor.ssl.TransportSecurityLayer;
import org.apache.hc.core5.ssl.SSLContexts;
import org.apache.hc.core5.util.Args;
@@ -92,7 +92,7 @@ public class H2ServerTlsStrategy impleme
@Override
public void upgrade(
- final TlsCapable tlsCapable,
+ final TransportSecurityLayer tlsSession,
final String scheme,
final SocketAddress localAddress,
final SocketAddress remoteAddress,
@@ -100,7 +100,7 @@ public class H2ServerTlsStrategy impleme
final int port = ((InetSocketAddress) localAddress).getPort();
for (int securePort: securePorts) {
if (port == securePort) {
- tlsCapable.startTls(sslContext, sslBufferManagement,
+ tlsSession.start(sslContext, sslBufferManagement,
H2TlsSupport.decorateInitializer(initializer), verifier);
break;
}
Modified: httpcomponents/httpcore/trunk/httpcore5-testing/src/main/java/org/apache/hc/core5/testing/nio/LoggingIOSession.java
URL: http://svn.apache.org/viewvc/httpcomponents/httpcore/trunk/httpcore5-testing/src/main/java/org/apache/hc/core5/testing/nio/LoggingIOSession.java?rev=1774083&r1=1774082&r2=1774083&view=diff
==============================================================================
--- httpcomponents/httpcore/trunk/httpcore5-testing/src/main/java/org/apache/hc/core5/testing/nio/LoggingIOSession.java (original)
+++ httpcomponents/httpcore/trunk/httpcore5-testing/src/main/java/org/apache/hc/core5/testing/nio/LoggingIOSession.java Tue Dec 13 19:27:31 2016
@@ -34,6 +34,7 @@ import java.nio.channels.ByteChannel;
import java.nio.channels.SelectionKey;
import javax.net.ssl.SSLContext;
+import javax.net.ssl.SSLSession;
import org.apache.hc.core5.reactor.Command;
import org.apache.hc.core5.reactor.IOEventHandler;
@@ -41,10 +42,10 @@ import org.apache.hc.core5.reactor.IOSes
import org.apache.hc.core5.reactor.ssl.SSLBufferManagement;
import org.apache.hc.core5.reactor.ssl.SSLSessionInitializer;
import org.apache.hc.core5.reactor.ssl.SSLSessionVerifier;
-import org.apache.hc.core5.reactor.ssl.TlsCapable;
+import org.apache.hc.core5.reactor.ssl.TransportSecurityLayer;
import org.apache.hc.core5.testing.classic.Wire;
import org.apache.logging.log4j.Logger;
-public class LoggingIOSession implements IOSession, TlsCapable {
+public class LoggingIOSession implements IOSession, TransportSecurityLayer {
private final Logger log;
private final Wire wirelog;
@@ -193,24 +194,24 @@ public class LoggingIOSession implements
}
@Override
- public void startTls(
+ public void start(
final SSLContext sslContext,
final SSLBufferManagement sslBufferManagement,
final SSLSessionInitializer initializer,
final SSLSessionVerifier verifier) throws UnsupportedOperationException {
- if (session instanceof TlsCapable) {
- ((TlsCapable) session).startTls(sslContext, sslBufferManagement, initializer, verifier);
+ if (session instanceof TransportSecurityLayer) {
+ ((TransportSecurityLayer) session).start(sslContext, sslBufferManagement, initializer, verifier);
} else {
throw new UnsupportedOperationException();
}
}
@Override
- public boolean isTlsActive() {
- if (session instanceof TlsCapable) {
- return ((TlsCapable) session).isTlsActive();
+ public SSLSession getSSLSession() {
+ if (session instanceof TransportSecurityLayer) {
+ return ((TransportSecurityLayer) session).getSSLSession();
} else {
- return false;
+ return null;
}
}
Modified: httpcomponents/httpcore/trunk/httpcore5-testing/src/main/java/org/apache/hc/core5/testing/nio/http/InternalClientHttp1EventHandlerFactory.java
URL: http://svn.apache.org/viewvc/httpcomponents/httpcore/trunk/httpcore5-testing/src/main/java/org/apache/hc/core5/testing/nio/http/InternalClientHttp1EventHandlerFactory.java?rev=1774083&r1=1774082&r2=1774083&view=diff
==============================================================================
--- httpcomponents/httpcore/trunk/httpcore5-testing/src/main/java/org/apache/hc/core5/testing/nio/http/InternalClientHttp1EventHandlerFactory.java (original)
+++ httpcomponents/httpcore/trunk/httpcore5-testing/src/main/java/org/apache/hc/core5/testing/nio/http/InternalClientHttp1EventHandlerFactory.java Tue Dec 13 19:27:31 2016
@@ -59,7 +59,7 @@ import org.apache.hc.core5.http.protocol
import org.apache.hc.core5.reactor.IOEventHandler;
import org.apache.hc.core5.reactor.IOEventHandlerFactory;
import org.apache.hc.core5.reactor.IOSession;
-import org.apache.hc.core5.reactor.ssl.TlsCapable;
+import org.apache.hc.core5.reactor.ssl.TransportSecurityLayer;
import org.apache.hc.core5.testing.nio.LoggingIOEventHandler;
import org.apache.hc.core5.testing.nio.LoggingIOSession;
import org.apache.hc.core5.util.Args;
@@ -115,8 +115,8 @@ class InternalClientHttp1EventHandlerFac
@Override
public IOEventHandler createHandler(final IOSession ioSession) {
final String id = "http1-outgoing-" + COUNT.incrementAndGet();
- if (sslContext != null && ioSession instanceof TlsCapable) {
- ((TlsCapable) ioSession).startTls(sslContext, null ,null, null);
+ if (sslContext != null && ioSession instanceof TransportSecurityLayer) {
+ ((TransportSecurityLayer) ioSession).start(sslContext, null ,null, null);
}
final Logger sessionLog = LogManager.getLogger(ioSession.getClass());
final Logger wireLog = LogManager.getLogger("org.apache.hc.core5.http.wire");
Modified: httpcomponents/httpcore/trunk/httpcore5-testing/src/main/java/org/apache/hc/core5/testing/nio/http/InternalServerHttp1EventHandlerFactory.java
URL: http://svn.apache.org/viewvc/httpcomponents/httpcore/trunk/httpcore5-testing/src/main/java/org/apache/hc/core5/testing/nio/http/InternalServerHttp1EventHandlerFactory.java?rev=1774083&r1=1774082&r2=1774083&view=diff
==============================================================================
--- httpcomponents/httpcore/trunk/httpcore5-testing/src/main/java/org/apache/hc/core5/testing/nio/http/InternalServerHttp1EventHandlerFactory.java (original)
+++ httpcomponents/httpcore/trunk/httpcore5-testing/src/main/java/org/apache/hc/core5/testing/nio/http/InternalServerHttp1EventHandlerFactory.java Tue Dec 13 19:27:31 2016
@@ -61,7 +61,7 @@ import org.apache.hc.core5.http.protocol
import org.apache.hc.core5.reactor.IOEventHandler;
import org.apache.hc.core5.reactor.IOEventHandlerFactory;
import org.apache.hc.core5.reactor.IOSession;
-import org.apache.hc.core5.reactor.ssl.TlsCapable;
+import org.apache.hc.core5.reactor.ssl.TransportSecurityLayer;
import org.apache.hc.core5.testing.nio.LoggingIOEventHandler;
import org.apache.hc.core5.testing.nio.LoggingIOSession;
import org.apache.hc.core5.util.Args;
@@ -121,8 +121,8 @@ class InternalServerHttp1EventHandlerFac
@Override
public IOEventHandler createHandler(final IOSession ioSession) {
final String id = "http1-incoming-" + COUNT.incrementAndGet();
- if (sslContext != null && ioSession instanceof TlsCapable) {
- ((TlsCapable) ioSession).startTls(sslContext, null ,null, null);
+ if (sslContext != null && ioSession instanceof TransportSecurityLayer) {
+ ((TransportSecurityLayer) ioSession).start(sslContext, null ,null, null);
}
final Logger sessionLog = LogManager.getLogger(ioSession.getClass());
final Logger wireLog = LogManager.getLogger("org.apache.hc.core5.http.wire");
Modified: httpcomponents/httpcore/trunk/httpcore5-testing/src/main/java/org/apache/hc/core5/testing/nio/http2/InternalClientHttp2EventHandlerFactory.java
URL: http://svn.apache.org/viewvc/httpcomponents/httpcore/trunk/httpcore5-testing/src/main/java/org/apache/hc/core5/testing/nio/http2/InternalClientHttp2EventHandlerFactory.java?rev=1774083&r1=1774082&r2=1774083&view=diff
==============================================================================
--- httpcomponents/httpcore/trunk/httpcore5-testing/src/main/java/org/apache/hc/core5/testing/nio/http2/InternalClientHttp2EventHandlerFactory.java (original)
+++ httpcomponents/httpcore/trunk/httpcore5-testing/src/main/java/org/apache/hc/core5/testing/nio/http2/InternalClientHttp2EventHandlerFactory.java Tue Dec 13 19:27:31 2016
@@ -44,7 +44,7 @@ import org.apache.hc.core5.http2.impl.ni
import org.apache.hc.core5.reactor.IOEventHandler;
import org.apache.hc.core5.reactor.IOEventHandlerFactory;
import org.apache.hc.core5.reactor.IOSession;
-import org.apache.hc.core5.reactor.ssl.TlsCapable;
+import org.apache.hc.core5.reactor.ssl.TransportSecurityLayer;
import org.apache.hc.core5.testing.nio.LoggingIOEventHandler;
import org.apache.hc.core5.testing.nio.LoggingIOSession;
import org.apache.hc.core5.util.Args;
@@ -77,8 +77,8 @@ class InternalClientHttp2EventHandlerFac
@Override
public IOEventHandler createHandler(final IOSession ioSession) {
final String id = "http2-outgoing-" + COUNT.incrementAndGet();
- if (sslContext != null && ioSession instanceof TlsCapable) {
- ((TlsCapable) ioSession).startTls(sslContext, null ,null, null);
+ if (sslContext != null && ioSession instanceof TransportSecurityLayer) {
+ ((TransportSecurityLayer) ioSession).start(sslContext, null ,null, null);
}
final Logger sessionLog = LogManager.getLogger(ioSession.getClass());
return new LoggingIOEventHandler(new ClientHttpProtocolNegotiator(
Modified: httpcomponents/httpcore/trunk/httpcore5-testing/src/main/java/org/apache/hc/core5/testing/nio/http2/InternalServerHttp2EventHandlerFactory.java
URL: http://svn.apache.org/viewvc/httpcomponents/httpcore/trunk/httpcore5-testing/src/main/java/org/apache/hc/core5/testing/nio/http2/InternalServerHttp2EventHandlerFactory.java?rev=1774083&r1=1774082&r2=1774083&view=diff
==============================================================================
--- httpcomponents/httpcore/trunk/httpcore5-testing/src/main/java/org/apache/hc/core5/testing/nio/http2/InternalServerHttp2EventHandlerFactory.java (original)
+++ httpcomponents/httpcore/trunk/httpcore5-testing/src/main/java/org/apache/hc/core5/testing/nio/http2/InternalServerHttp2EventHandlerFactory.java Tue Dec 13 19:27:31 2016
@@ -44,7 +44,7 @@ import org.apache.hc.core5.http2.impl.ni
import org.apache.hc.core5.reactor.IOEventHandler;
import org.apache.hc.core5.reactor.IOEventHandlerFactory;
import org.apache.hc.core5.reactor.IOSession;
-import org.apache.hc.core5.reactor.ssl.TlsCapable;
+import org.apache.hc.core5.reactor.ssl.TransportSecurityLayer;
import org.apache.hc.core5.testing.nio.LoggingIOEventHandler;
import org.apache.hc.core5.testing.nio.LoggingIOSession;
import org.apache.hc.core5.util.Args;
@@ -77,8 +77,8 @@ class InternalServerHttp2EventHandlerFac
@Override
public IOEventHandler createHandler(final IOSession ioSession) {
final String id = "http2-incoming-" + COUNT.incrementAndGet();
- if (sslContext != null && ioSession instanceof TlsCapable) {
- ((TlsCapable) ioSession).startTls(sslContext, null ,null, null);
+ if (sslContext != null && ioSession instanceof TransportSecurityLayer) {
+ ((TransportSecurityLayer) ioSession).start(sslContext, null ,null, null);
}
final Logger sessionLog = LogManager.getLogger(ioSession.getClass());
return new LoggingIOEventHandler(new ServerHttpProtocolNegotiator(
Modified: httpcomponents/httpcore/trunk/httpcore5-testing/src/test/java/org/apache/hc/core5/testing/nio/http/EchoHandler.java
URL: http://svn.apache.org/viewvc/httpcomponents/httpcore/trunk/httpcore5-testing/src/test/java/org/apache/hc/core5/testing/nio/http/EchoHandler.java?rev=1774083&r1=1774082&r2=1774083&view=diff
==============================================================================
--- httpcomponents/httpcore/trunk/httpcore5-testing/src/test/java/org/apache/hc/core5/testing/nio/http/EchoHandler.java (original)
+++ httpcomponents/httpcore/trunk/httpcore5-testing/src/test/java/org/apache/hc/core5/testing/nio/http/EchoHandler.java Tue Dec 13 19:27:31 2016
@@ -42,7 +42,6 @@ import org.apache.hc.core5.http.nio.Asyn
import org.apache.hc.core5.http.nio.CapacityChannel;
import org.apache.hc.core5.http.nio.DataStreamChannel;
import org.apache.hc.core5.http.nio.ResponseChannel;
-import org.apache.hc.core5.http.protocol.HttpContext;
public class EchoHandler implements AsyncServerExchangeHandler {
@@ -65,10 +64,6 @@ public class EchoHandler implements Asyn
}
@Override
- public void setContext(final HttpContext context) {
- }
-
- @Override
public void handleRequest(
final HttpRequest request,
final EntityDetails entityDetails,
Modified: httpcomponents/httpcore/trunk/httpcore5-testing/src/test/java/org/apache/hc/core5/testing/nio/http/Http1IntegrationTest.java
URL: http://svn.apache.org/viewvc/httpcomponents/httpcore/trunk/httpcore5-testing/src/test/java/org/apache/hc/core5/testing/nio/http/Http1IntegrationTest.java?rev=1774083&r1=1774082&r2=1774083&view=diff
==============================================================================
--- httpcomponents/httpcore/trunk/httpcore5-testing/src/test/java/org/apache/hc/core5/testing/nio/http/Http1IntegrationTest.java (original)
+++ httpcomponents/httpcore/trunk/httpcore5-testing/src/test/java/org/apache/hc/core5/testing/nio/http/Http1IntegrationTest.java Tue Dec 13 19:27:31 2016
@@ -58,6 +58,7 @@ import java.util.concurrent.Future;
import java.util.concurrent.TimeUnit;
import java.util.concurrent.atomic.AtomicReference;
+import org.apache.hc.core5.function.Supplier;
import org.apache.hc.core5.http.ConnectionReuseStrategy;
import org.apache.hc.core5.http.ContentLengthStrategy;
import org.apache.hc.core5.http.ContentType;
@@ -73,7 +74,6 @@ import org.apache.hc.core5.http.HttpStat
import org.apache.hc.core5.http.HttpVersion;
import org.apache.hc.core5.http.MalformedChunkCodingException;
import org.apache.hc.core5.http.Message;
-import org.apache.hc.core5.function.Supplier;
import org.apache.hc.core5.http.config.ConnectionConfig;
import org.apache.hc.core5.http.config.H1Config;
import org.apache.hc.core5.http.impl.BasicHttpTransportMetrics;
@@ -83,8 +83,8 @@ import org.apache.hc.core5.http.impl.Htt
import org.apache.hc.core5.http.impl.HttpProcessors;
import org.apache.hc.core5.http.impl.nio.AbstractClassicServerExchangeHandler;
import org.apache.hc.core5.http.impl.nio.AbstractContentEncoder;
-import org.apache.hc.core5.http.impl.nio.bootstrap.ClientEndpoint;
import org.apache.hc.core5.http.impl.nio.ServerHttp1StreamDuplexer;
+import org.apache.hc.core5.http.impl.nio.bootstrap.ClientEndpoint;
import org.apache.hc.core5.http.impl.nio.entity.AbstractClassicEntityConsumer;
import org.apache.hc.core5.http.impl.nio.entity.AbstractClassicEntityProducer;
import org.apache.hc.core5.http.message.BasicHttpRequest;
@@ -787,10 +787,6 @@ public class Http1IntegrationTest extend
"All is well");
@Override
- public void setContext(final HttpContext context) {
- }
-
- @Override
public void handleRequest(
final HttpRequest request,
final EntityDetails entityDetails,
@@ -892,10 +888,6 @@ public class Http1IntegrationTest extend
private final AtomicReference<AsyncResponseProducer> responseProducer = new AtomicReference<>(null);
@Override
- public void setContext(final HttpContext context) {
- }
-
- @Override
public void handleRequest(
final HttpRequest request,
final EntityDetails entityDetails,
Modified: httpcomponents/httpcore/trunk/httpcore5-testing/src/test/java/org/apache/hc/core5/testing/nio/http2/Http2IntegrationTest.java
URL: http://svn.apache.org/viewvc/httpcomponents/httpcore/trunk/httpcore5-testing/src/test/java/org/apache/hc/core5/testing/nio/http2/Http2IntegrationTest.java?rev=1774083&r1=1774082&r2=1774083&view=diff
==============================================================================
--- httpcomponents/httpcore/trunk/httpcore5-testing/src/test/java/org/apache/hc/core5/testing/nio/http2/Http2IntegrationTest.java (original)
+++ httpcomponents/httpcore/trunk/httpcore5-testing/src/test/java/org/apache/hc/core5/testing/nio/http2/Http2IntegrationTest.java Tue Dec 13 19:27:31 2016
@@ -780,10 +780,6 @@ public class Http2IntegrationTest extend
private final AtomicReference<AsyncResponseProducer> responseProducer = new AtomicReference<>(null);
@Override
- public void setContext(final HttpContext context) {
- }
-
- @Override
public void updateCapacity(final CapacityChannel capacityChannel) throws IOException {
capacityChannel.update(Integer.MAX_VALUE);
}
Modified: httpcomponents/httpcore/trunk/httpcore5/src/examples/org/apache/hc/core5/http/examples/AsyncReverseProxyExample.java
URL: http://svn.apache.org/viewvc/httpcomponents/httpcore/trunk/httpcore5/src/examples/org/apache/hc/core5/http/examples/AsyncReverseProxyExample.java?rev=1774083&r1=1774082&r2=1774083&view=diff
==============================================================================
--- httpcomponents/httpcore/trunk/httpcore5/src/examples/org/apache/hc/core5/http/examples/AsyncReverseProxyExample.java (original)
+++ httpcomponents/httpcore/trunk/httpcore5/src/examples/org/apache/hc/core5/http/examples/AsyncReverseProxyExample.java Tue Dec 13 19:27:31 2016
@@ -74,7 +74,6 @@ import org.apache.hc.core5.http.nio.Capa
import org.apache.hc.core5.http.nio.DataStreamChannel;
import org.apache.hc.core5.http.nio.RequestChannel;
import org.apache.hc.core5.http.nio.ResponseChannel;
-import org.apache.hc.core5.http.protocol.HttpContext;
import org.apache.hc.core5.pool.ConnPoolListener;
import org.apache.hc.core5.pool.ConnPoolStats;
import org.apache.hc.core5.pool.PoolStats;
@@ -291,10 +290,6 @@ public class AsyncReverseProxyExample {
}
@Override
- public void setContext(final HttpContext context) {
- }
-
- @Override
public void handleRequest(
final HttpRequest incomingRequest,
final EntityDetails entityDetails,
Modified: httpcomponents/httpcore/trunk/httpcore5/src/main/java/org/apache/hc/core5/http/impl/nio/AbstractClassicServerExchangeHandler.java
URL: http://svn.apache.org/viewvc/httpcomponents/httpcore/trunk/httpcore5/src/main/java/org/apache/hc/core5/http/impl/nio/AbstractClassicServerExchangeHandler.java?rev=1774083&r1=1774082&r2=1774083&view=diff
==============================================================================
--- httpcomponents/httpcore/trunk/httpcore5/src/main/java/org/apache/hc/core5/http/impl/nio/AbstractClassicServerExchangeHandler.java (original)
+++ httpcomponents/httpcore/trunk/httpcore5/src/main/java/org/apache/hc/core5/http/impl/nio/AbstractClassicServerExchangeHandler.java Tue Dec 13 19:27:31 2016
@@ -49,6 +49,7 @@ import org.apache.hc.core5.http.impl.nio
import org.apache.hc.core5.http.impl.nio.entity.SharedOutputBuffer;
import org.apache.hc.core5.http.message.BasicHttpResponse;
import org.apache.hc.core5.http.message.HttpResponseWrapper;
+import org.apache.hc.core5.http.nio.HttpContextAware;
import org.apache.hc.core5.http.nio.AsyncServerExchangeHandler;
import org.apache.hc.core5.http.nio.CapacityChannel;
import org.apache.hc.core5.http.nio.DataStreamChannel;
@@ -62,7 +63,7 @@ import org.apache.hc.core5.util.Asserts;
/**
* @since 5.0
*/
-public abstract class AbstractClassicServerExchangeHandler implements AsyncServerExchangeHandler {
+public abstract class AbstractClassicServerExchangeHandler implements HttpContextAware, AsyncServerExchangeHandler {
private enum State { IDLE, ACTIVE, COMPLETED }
Modified: httpcomponents/httpcore/trunk/httpcore5/src/main/java/org/apache/hc/core5/http/impl/nio/AbstractHttp1StreamDuplexer.java
URL: http://svn.apache.org/viewvc/httpcomponents/httpcore/trunk/httpcore5/src/main/java/org/apache/hc/core5/http/impl/nio/AbstractHttp1StreamDuplexer.java?rev=1774083&r1=1774082&r2=1774083&view=diff
==============================================================================
--- httpcomponents/httpcore/trunk/httpcore5/src/main/java/org/apache/hc/core5/http/impl/nio/AbstractHttp1StreamDuplexer.java (original)
+++ httpcomponents/httpcore/trunk/httpcore5/src/main/java/org/apache/hc/core5/http/impl/nio/AbstractHttp1StreamDuplexer.java Tue Dec 13 19:27:31 2016
@@ -41,10 +41,10 @@ import java.util.concurrent.locks.Lock;
import java.util.concurrent.locks.ReentrantLock;
import javax.net.ssl.SSLContext;
+import javax.net.ssl.SSLSession;
import org.apache.hc.core5.http.ConnectionClosedException;
import org.apache.hc.core5.http.Header;
-import org.apache.hc.core5.http.HttpConnection;
import org.apache.hc.core5.http.HttpConnectionMetrics;
import org.apache.hc.core5.http.HttpException;
import org.apache.hc.core5.http.HttpMessage;
@@ -69,15 +69,16 @@ import org.apache.hc.core5.http.nio.comm
import org.apache.hc.core5.net.InetAddressUtils;
import org.apache.hc.core5.reactor.Command;
import org.apache.hc.core5.reactor.EventMask;
+import org.apache.hc.core5.reactor.IOEventHandler;
import org.apache.hc.core5.reactor.IOSession;
import org.apache.hc.core5.reactor.ssl.SSLBufferManagement;
import org.apache.hc.core5.reactor.ssl.SSLSessionInitializer;
import org.apache.hc.core5.reactor.ssl.SSLSessionVerifier;
-import org.apache.hc.core5.reactor.ssl.TlsCapable;
+import org.apache.hc.core5.reactor.ssl.TransportSecurityLayer;
import org.apache.hc.core5.util.Args;
abstract class AbstractHttp1StreamDuplexer<IncomingMessage extends HttpMessage, OutgoingMessage extends HttpMessage>
- implements ResourceHolder, HttpConnection, TlsCapable {
+ implements ResourceHolder, UpgradeableHttpConnection {
private enum ConnectionState { READY, ACTIVE, GRACEFUL_SHUTDOWN, SHUTDOWN}
@@ -448,28 +449,6 @@ abstract class AbstractHttp1StreamDuplex
}
@Override
- public void startTls(
- final SSLContext sslContext,
- final SSLBufferManagement sslBufferManagement,
- final SSLSessionInitializer initializer,
- final SSLSessionVerifier verifier) throws UnsupportedOperationException {
- if (ioSession instanceof TlsCapable) {
- ((TlsCapable) ioSession).startTls(sslContext, sslBufferManagement, initializer, verifier);
- } else {
- throw new UnsupportedOperationException();
- }
- }
-
- @Override
- public boolean isTlsActive() {
- if (ioSession instanceof TlsCapable) {
- return ((TlsCapable) ioSession).isTlsActive();
- } else {
- return false;
- }
- }
-
- @Override
public void close() throws IOException {
ioSession.addFirst(new ShutdownCommand(ShutdownType.GRACEFUL));
}
@@ -515,6 +494,33 @@ abstract class AbstractHttp1StreamDuplex
}
@Override
+ public SSLSession getSSLSession() {
+ if (ioSession instanceof TransportSecurityLayer) {
+ return ((TransportSecurityLayer) ioSession).getSSLSession();
+ } else {
+ return null;
+ }
+ }
+
+ @Override
+ public void start(
+ final SSLContext sslContext,
+ final SSLBufferManagement sslBufferManagement,
+ final SSLSessionInitializer initializer,
+ final SSLSessionVerifier verifier) throws UnsupportedOperationException {
+ if (ioSession instanceof TransportSecurityLayer) {
+ ((TransportSecurityLayer) ioSession).start(sslContext, sslBufferManagement, initializer, verifier);
+ } else {
+ throw new UnsupportedOperationException();
+ }
+ }
+
+ @Override
+ public void upgrade(final IOEventHandler eventHandler) {
+ ioSession.setHandler(eventHandler);
+ }
+
+ @Override
public String toString() {
final SocketAddress remoteAddress = ioSession.getRemoteAddress();
final SocketAddress localAddress = ioSession.getLocalAddress();
Modified: httpcomponents/httpcore/trunk/httpcore5/src/main/java/org/apache/hc/core5/http/impl/nio/ClientHttp1StreamHandler.java
URL: http://svn.apache.org/viewvc/httpcomponents/httpcore/trunk/httpcore5/src/main/java/org/apache/hc/core5/http/impl/nio/ClientHttp1StreamHandler.java?rev=1774083&r1=1774082&r2=1774083&view=diff
==============================================================================
--- httpcomponents/httpcore/trunk/httpcore5/src/main/java/org/apache/hc/core5/http/impl/nio/ClientHttp1StreamHandler.java (original)
+++ httpcomponents/httpcore/trunk/httpcore5/src/main/java/org/apache/hc/core5/http/impl/nio/ClientHttp1StreamHandler.java Tue Dec 13 19:27:31 2016
@@ -48,6 +48,7 @@ import org.apache.hc.core5.http.Unsuppor
import org.apache.hc.core5.http.config.H1Config;
import org.apache.hc.core5.http.impl.LazyEntityDetails;
import org.apache.hc.core5.http.nio.AsyncClientExchangeHandler;
+import org.apache.hc.core5.http.nio.HttpContextAware;
import org.apache.hc.core5.http.nio.ContentDecoder;
import org.apache.hc.core5.http.nio.DataStreamChannel;
import org.apache.hc.core5.http.nio.RequestChannel;
@@ -162,6 +163,11 @@ class ClientHttp1StreamHandler implement
context.setProtocolVersion(transportVersion);
context.setAttribute(HttpCoreContext.HTTP_REQUEST, request);
context.setAttribute(HttpCoreContext.HTTP_CONNECTION, connection);
+
+ if (exchangeHandler instanceof HttpContextAware) {
+ ((HttpContextAware) exchangeHandler).setContext(context);
+ }
+
httpProcessor.process(request, entityDetails, context);
final boolean endStream = entityDetails == null;
Modified: httpcomponents/httpcore/trunk/httpcore5/src/main/java/org/apache/hc/core5/http/impl/nio/ServerHttp1IOEventHandlerFactory.java
URL: http://svn.apache.org/viewvc/httpcomponents/httpcore/trunk/httpcore5/src/main/java/org/apache/hc/core5/http/impl/nio/ServerHttp1IOEventHandlerFactory.java?rev=1774083&r1=1774082&r2=1774083&view=diff
==============================================================================
--- httpcomponents/httpcore/trunk/httpcore5/src/main/java/org/apache/hc/core5/http/impl/nio/ServerHttp1IOEventHandlerFactory.java (original)
+++ httpcomponents/httpcore/trunk/httpcore5/src/main/java/org/apache/hc/core5/http/impl/nio/ServerHttp1IOEventHandlerFactory.java Tue Dec 13 19:27:31 2016
@@ -49,7 +49,7 @@ import org.apache.hc.core5.http.protocol
import org.apache.hc.core5.reactor.IOEventHandler;
import org.apache.hc.core5.reactor.IOEventHandlerFactory;
import org.apache.hc.core5.reactor.IOSession;
-import org.apache.hc.core5.reactor.ssl.TlsCapable;
+import org.apache.hc.core5.reactor.ssl.TransportSecurityLayer;
import org.apache.hc.core5.util.Args;
/**
@@ -141,9 +141,9 @@ public class ServerHttp1IOEventHandlerFa
}
protected ServerHttp1StreamDuplexer createStreamDuplexer(final IOSession ioSession) {
- if (tlsStrategy != null && ioSession instanceof TlsCapable) {
+ if (tlsStrategy != null && ioSession instanceof TransportSecurityLayer) {
tlsStrategy.upgrade(
- (TlsCapable) ioSession,
+ (TransportSecurityLayer) ioSession,
null,
ioSession.getLocalAddress(),
ioSession.getRemoteAddress());
Modified: httpcomponents/httpcore/trunk/httpcore5/src/main/java/org/apache/hc/core5/http/impl/nio/ServerHttp1StreamHandler.java
URL: http://svn.apache.org/viewvc/httpcomponents/httpcore/trunk/httpcore5/src/main/java/org/apache/hc/core5/http/impl/nio/ServerHttp1StreamHandler.java?rev=1774083&r1=1774082&r2=1774083&view=diff
==============================================================================
--- httpcomponents/httpcore/trunk/httpcore5/src/main/java/org/apache/hc/core5/http/impl/nio/ServerHttp1StreamHandler.java (original)
+++ httpcomponents/httpcore/trunk/httpcore5/src/main/java/org/apache/hc/core5/http/impl/nio/ServerHttp1StreamHandler.java Tue Dec 13 19:27:31 2016
@@ -47,6 +47,7 @@ import org.apache.hc.core5.http.Protocol
import org.apache.hc.core5.http.ProtocolVersion;
import org.apache.hc.core5.http.UnsupportedHttpVersionException;
import org.apache.hc.core5.http.impl.LazyEntityDetails;
+import org.apache.hc.core5.http.nio.HttpContextAware;
import org.apache.hc.core5.http.nio.AsyncPushProducer;
import org.apache.hc.core5.http.nio.AsyncResponseProducer;
import org.apache.hc.core5.http.nio.AsyncServerExchangeHandler;
@@ -253,7 +254,9 @@ class ServerHttp1StreamHandler implement
context.setAttribute(HttpCoreContext.HTTP_REQUEST, request);
context.setAttribute(HttpCoreContext.HTTP_CONNECTION, connection);
- exchangeHandler.setContext(context);
+ if (exchangeHandler instanceof HttpContextAware) {
+ ((HttpContextAware) exchangeHandler).setContext(context);
+ }
final EntityDetails requestEntityDetails = requestEndStream ? null : new LazyEntityDetails(request);
try {
@@ -261,7 +264,6 @@ class ServerHttp1StreamHandler implement
} catch (HttpException ex) {
final AsyncResponseProducer responseProducer = handleException(ex);
exchangeHandler = new ImmediateResponseExchangeHandler(responseProducer);
- exchangeHandler.setContext(context);
}
exchangeHandler.handleRequest(request, requestEntityDetails, new ResponseChannel() {
Copied: httpcomponents/httpcore/trunk/httpcore5/src/main/java/org/apache/hc/core5/http/impl/nio/UpgradeableHttpConnection.java (from r1774082, httpcomponents/httpcore/trunk/httpcore5/src/main/java/org/apache/hc/core5/reactor/ssl/TlsCapable.java)
URL: http://svn.apache.org/viewvc/httpcomponents/httpcore/trunk/httpcore5/src/main/java/org/apache/hc/core5/http/impl/nio/UpgradeableHttpConnection.java?p2=httpcomponents/httpcore/trunk/httpcore5/src/main/java/org/apache/hc/core5/http/impl/nio/UpgradeableHttpConnection.java&p1=httpcomponents/httpcore/trunk/httpcore5/src/main/java/org/apache/hc/core5/reactor/ssl/TlsCapable.java&r1=1774082&r2=1774083&rev=1774083&view=diff
==============================================================================
--- httpcomponents/httpcore/trunk/httpcore5/src/main/java/org/apache/hc/core5/reactor/ssl/TlsCapable.java (original)
+++ httpcomponents/httpcore/trunk/httpcore5/src/main/java/org/apache/hc/core5/http/impl/nio/UpgradeableHttpConnection.java Tue Dec 13 19:27:31 2016
@@ -25,23 +25,19 @@
*
*/
-package org.apache.hc.core5.reactor.ssl;
+package org.apache.hc.core5.http.impl.nio;
-import javax.net.ssl.SSLContext;
+import org.apache.hc.core5.http.HttpConnection;
+import org.apache.hc.core5.reactor.IOEventHandler;
+import org.apache.hc.core5.reactor.ssl.TransportSecurityLayer;
/**
- * Represents capability to start a TLS session.
+ * HTTP connection capable of upgrading its transport security and protocol.
*
* @since 5.0
*/
-public interface TlsCapable {
+public interface UpgradeableHttpConnection extends HttpConnection, TransportSecurityLayer {
- void startTls(
- SSLContext sslContext,
- SSLBufferManagement sslBufferManagement,
- SSLSessionInitializer initializer,
- SSLSessionVerifier verifier) throws UnsupportedOperationException;
-
- boolean isTlsActive();
+ void upgrade(IOEventHandler eventHandler);
}
Modified: httpcomponents/httpcore/trunk/httpcore5/src/main/java/org/apache/hc/core5/http/impl/nio/bootstrap/HttpAsyncRequester.java
URL: http://svn.apache.org/viewvc/httpcomponents/httpcore/trunk/httpcore5/src/main/java/org/apache/hc/core5/http/impl/nio/bootstrap/HttpAsyncRequester.java?rev=1774083&r1=1774082&r2=1774083&view=diff
==============================================================================
--- httpcomponents/httpcore/trunk/httpcore5/src/main/java/org/apache/hc/core5/http/impl/nio/bootstrap/HttpAsyncRequester.java (original)
+++ httpcomponents/httpcore/trunk/httpcore5/src/main/java/org/apache/hc/core5/http/impl/nio/bootstrap/HttpAsyncRequester.java Tue Dec 13 19:27:31 2016
@@ -50,7 +50,7 @@ import org.apache.hc.core5.reactor.IORea
import org.apache.hc.core5.reactor.IOSession;
import org.apache.hc.core5.reactor.SessionRequest;
import org.apache.hc.core5.reactor.SessionRequestCallback;
-import org.apache.hc.core5.reactor.ssl.TlsCapable;
+import org.apache.hc.core5.reactor.ssl.TransportSecurityLayer;
import org.apache.hc.core5.util.Args;
/**
@@ -121,9 +121,9 @@ public class HttpAsyncRequester extends
@Override
public void completed(final SessionRequest request) {
final IOSession session = request.getSession();
- if (tlsStrategy != null && session instanceof TlsCapable) {
+ if (tlsStrategy != null && session instanceof TransportSecurityLayer) {
tlsStrategy.upgrade(
- (TlsCapable) session,
+ (TransportSecurityLayer) session,
host.getSchemeName(),
session.getLocalAddress(),
session.getRemoteAddress());
Modified: httpcomponents/httpcore/trunk/httpcore5/src/main/java/org/apache/hc/core5/http/nio/AsyncServerExchangeHandler.java
URL: http://svn.apache.org/viewvc/httpcomponents/httpcore/trunk/httpcore5/src/main/java/org/apache/hc/core5/http/nio/AsyncServerExchangeHandler.java?rev=1774083&r1=1774082&r2=1774083&view=diff
==============================================================================
--- httpcomponents/httpcore/trunk/httpcore5/src/main/java/org/apache/hc/core5/http/nio/AsyncServerExchangeHandler.java (original)
+++ httpcomponents/httpcore/trunk/httpcore5/src/main/java/org/apache/hc/core5/http/nio/AsyncServerExchangeHandler.java Tue Dec 13 19:27:31 2016
@@ -31,7 +31,6 @@ import java.io.IOException;
import org.apache.hc.core5.http.EntityDetails;
import org.apache.hc.core5.http.HttpException;
import org.apache.hc.core5.http.HttpRequest;
-import org.apache.hc.core5.http.protocol.HttpContext;
/**
* Abstract asynchronous server side message exchange handler that acts as a request consumer
@@ -41,8 +40,6 @@ import org.apache.hc.core5.http.protocol
*/
public interface AsyncServerExchangeHandler extends AsyncDataConsumer, AsyncDataProducer {
- void setContext(HttpContext context);
-
void handleRequest(
HttpRequest request,
EntityDetails entityDetails,
Copied: httpcomponents/httpcore/trunk/httpcore5/src/main/java/org/apache/hc/core5/http/nio/HttpContextAware.java (from r1774082, httpcomponents/httpcore/trunk/httpcore5/src/main/java/org/apache/hc/core5/reactor/ssl/TlsCapable.java)
URL: http://svn.apache.org/viewvc/httpcomponents/httpcore/trunk/httpcore5/src/main/java/org/apache/hc/core5/http/nio/HttpContextAware.java?p2=httpcomponents/httpcore/trunk/httpcore5/src/main/java/org/apache/hc/core5/http/nio/HttpContextAware.java&p1=httpcomponents/httpcore/trunk/httpcore5/src/main/java/org/apache/hc/core5/reactor/ssl/TlsCapable.java&r1=1774082&r2=1774083&rev=1774083&view=diff
==============================================================================
--- httpcomponents/httpcore/trunk/httpcore5/src/main/java/org/apache/hc/core5/reactor/ssl/TlsCapable.java (original)
+++ httpcomponents/httpcore/trunk/httpcore5/src/main/java/org/apache/hc/core5/http/nio/HttpContextAware.java Tue Dec 13 19:27:31 2016
@@ -24,24 +24,17 @@
* <http://www.apache.org/>.
*
*/
+package org.apache.hc.core5.http.nio;
-package org.apache.hc.core5.reactor.ssl;
-
-import javax.net.ssl.SSLContext;
+import org.apache.hc.core5.http.protocol.HttpContext;
/**
- * Represents capability to start a TLS session.
+ * {@link HttpContext} aware protocol handler.
*
* @since 5.0
*/
-public interface TlsCapable {
-
- void startTls(
- SSLContext sslContext,
- SSLBufferManagement sslBufferManagement,
- SSLSessionInitializer initializer,
- SSLSessionVerifier verifier) throws UnsupportedOperationException;
+public interface HttpContextAware {
- boolean isTlsActive();
+ void setContext(HttpContext context);
}
Modified: httpcomponents/httpcore/trunk/httpcore5/src/main/java/org/apache/hc/core5/http/nio/ssl/BasicClientTlsStrategy.java
URL: http://svn.apache.org/viewvc/httpcomponents/httpcore/trunk/httpcore5/src/main/java/org/apache/hc/core5/http/nio/ssl/BasicClientTlsStrategy.java?rev=1774083&r1=1774082&r2=1774083&view=diff
==============================================================================
--- httpcomponents/httpcore/trunk/httpcore5/src/main/java/org/apache/hc/core5/http/nio/ssl/BasicClientTlsStrategy.java (original)
+++ httpcomponents/httpcore/trunk/httpcore5/src/main/java/org/apache/hc/core5/http/nio/ssl/BasicClientTlsStrategy.java Tue Dec 13 19:27:31 2016
@@ -34,7 +34,7 @@ import javax.net.ssl.SSLContext;
import org.apache.hc.core5.reactor.ssl.SSLBufferManagement;
import org.apache.hc.core5.reactor.ssl.SSLSessionInitializer;
import org.apache.hc.core5.reactor.ssl.SSLSessionVerifier;
-import org.apache.hc.core5.reactor.ssl.TlsCapable;
+import org.apache.hc.core5.reactor.ssl.TransportSecurityLayer;
import org.apache.hc.core5.ssl.SSLContexts;
import org.apache.hc.core5.util.Args;
@@ -85,13 +85,13 @@ public class BasicClientTlsStrategy impl
@Override
public void upgrade(
- final TlsCapable tlsCapable,
+ final TransportSecurityLayer tlsSession,
final String scheme,
final SocketAddress localAddress,
final SocketAddress remoteAddress,
final String... parameters) {
if ("https".equalsIgnoreCase(scheme)) {
- tlsCapable.startTls(sslContext, sslBufferManagement, initializer, verifier);
+ tlsSession.start(sslContext, sslBufferManagement, initializer, verifier);
}
}
Modified: httpcomponents/httpcore/trunk/httpcore5/src/main/java/org/apache/hc/core5/http/nio/ssl/BasicServerTlsStrategy.java
URL: http://svn.apache.org/viewvc/httpcomponents/httpcore/trunk/httpcore5/src/main/java/org/apache/hc/core5/http/nio/ssl/BasicServerTlsStrategy.java?rev=1774083&r1=1774082&r2=1774083&view=diff
==============================================================================
--- httpcomponents/httpcore/trunk/httpcore5/src/main/java/org/apache/hc/core5/http/nio/ssl/BasicServerTlsStrategy.java (original)
+++ httpcomponents/httpcore/trunk/httpcore5/src/main/java/org/apache/hc/core5/http/nio/ssl/BasicServerTlsStrategy.java Tue Dec 13 19:27:31 2016
@@ -35,7 +35,7 @@ import javax.net.ssl.SSLContext;
import org.apache.hc.core5.reactor.ssl.SSLBufferManagement;
import org.apache.hc.core5.reactor.ssl.SSLSessionInitializer;
import org.apache.hc.core5.reactor.ssl.SSLSessionVerifier;
-import org.apache.hc.core5.reactor.ssl.TlsCapable;
+import org.apache.hc.core5.reactor.ssl.TransportSecurityLayer;
import org.apache.hc.core5.ssl.SSLContexts;
import org.apache.hc.core5.util.Args;
@@ -91,7 +91,7 @@ public class BasicServerTlsStrategy impl
@Override
public void upgrade(
- final TlsCapable tlsCapable,
+ final TransportSecurityLayer tlsSession,
final String scheme,
final SocketAddress localAddress,
final SocketAddress remoteAddress,
@@ -99,7 +99,7 @@ public class BasicServerTlsStrategy impl
final int port = ((InetSocketAddress) localAddress).getPort();
for (int securePort: securePorts) {
if (port == securePort) {
- tlsCapable.startTls(sslContext, sslBufferManagement, initializer, verifier);
+ tlsSession.start(sslContext, sslBufferManagement, initializer, verifier);
break;
}
}
Modified: httpcomponents/httpcore/trunk/httpcore5/src/main/java/org/apache/hc/core5/http/nio/ssl/TlsStrategy.java
URL: http://svn.apache.org/viewvc/httpcomponents/httpcore/trunk/httpcore5/src/main/java/org/apache/hc/core5/http/nio/ssl/TlsStrategy.java?rev=1774083&r1=1774082&r2=1774083&view=diff
==============================================================================
--- httpcomponents/httpcore/trunk/httpcore5/src/main/java/org/apache/hc/core5/http/nio/ssl/TlsStrategy.java (original)
+++ httpcomponents/httpcore/trunk/httpcore5/src/main/java/org/apache/hc/core5/http/nio/ssl/TlsStrategy.java Tue Dec 13 19:27:31 2016
@@ -29,17 +29,17 @@ package org.apache.hc.core5.http.nio.ssl
import java.net.SocketAddress;
-import org.apache.hc.core5.reactor.ssl.TlsCapable;
+import org.apache.hc.core5.reactor.ssl.TransportSecurityLayer;
/**
- * TLS protocol upgrade strategy for non-blocking {@link TlsCapable} connections.
+ * TLS protocol upgrade strategy for non-blocking {@link TransportSecurityLayer} connections.
*
* @since 5.0
*/
public interface TlsStrategy {
void upgrade(
- TlsCapable tlsCapable,
+ TransportSecurityLayer tlsSession,
String scheme,
SocketAddress localAddress,
SocketAddress remoteAddress,
Modified: httpcomponents/httpcore/trunk/httpcore5/src/main/java/org/apache/hc/core5/http/nio/support/AbstractServerExchangeHandler.java
URL: http://svn.apache.org/viewvc/httpcomponents/httpcore/trunk/httpcore5/src/main/java/org/apache/hc/core5/http/nio/support/AbstractServerExchangeHandler.java?rev=1774083&r1=1774082&r2=1774083&view=diff
==============================================================================
--- httpcomponents/httpcore/trunk/httpcore5/src/main/java/org/apache/hc/core5/http/nio/support/AbstractServerExchangeHandler.java (original)
+++ httpcomponents/httpcore/trunk/httpcore5/src/main/java/org/apache/hc/core5/http/nio/support/AbstractServerExchangeHandler.java Tue Dec 13 19:27:31 2016
@@ -39,6 +39,7 @@ import org.apache.hc.core5.http.HttpHead
import org.apache.hc.core5.http.HttpRequest;
import org.apache.hc.core5.http.HttpStatus;
import org.apache.hc.core5.http.message.BasicHttpResponse;
+import org.apache.hc.core5.http.nio.HttpContextAware;
import org.apache.hc.core5.http.nio.AsyncPushProducer;
import org.apache.hc.core5.http.nio.AsyncRequestConsumer;
import org.apache.hc.core5.http.nio.AsyncResponseProducer;
@@ -53,7 +54,7 @@ import org.apache.hc.core5.util.Asserts;
/**
* @since 5.0
*/
-public abstract class AbstractServerExchangeHandler<T> implements AsyncServerExchangeHandler {
+public abstract class AbstractServerExchangeHandler<T> implements HttpContextAware, AsyncServerExchangeHandler {
private final AtomicReference<AsyncRequestConsumer<T>> requestConsumerRef;
private final AtomicReference<AsyncResponseProducer> responseProducerRef;
Modified: httpcomponents/httpcore/trunk/httpcore5/src/main/java/org/apache/hc/core5/http/nio/support/ImmediateResponseExchangeHandler.java
URL: http://svn.apache.org/viewvc/httpcomponents/httpcore/trunk/httpcore5/src/main/java/org/apache/hc/core5/http/nio/support/ImmediateResponseExchangeHandler.java?rev=1774083&r1=1774082&r2=1774083&view=diff
==============================================================================
--- httpcomponents/httpcore/trunk/httpcore5/src/main/java/org/apache/hc/core5/http/nio/support/ImmediateResponseExchangeHandler.java (original)
+++ httpcomponents/httpcore/trunk/httpcore5/src/main/java/org/apache/hc/core5/http/nio/support/ImmediateResponseExchangeHandler.java Tue Dec 13 19:27:31 2016
@@ -30,12 +30,12 @@ import java.io.IOException;
import java.nio.ByteBuffer;
import java.util.List;
+import org.apache.hc.core5.http.ContentType;
import org.apache.hc.core5.http.EntityDetails;
import org.apache.hc.core5.http.Header;
import org.apache.hc.core5.http.HttpException;
import org.apache.hc.core5.http.HttpRequest;
import org.apache.hc.core5.http.HttpResponse;
-import org.apache.hc.core5.http.ContentType;
import org.apache.hc.core5.http.message.BasicHttpResponse;
import org.apache.hc.core5.http.nio.AsyncResponseProducer;
import org.apache.hc.core5.http.nio.AsyncServerExchangeHandler;
@@ -44,7 +44,6 @@ import org.apache.hc.core5.http.nio.Capa
import org.apache.hc.core5.http.nio.DataStreamChannel;
import org.apache.hc.core5.http.nio.ResponseChannel;
import org.apache.hc.core5.http.nio.entity.BasicAsyncEntityProducer;
-import org.apache.hc.core5.http.protocol.HttpContext;
import org.apache.hc.core5.util.Args;
/**
@@ -67,10 +66,6 @@ public final class ImmediateResponseExch
}
@Override
- public void setContext(final HttpContext context) {
- }
-
- @Override
public void handleRequest(
final HttpRequest request,
final EntityDetails entityDetails,
Modified: httpcomponents/httpcore/trunk/httpcore5/src/main/java/org/apache/hc/core5/reactor/ManagedIOSession.java
URL: http://svn.apache.org/viewvc/httpcomponents/httpcore/trunk/httpcore5/src/main/java/org/apache/hc/core5/reactor/ManagedIOSession.java?rev=1774083&r1=1774082&r2=1774083&view=diff
==============================================================================
--- httpcomponents/httpcore/trunk/httpcore5/src/main/java/org/apache/hc/core5/reactor/ManagedIOSession.java (original)
+++ httpcomponents/httpcore/trunk/httpcore5/src/main/java/org/apache/hc/core5/reactor/ManagedIOSession.java Tue Dec 13 19:27:31 2016
@@ -35,6 +35,7 @@ import java.util.concurrent.atomic.Atomi
import java.util.concurrent.atomic.AtomicReference;
import javax.net.ssl.SSLContext;
+import javax.net.ssl.SSLSession;
import org.apache.hc.core5.annotation.Contract;
import org.apache.hc.core5.annotation.ThreadingBehavior;
@@ -44,14 +45,14 @@ import org.apache.hc.core5.reactor.ssl.S
import org.apache.hc.core5.reactor.ssl.SSLMode;
import org.apache.hc.core5.reactor.ssl.SSLSessionInitializer;
import org.apache.hc.core5.reactor.ssl.SSLSessionVerifier;
-import org.apache.hc.core5.reactor.ssl.TlsCapable;
+import org.apache.hc.core5.reactor.ssl.TransportSecurityLayer;
import org.apache.hc.core5.util.Asserts;
/**
* @since 5.0
*/
@Contract(threading = ThreadingBehavior.SAFE)
-class ManagedIOSession implements IOSession, TlsCapable {
+class ManagedIOSession implements IOSession, TransportSecurityLayer {
private final NamedEndpoint namedEndpoint;
private final IOSession ioSession;
@@ -195,7 +196,7 @@ class ManagedIOSession implements IOSess
}
@Override
- public void startTls(
+ public void start(
final SSLContext sslContext,
final SSLBufferManagement sslBufferManagement,
final SSLSessionInitializer initializer,
@@ -213,8 +214,9 @@ class ManagedIOSession implements IOSess
}
@Override
- public boolean isTlsActive() {
- return tlsSessionRef.get() != null;
+ public SSLSession getSSLSession() {
+ final SSLIOSession sslIoSession = tlsSessionRef.get();
+ return sslIoSession != null ? sslIoSession.getSSLSession() : null;
}
public void close() {
Copied: httpcomponents/httpcore/trunk/httpcore5/src/main/java/org/apache/hc/core5/reactor/ssl/TransportSecurityLayer.java (from r1774082, httpcomponents/httpcore/trunk/httpcore5/src/main/java/org/apache/hc/core5/reactor/ssl/TlsCapable.java)
URL: http://svn.apache.org/viewvc/httpcomponents/httpcore/trunk/httpcore5/src/main/java/org/apache/hc/core5/reactor/ssl/TransportSecurityLayer.java?p2=httpcomponents/httpcore/trunk/httpcore5/src/main/java/org/apache/hc/core5/reactor/ssl/TransportSecurityLayer.java&p1=httpcomponents/httpcore/trunk/httpcore5/src/main/java/org/apache/hc/core5/reactor/ssl/TlsCapable.java&r1=1774082&r2=1774083&rev=1774083&view=diff
==============================================================================
--- httpcomponents/httpcore/trunk/httpcore5/src/main/java/org/apache/hc/core5/reactor/ssl/TlsCapable.java (original)
+++ httpcomponents/httpcore/trunk/httpcore5/src/main/java/org/apache/hc/core5/reactor/ssl/TransportSecurityLayer.java Tue Dec 13 19:27:31 2016
@@ -28,20 +28,21 @@
package org.apache.hc.core5.reactor.ssl;
import javax.net.ssl.SSLContext;
+import javax.net.ssl.SSLSession;
/**
- * Represents capability to start a TLS session.
+ * Represents a TLS capable session layer.
*
* @since 5.0
*/
-public interface TlsCapable {
+public interface TransportSecurityLayer {
- void startTls(
+ void start(
SSLContext sslContext,
SSLBufferManagement sslBufferManagement,
SSLSessionInitializer initializer,
SSLSessionVerifier verifier) throws UnsupportedOperationException;
- boolean isTlsActive();
+ SSLSession getSSLSession();
}
Propchange: httpcomponents/httpcore/trunk/httpcore5/src/main/java/org/apache/hc/core5/reactor/ssl/TransportSecurityLayer.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: httpcomponents/httpcore/trunk/httpcore5/src/main/java/org/apache/hc/core5/reactor/ssl/TransportSecurityLayer.java
------------------------------------------------------------------------------
svn:keywords = Date Revision
Propchange: httpcomponents/httpcore/trunk/httpcore5/src/main/java/org/apache/hc/core5/reactor/ssl/TransportSecurityLayer.java
------------------------------------------------------------------------------
svn:mime-type = text/plain