Author: jonesde
Date: Tue Dec 19 10:08:59 2006 New Revision: 488748 URL: http://svn.apache.org/viewvc?view=rev&rev=488748 Log: Added valve to support incoming HTTP requests from an SSL Accelerator that are not HTTPS/SSL requests, but that should be treated by the server as secure Added: incubator/ofbiz/trunk/framework/catalina/src/org/ofbiz/catalina/container/SslAcceleratorValve.java (with props) Modified: incubator/ofbiz/trunk/framework/base/config/ofbiz-containers.xml incubator/ofbiz/trunk/framework/catalina/src/org/ofbiz/catalina/container/CatalinaContainer.java Modified: incubator/ofbiz/trunk/framework/base/config/ofbiz-containers.xml URL: http://svn.apache.org/viewvc/incubator/ofbiz/trunk/framework/base/config/ofbiz-containers.xml?view=diff&rev=488748&r1=488747&r2=488748 ============================================================================== --- incubator/ofbiz/trunk/framework/base/config/ofbiz-containers.xml (original) +++ incubator/ofbiz/trunk/framework/base/config/ofbiz-containers.xml Tue Dec 19 10:08:59 2006 @@ -119,6 +119,7 @@ <property name="mcast-drop-time" value="3000"/> </property> --> + <!-- <property name="ssl-accelerator-port" value="8443"/> --> </property> <!-- all connectors support type, host, port, enable-lookups --> <property name="ajp-connector" value="connector"> Modified: incubator/ofbiz/trunk/framework/catalina/src/org/ofbiz/catalina/container/CatalinaContainer.java URL: http://svn.apache.org/viewvc/incubator/ofbiz/trunk/framework/catalina/src/org/ofbiz/catalina/container/CatalinaContainer.java?view=diff&rev=488748&r1=488747&r2=488748 ============================================================================== --- incubator/ofbiz/trunk/framework/catalina/src/org/ofbiz/catalina/container/CatalinaContainer.java (original) +++ incubator/ofbiz/trunk/framework/catalina/src/org/ofbiz/catalina/container/CatalinaContainer.java Tue Dec 19 10:08:59 2006 @@ -300,6 +300,16 @@ } al.setDirectory(logFile.getAbsolutePath()); } + + // configure the SslAcceleratorValve + String sslAcceleratorPortStr = ContainerConfig.getPropertyValue(engineConfig, "ssl-accelerator-port", null); + if (UtilValidate.isNotEmpty(sslAcceleratorPortStr)) { + Integer sslAcceleratorPort = Integer.valueOf(sslAcceleratorPortStr); + SslAcceleratorValve sslAcceleratorValve = new SslAcceleratorValve(); + sslAcceleratorValve.setSslAcceleratorPort(sslAcceleratorPort); + engine.addValve(sslAcceleratorValve); + } + String alp2 = ContainerConfig.getPropertyValue(engineConfig, "access-log-pattern", null); if (al != null && !UtilValidate.isEmpty(alp2)) { Added: incubator/ofbiz/trunk/framework/catalina/src/org/ofbiz/catalina/container/SslAcceleratorValve.java URL: http://svn.apache.org/viewvc/incubator/ofbiz/trunk/framework/catalina/src/org/ofbiz/catalina/container/SslAcceleratorValve.java?view=auto&rev=488748 ============================================================================== --- incubator/ofbiz/trunk/framework/catalina/src/org/ofbiz/catalina/container/SslAcceleratorValve.java (added) +++ incubator/ofbiz/trunk/framework/catalina/src/org/ofbiz/catalina/container/SslAcceleratorValve.java Tue Dec 19 10:08:59 2006 @@ -0,0 +1,54 @@ +/* + * Copyright 2001-2006 The Apache Software Foundation + * + * Licensed 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.ofbiz.catalina.container; + +import java.io.IOException; + +import javax.servlet.ServletException; + +import org.apache.catalina.connector.Request; +import org.apache.catalina.connector.Response; +import org.apache.catalina.valves.ValveBase; + +/** + * To use add (or uncomment) the following line to the Tomcat/Catalina configuarion (ie in ofbiz-containers.xml under the <property name="default-server" value="engine"> element) + * <property name="ssl-accelerator-port" value="8443"/> + * + * Once that is done just setup a connector just like the example http-connector and have it listen on the port you set in the ssl-accelerator-port value. + */ +public class SslAcceleratorValve extends ValveBase { + + protected Integer sslAcceleratorPort = null; + + public void setSslAcceleratorPort(Integer sslAcceleratorPort) { + this.sslAcceleratorPort = sslAcceleratorPort; + } + + public Integer getSslAcceleratorPort() { + return sslAcceleratorPort; + } + + /** @Override */ + public void invoke(Request req, Response resp) throws IOException, ServletException { + if (sslAcceleratorPort != null && req.getLocalPort() == sslAcceleratorPort.intValue()) { + req.setSecure(true); + } + + if (getNext() != null) { + getNext().invoke(req, resp); + } + } +} Propchange: incubator/ofbiz/trunk/framework/catalina/src/org/ofbiz/catalina/container/SslAcceleratorValve.java ------------------------------------------------------------------------------ svn:eol-style = native Propchange: incubator/ofbiz/trunk/framework/catalina/src/org/ofbiz/catalina/container/SslAcceleratorValve.java ------------------------------------------------------------------------------ svn:keywords = "Date Rev Author URL Id" Propchange: incubator/ofbiz/trunk/framework/catalina/src/org/ofbiz/catalina/container/SslAcceleratorValve.java ------------------------------------------------------------------------------ svn:mime-type = text/plain |
Free forum by Nabble | Edit this page |