Author: remy.maucherat(a)jboss.com
Date: 2011-06-10 10:49:38 -0400 (Fri, 10 Jun 2011)
New Revision: 1738
Modified:
trunk/java/org/apache/coyote/http11/Http11Protocol.java
trunk/java/org/apache/tomcat/util/net/jsse/JSSESocketFactory.java
Log:
- Add the capability to set the SSLContext, fully configured elsewhere. I like delegating
the hard stuff.
Modified: trunk/java/org/apache/coyote/http11/Http11Protocol.java
===================================================================
--- trunk/java/org/apache/coyote/http11/Http11Protocol.java 2011-06-10 12:54:21 UTC (rev
1737)
+++ trunk/java/org/apache/coyote/http11/Http11Protocol.java 2011-06-10 14:49:38 UTC (rev
1738)
@@ -36,6 +36,7 @@
import javax.management.MBeanRegistration;
import javax.management.MBeanServer;
import javax.management.ObjectName;
+import javax.net.ssl.SSLContext;
import org.apache.coyote.Adapter;
import org.apache.coyote.ProtocolHandler;
@@ -546,6 +547,14 @@
setAttribute("keyAlias", keyAlias);
}
+ public SSLContext getSSLContext() {
+ return (SSLContext) getAttribute("SSLContext");
+ }
+
+ public void setSSLContext(SSLContext sslContext) {
+ setAttribute("SSLContext", sslContext);
+ }
+
// ----------------------------------- Http11ConnectionHandler Inner Class
protected static class Http11ConnectionHandler implements Handler {
Modified: trunk/java/org/apache/tomcat/util/net/jsse/JSSESocketFactory.java
===================================================================
--- trunk/java/org/apache/tomcat/util/net/jsse/JSSESocketFactory.java 2011-06-10 12:54:21
UTC (rev 1737)
+++ trunk/java/org/apache/tomcat/util/net/jsse/JSSESocketFactory.java 2011-06-10 14:49:38
UTC (rev 1738)
@@ -446,13 +446,15 @@
}
// Create and init SSLContext
- SSLContext context = SSLContext.getInstance(protocol);
- context.init(getKeyManagers(keystoreType, keystoreProvider,
- algorithm,
- (String) attributes.get("keyAlias")),
- getTrustManagers(keystoreType, keystoreProvider,
- trustAlgorithm),
- new SecureRandom());
+ SSLContext context = (SSLContext) attributes.get("SSLContext");
+ if (context == null) {
+ context = SSLContext.getInstance(protocol);
+ context.init(
+ getKeyManagers(keystoreType, keystoreProvider,
+ algorithm, (String)
attributes.get("keyAlias")),
+ getTrustManagers(keystoreType, keystoreProvider,
+ trustAlgorithm), new SecureRandom());
+ }
// Configure SSL session cache
int sessionCacheSize;
Show replies by date