From 03037bfe912b0995d8c7337f639eb6432d2f91a7 Mon Sep 17 00:00:00 2001 From: markt Date: Tue, 8 Mar 2011 14:03:20 +0000 Subject: [PATCH] Add the hooks (no implementation yet) for BIO and NIO to share the code that is currently in JSSESocketFactory git-svn-id: https://svn.apache.org/repos/asf/tomcat/trunk@1079360 13f79535-47bb-0310-9956-ffa450edef68 --- java/org/apache/tomcat/util/net/NioEndpoint.java | 5 +++++ .../apache/tomcat/util/net/SSLImplementation.java | 2 ++ java/org/apache/tomcat/util/net/SSLUtil.java | 21 +++++++++++++++++++++ .../tomcat/util/net/jsse/JSSEImplementation.java | 5 +++++ .../tomcat/util/net/jsse/JSSESocketFactory.java | 3 ++- 5 files changed, 35 insertions(+), 1 deletion(-) create mode 100644 java/org/apache/tomcat/util/net/SSLUtil.java diff --git a/java/org/apache/tomcat/util/net/NioEndpoint.java b/java/org/apache/tomcat/util/net/NioEndpoint.java index 59ee0ed1f..d60f04b80 100644 --- a/java/org/apache/tomcat/util/net/NioEndpoint.java +++ b/java/org/apache/tomcat/util/net/NioEndpoint.java @@ -94,6 +94,8 @@ public class NioEndpoint extends AbstractEndpoint { */ protected ServerSocketChannel serverSock = null; + protected SSLUtil sslUtil = null; + /** * use send file */ @@ -477,6 +479,9 @@ public class NioEndpoint extends AbstractEndpoint { // Initialize SSL if needed if (isSSLEnabled()) { + if (sslUtil == null) { + sslUtil = handler.getSslImplementation().getSSLUtil(this); + } // Initialize SSL String keystorePass = getKeystorePass(); if (keystorePass == null) { diff --git a/java/org/apache/tomcat/util/net/SSLImplementation.java b/java/org/apache/tomcat/util/net/SSLImplementation.java index a194af9a7..f79b39f8c 100644 --- a/java/org/apache/tomcat/util/net/SSLImplementation.java +++ b/java/org/apache/tomcat/util/net/SSLImplementation.java @@ -86,4 +86,6 @@ public abstract class SSLImplementation { public abstract SSLSupport getSSLSupport(Socket sock); public abstract SSLSupport getSSLSupport(SSLSession session); + + public abstract SSLUtil getSSLUtil(AbstractEndpoint ep); } diff --git a/java/org/apache/tomcat/util/net/SSLUtil.java b/java/org/apache/tomcat/util/net/SSLUtil.java new file mode 100644 index 000000000..04f551b69 --- /dev/null +++ b/java/org/apache/tomcat/util/net/SSLUtil.java @@ -0,0 +1,21 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.apache.tomcat.util.net; + +public interface SSLUtil { + +} diff --git a/java/org/apache/tomcat/util/net/jsse/JSSEImplementation.java b/java/org/apache/tomcat/util/net/jsse/JSSEImplementation.java index a3cebb732..be2a5de90 100644 --- a/java/org/apache/tomcat/util/net/jsse/JSSEImplementation.java +++ b/java/org/apache/tomcat/util/net/jsse/JSSEImplementation.java @@ -25,6 +25,7 @@ import javax.net.ssl.SSLSocket; import org.apache.tomcat.util.net.AbstractEndpoint; import org.apache.tomcat.util.net.SSLImplementation; import org.apache.tomcat.util.net.SSLSupport; +import org.apache.tomcat.util.net.SSLUtil; import org.apache.tomcat.util.net.ServerSocketFactory; /* JSSEImplementation: @@ -56,4 +57,8 @@ public class JSSEImplementation extends SSLImplementation { return new JSSESupport(session); } + @Override + public SSLUtil getSSLUtil(AbstractEndpoint endpoint) { + return new JSSESocketFactory(endpoint); + } } diff --git a/java/org/apache/tomcat/util/net/jsse/JSSESocketFactory.java b/java/org/apache/tomcat/util/net/jsse/JSSESocketFactory.java index 7fa6fab7c..449f282d9 100644 --- a/java/org/apache/tomcat/util/net/jsse/JSSESocketFactory.java +++ b/java/org/apache/tomcat/util/net/jsse/JSSESocketFactory.java @@ -62,6 +62,7 @@ import javax.net.ssl.X509KeyManager; import org.apache.tomcat.util.net.AbstractEndpoint; import org.apache.tomcat.util.net.Constants; +import org.apache.tomcat.util.net.SSLUtil; import org.apache.tomcat.util.net.ServerSocketFactory; import org.apache.tomcat.util.res.StringManager; @@ -78,7 +79,7 @@ import org.apache.tomcat.util.res.StringManager; * @author Jan Luehe * @author Bill Barker */ -public class JSSESocketFactory implements ServerSocketFactory { +public class JSSESocketFactory implements ServerSocketFactory, SSLUtil { private static final org.apache.juli.logging.Log log = org.apache.juli.logging.LogFactory.getLog(JSSESocketFactory.class); -- 2.11.0