portals-portalapps-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From woon...@apache.org
Subject svn commit: r818597 - in /portals/applications/webcontent/trunk: webcontent-jar/ webcontent-jar/src/main/java/org/apache/portals/applications/webcontent/proxy/ webcontent-jar/src/main/java/org/apache/portals/applications/webcontent/proxy/impl/ webconte...
Date Thu, 24 Sep 2009 19:19:26 GMT
Author: woonsan
Date: Thu Sep 24 19:19:21 2009
New Revision: 818597

URL: http://svn.apache.org/viewvc?rev=818597&view=rev
Log:
APA-17: Refines configuration files with simple java properties file instead of custom format or servlet init params.
Also, improves reverse service component to be injectable with user's authScope-credentials map, which enables SSO feature.

Added:
    portals/applications/webcontent/trunk/webcontent-jar/src/main/java/org/apache/portals/applications/webcontent/proxy/HttpReverseProxyConstants.java   (with props)
    portals/applications/webcontent/trunk/webcontent-jar/src/test/java/org/apache/portals/applications/webcontent/proxy/
    portals/applications/webcontent/trunk/webcontent-jar/src/test/java/org/apache/portals/applications/webcontent/proxy/TestHttpClientAuth.java   (with props)
    portals/applications/webcontent/trunk/webcontent-war/src/main/webapp/WEB-INF/conf/reverseproxy.properties   (with props)
Removed:
    portals/applications/webcontent/trunk/webcontent-war/src/main/webapp/WEB-INF/conf/reverseproxy-urlmappings.properties
Modified:
    portals/applications/webcontent/trunk/webcontent-jar/pom.xml
    portals/applications/webcontent/trunk/webcontent-jar/src/main/java/org/apache/portals/applications/webcontent/proxy/impl/DefaultHttpReverseProxyServlet.java
    portals/applications/webcontent/trunk/webcontent-jar/src/main/java/org/apache/portals/applications/webcontent/proxy/impl/RewritableHttpReverseProxyServiceImpl.java
    portals/applications/webcontent/trunk/webcontent-war/src/main/webapp/WEB-INF/web.xml

Modified: portals/applications/webcontent/trunk/webcontent-jar/pom.xml
URL: http://svn.apache.org/viewvc/portals/applications/webcontent/trunk/webcontent-jar/pom.xml?rev=818597&r1=818596&r2=818597&view=diff
==============================================================================
--- portals/applications/webcontent/trunk/webcontent-jar/pom.xml (original)
+++ portals/applications/webcontent/trunk/webcontent-jar/pom.xml Thu Sep 24 19:19:21 2009
@@ -40,11 +40,11 @@
     <httpcomponents-httpcore.version>4.0.1</httpcomponents-httpcore.version>
     <httpcomponents-httpclient.version>4.0</httpcomponents-httpclient.version>
     <jcip-annotations.version>1.0</jcip-annotations.version>
-    <json.version>20080701</json.version>
     <commons-lang.version>2.4</commons-lang.version>
     <commons-io.version>1.4</commons-io.version>
     <commons-httpclient.version>3.0.1</commons-httpclient.version>
-    <commons-beanutils.version>1.7.0</commons-beanutils.version>
+    <commons-beanutils.version>1.8.0</commons-beanutils.version>
+    <commons-configuration.version>1.6</commons-configuration.version>
   </properties>
 
   <!-- Dependencies -->
@@ -163,9 +163,15 @@
       </exclusions>
     </dependency>
     <dependency>
-      <groupId>org.json</groupId>
-      <artifactId>json</artifactId>
-      <version>${json.version}</version>
+      <groupId>commons-configuration</groupId>
+      <artifactId>commons-configuration</artifactId>
+      <version>${commons-configuration.version}</version>
+      <exclusions>
+        <exclusion>
+          <groupId>commons-logging</groupId>
+          <artifactId>commons-logging</artifactId>
+        </exclusion>
+      </exclusions>
     </dependency>
     <dependency>
       <groupId>org.slf4j</groupId>

Added: portals/applications/webcontent/trunk/webcontent-jar/src/main/java/org/apache/portals/applications/webcontent/proxy/HttpReverseProxyConstants.java
URL: http://svn.apache.org/viewvc/portals/applications/webcontent/trunk/webcontent-jar/src/main/java/org/apache/portals/applications/webcontent/proxy/HttpReverseProxyConstants.java?rev=818597&view=auto
==============================================================================
--- portals/applications/webcontent/trunk/webcontent-jar/src/main/java/org/apache/portals/applications/webcontent/proxy/HttpReverseProxyConstants.java (added)
+++ portals/applications/webcontent/trunk/webcontent-jar/src/main/java/org/apache/portals/applications/webcontent/proxy/HttpReverseProxyConstants.java Thu Sep 24 19:19:21 2009
@@ -0,0 +1,28 @@
+/*
+ * 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.portals.applications.webcontent.proxy;
+
+public interface HttpReverseProxyConstants
+{
+    
+    String HTTP_HEADER_LOCATION = "Location";
+    
+    String REVERSE_PROXY_PATH_MAPPER_ATTRIBUTE = "org.apache.portals.applications.webcontent.proxy.reverseProxyPathMapper";
+    
+    String REVERSE_PROXY_AUTH_CREDS_MAP_ATTRIBUTE = "org.apache.portals.applications.webcontent.proxy.reverseProxyAuthCredsMap";
+    
+}

Propchange: portals/applications/webcontent/trunk/webcontent-jar/src/main/java/org/apache/portals/applications/webcontent/proxy/HttpReverseProxyConstants.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: portals/applications/webcontent/trunk/webcontent-jar/src/main/java/org/apache/portals/applications/webcontent/proxy/HttpReverseProxyConstants.java
------------------------------------------------------------------------------
    svn:keywords = Id

Propchange: portals/applications/webcontent/trunk/webcontent-jar/src/main/java/org/apache/portals/applications/webcontent/proxy/HttpReverseProxyConstants.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Modified: portals/applications/webcontent/trunk/webcontent-jar/src/main/java/org/apache/portals/applications/webcontent/proxy/impl/DefaultHttpReverseProxyServlet.java
URL: http://svn.apache.org/viewvc/portals/applications/webcontent/trunk/webcontent-jar/src/main/java/org/apache/portals/applications/webcontent/proxy/impl/DefaultHttpReverseProxyServlet.java?rev=818597&r1=818596&r2=818597&view=diff
==============================================================================
--- portals/applications/webcontent/trunk/webcontent-jar/src/main/java/org/apache/portals/applications/webcontent/proxy/impl/DefaultHttpReverseProxyServlet.java (original)
+++ portals/applications/webcontent/trunk/webcontent-jar/src/main/java/org/apache/portals/applications/webcontent/proxy/impl/DefaultHttpReverseProxyServlet.java Thu Sep 24 19:19:21 2009
@@ -20,12 +20,10 @@
 import java.io.InputStream;
 import java.net.InetAddress;
 import java.util.ArrayList;
-import java.util.Enumeration;
 import java.util.HashMap;
+import java.util.Iterator;
 import java.util.List;
 import java.util.Map;
-import java.util.regex.Matcher;
-import java.util.regex.Pattern;
 
 import javax.servlet.ServletConfig;
 import javax.servlet.ServletException;
@@ -36,9 +34,10 @@
 import org.apache.commons.beanutils.BeanUtils;
 import org.apache.commons.collections.KeyValue;
 import org.apache.commons.collections.keyvalue.DefaultKeyValue;
+import org.apache.commons.configuration.Configuration;
+import org.apache.commons.configuration.PropertiesConfiguration;
 import org.apache.commons.io.IOUtils;
-import org.apache.commons.io.LineIterator;
-import org.apache.commons.lang.BooleanUtils;
+import org.apache.commons.lang.ArrayUtils;
 import org.apache.commons.lang.StringUtils;
 import org.apache.http.HttpHost;
 import org.apache.http.client.params.ClientParamBean;
@@ -54,9 +53,6 @@
 import org.apache.portals.applications.webcontent.rewriter.MappingRewriterController;
 import org.apache.portals.applications.webcontent.rewriter.Rewriter;
 import org.apache.portals.applications.webcontent.rewriter.RewriterController;
-import org.json.JSONArray;
-import org.json.JSONException;
-import org.json.JSONObject;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
@@ -74,222 +70,117 @@
     protected HttpReverseProxyPathMapperProvider proxyPathMapperProvider;
     protected HttpReverseProxyService proxyService;
     
-    private List<Class> rewriterClassList;
-    private List<Class> adaptorClassList;
+    private Configuration configuration;
     
     @Override
     public void init(ServletConfig config) throws ServletException
     {
-        List<HttpReverseProxyPathMapper> proxyPathMappers = new ArrayList<HttpReverseProxyPathMapper>();
-        
-        List<Class> classList = buildClassList(config.getInitParameter("reverseproxy.rewriter.classes"));
-        
-        if (classList != null)
-        {
-            rewriterClassList = classList;
-        }
+        loadConfiguration(config);
         
-        classList = buildClassList(config.getInitParameter("reverseproxy.adaptor.classes"));
-        
-        if (classList != null)
-        {
-            adaptorClassList = classList;
-        }
+        List<HttpReverseProxyPathMapper> proxyPathMappers = new ArrayList<HttpReverseProxyPathMapper>();
         
         List<KeyValue> rewriterControllerPairs = new ArrayList<KeyValue>();
         List<KeyValue> rewriterPairs = new ArrayList<KeyValue>();
-
-        String urlMappings = config.getInitParameter("reverseproxy.urlmappings");
         
-        if (urlMappings != null)
+        Configuration passConf = configuration.subset("proxy.reverse.pass");
+        String [] pathNames = passConf.getStringArray("");
+        
+        try
         {
-            Pattern reverseProxyPathURLPattern = Pattern.compile("^ReverseProxyPathURL\\s+(\\S+)\\s+(\\S+)$", Pattern.CASE_INSENSITIVE);
-            Pattern reverseProxyRewriterPattern = Pattern.compile("^ReverseProxyRewriter\\s+(\\S+)\\s+(\\S+)\\s+(\\S+)$", Pattern.CASE_INSENSITIVE);
-            
-            InputStream urlMappingsInput = null;
-            
-            try
+            for (String pathName : pathNames)
             {
-                urlMappingsInput = config.getServletContext().getResourceAsStream(urlMappings);
-                LineIterator lineIt = IOUtils.lineIterator(urlMappingsInput, null);
+                Configuration pathPassConf = passConf.subset(pathName);
                 
-                while (lineIt.hasNext())
-                {
-                    String line = lineIt.nextLine();
+                String localBasePath = pathPassConf.getString("local");
+                String remoteBaseURL = pathPassConf.getString("remote");
                 
-                    if ("".equals(line) || line.startsWith("#"))
-                    {
-                        continue;
-                    }
-                    
-                    Matcher reverseProxyPathURLMatcher = reverseProxyPathURLPattern.matcher(line);
-                    Matcher reverseProxyRewriterMatcher = reverseProxyRewriterPattern.matcher(line);
+                proxyPathMappers.add(new DefaultHttpProxyPathMapperImpl(localBasePath, remoteBaseURL));
+                
+                String [] rewriterClassNames = pathPassConf.getStringArray("rewriters");
+                String [] rewriterRuleConfs = pathPassConf.getStringArray("rules");
+                String [] adaptorClassNames = pathPassConf.getStringArray("adaptors");
+                
+                if (ArrayUtils.getLength(rewriterRuleConfs) == 2)
+                {
+                    RewriterController rewriterController = createRewriterController(config, rewriterRuleConfs[0], rewriterClassNames, adaptorClassNames);
                     
-                    if (reverseProxyPathURLMatcher.matches())
+                    if (rewriterController != null)
                     {
-                        String localBasePath = reverseProxyPathURLMatcher.group(1);
-                        String remoteBaseURL = reverseProxyPathURLMatcher.group(2);
-                        HttpReverseProxyPathMapper proxyPathMapper = new DefaultHttpProxyPathMapperImpl(localBasePath, remoteBaseURL);
-                        proxyPathMappers.add(proxyPathMapper);
-                    }
-                    else if (reverseProxyRewriterMatcher.matches())
-                    {
-                        String localBasePath = reverseProxyRewriterMatcher.group(1);
-                        String rulesMapping = reverseProxyRewriterMatcher.group(2);
-                        String rewriterRules = reverseProxyRewriterMatcher.group(3);
-                        
-                        try
-                        {
-                            RewriterController rewriterController = createRewriterController(config, rulesMapping);
-                            
-                            if (rewriterController != null)
-                            {
-                                rewriterControllerPairs.add(new DefaultKeyValue(localBasePath, rewriterController));
-                                Rewriter rewriter = createRewriter(config, rewriterController, rewriterRules);
-                                rewriterPairs.add(new DefaultKeyValue(localBasePath, rewriter));
-                            }
-                        }
-                        catch (Exception e)
-                        {
-                            throw new ServletException(e);
-                        }
+                        rewriterControllerPairs.add(new DefaultKeyValue(localBasePath, rewriterController));
+                        Rewriter rewriter = createRewriter(config, rewriterController, rewriterRuleConfs[1]);
+                        rewriterPairs.add(new DefaultKeyValue(localBasePath, rewriter));
                     }
                 }
             }
-            catch (IOException e)
-            {
-                throw new ServletException("Failed to initialize url mappings. " + e);
-            }
-            finally
-            {
-                if (urlMappingsInput != null)
-                {
-                    IOUtils.closeQuietly(urlMappingsInput);
-                }
-            }
+        }
+        catch (Exception e)
+        {
+            throw new ServletException("Failed to initialize url mappings. " + e);
         }
         
         proxyPathMapperProvider = new DefaultHttpReverseProxyPathMapperProviderImpl(proxyPathMappers, rewriterControllerPairs, rewriterPairs);
         proxyService = new RewritableHttpReverseProxyServiceImpl(proxyPathMapperProvider);
         
-        String param = config.getInitParameter("reverseproxy.hostheadervalue");
+        Configuration serverConf = configuration.subset("proxy.server");
         
-        if (param != null)
+        if (!StringUtils.isBlank(serverConf.getString("hostname")))
         {
-            ((RewritableHttpReverseProxyServiceImpl) proxyService).setHostHeaderValue(param.trim());
+            ((RewritableHttpReverseProxyServiceImpl) proxyService).setHostHeaderValue(serverConf.getString("hostname"));
         }
         
-        param = config.getInitParameter("reverseproxy.localbaseurl");
-        
-        if (param != null)
+        if (!StringUtils.isBlank(serverConf.getString("baseurl")))
         {
-            ((RewritableHttpReverseProxyServiceImpl) proxyService).setLocalBaseURL(param.trim());
+            ((RewritableHttpReverseProxyServiceImpl) proxyService).setLocalBaseURL(serverConf.getString("baseurl"));
         }
         
-        param = config.getInitParameter("reverseproxy.prependlocalbaseurl");
+        Configuration clientParamsConf = configuration.subset("proxy.http.client.param");
         
-        if (param != null)
+        if (!clientParamsConf.isEmpty())
         {
-            ((RewritableHttpReverseProxyServiceImpl) proxyService).setPrependLocalBaseURL(BooleanUtils.toBoolean(param.trim()));
+            HttpParams clientParams = new BasicHttpParams();
+            setBeanPropertiesByConfiguration(new ClientParamBean(clientParams), clientParamsConf);
+            ((RewritableHttpReverseProxyServiceImpl) proxyService).setClientParams(clientParams);
         }
         
-        boolean clientParamSet = false;
-        HttpParams clientParams = new BasicHttpParams();
-        ClientParamBean clientParamBean = new ClientParamBean(clientParams);
-        
-        boolean requestParamSet = false;
-        HttpParams requestParams = new BasicHttpParams();
-        ClientParamBean requestParamBean = new ClientParamBean(requestParams);
-        
-        boolean connManagerParamSet = false;
-        HttpParams connManagerParams = new BasicHttpParams();
-        ConnManagerParamBean connManagerParamBean = new ConnManagerParamBean(connManagerParams);
+        Configuration connManagerParamsConf = configuration.subset("proxy.http.connManager.param");
+        Configuration routesConf = configuration.subset("proxy.http.route");
         
-        boolean connPerRouteParamSet = false;
-        ConnPerRouteBean connPerRouteBean = new ConnPerRouteBean();
-        Map<HttpRoute, Integer> maxForRoutes = new HashMap<HttpRoute, Integer>();
-        
-        for (Enumeration enumParamNames = config.getInitParameterNames(); enumParamNames.hasMoreElements(); )
+        if (!connManagerParamsConf.isEmpty() || !routesConf.isEmpty())
         {
-            String paramName = (String) enumParamNames.nextElement();
+            HttpParams connManagerParams = new BasicHttpParams();
+            ConnManagerParamBean connManagerParamBean = new ConnManagerParamBean(connManagerParams);
+            setBeanPropertiesByConfiguration(connManagerParamBean, connManagerParamsConf);
             
-            try
+            if (!routesConf.isEmpty())
             {
-                if (paramName.startsWith("client.param."))
-                {
-                    String propName = paramName.substring("client.param.".length());
-                    String paramValue = config.getInitParameter(paramName);
-                    BeanUtils.setProperty(clientParamBean, propName, paramValue);
-                    clientParamSet = true;
-                }
-                else if (paramName.startsWith("request.param."))
-                {
-                    String propName = paramName.substring("request.param.".length());
-                    String paramValue = config.getInitParameter(paramName);
-                    BeanUtils.setProperty(requestParamBean, propName, paramValue);
-                    requestParamSet = true;
-                }
-                else if (paramName.startsWith("conn.manager.param."))
-                {
-                    String propName = paramName.substring("conn.manager.param.".length());
-                    String paramValue = config.getInitParameter(paramName);
-                    BeanUtils.setProperty(connManagerParamBean, propName, paramValue);
-                    connManagerParamSet = true;
-                }
-                else if (paramName.startsWith("conn.per.route.param."))
+                ConnPerRouteBean connPerRouteBean = new ConnPerRouteBean();
+                setBeanPropertiesByConfiguration(connPerRouteBean, routesConf.subset("param"));
+                
+                Map<HttpRoute, Integer> maxForRoutes = new HashMap<HttpRoute, Integer>();
+                
+                String [] routeNames = routesConf.getStringArray("");
+                
+                for (String routeName : routeNames)
                 {
-                    String propName = paramName.substring("conn.per.route.param.".length());
-                    String paramValue = config.getInitParameter(paramName);
+                    Configuration routeConf = routesConf.subset(routeName);
                     
-                    if ("maxForRoutes".equals(propName))
+                    try
                     {
-                        JSONArray routes = new JSONObject(paramValue).getJSONArray("routes");
+                        HttpRoute httpRoute = buildHttpRoute(routeConf);
+                        int maxConnections = routeConf.getInt("maxConnections", -1);
                         
-                        for (int i = 0; i < routes.length(); i++)
+                        if (maxConnections >= 0)
                         {
-                            JSONObject route = routes.getJSONObject(i);
-                            HttpRoute httpRoute = buildHttpRoute(route);
-                            int maxForRoute = route.getInt("max");
-                            maxForRoutes.put(httpRoute, new Integer(maxForRoute));
+                            maxForRoutes.put(httpRoute, maxConnections);
                         }
-                        
-                        connPerRouteBean.setMaxForRoutes(maxForRoutes);
                     }
-                    else
+                    catch (Exception e)
                     {
-                        BeanUtils.setProperty(connPerRouteBean, propName, paramValue);
+                        throw new ServletException(e);
                     }
-                    
-                    connPerRouteParamSet = true;
-                }
-            }
-            catch (Exception e)
-            {
-                if (log.isDebugEnabled())
-                {
-                    log.error("Failed to set parameter named " + paramName, e);
-                }
-                else
-                {
-                    log.error("Failed to set parameter named {}. {}", paramName, e);
                 }
-            }
-        }
-        
-        if (clientParamSet)
-        {
-            ((RewritableHttpReverseProxyServiceImpl) proxyService).setClientParams(clientParams);
-        }
-        
-        if (requestParamSet)
-        {
-            ((RewritableHttpReverseProxyServiceImpl) proxyService).setRequestParams(requestParams);
-        }
-        
-        if (connManagerParamSet || connPerRouteParamSet)
-        {
-            if (connPerRouteParamSet)
-            {
+                
+                connPerRouteBean.setMaxForRoutes(maxForRoutes);
                 connManagerParamBean.setConnectionsPerRoute(connPerRouteBean);
             }
             
@@ -319,16 +210,9 @@
         doGet(request, response);
     }
     
-    private RewriterController createRewriterController(ServletConfig config, String rulesMappingResourcePath) throws Exception
+    private RewriterController createRewriterController(ServletConfig config, String rulesMappingResourcePath, String [] rewriterClassNames, String [] adaptorClassNames) throws Exception
     {
-        if (rewriterClassList != null && adaptorClassList != null)
-        {
-            return new MappingRewriterController(config.getServletContext().getRealPath(rulesMappingResourcePath), rewriterClassList, adaptorClassList);
-        }
-        else
-        {
-            return null;
-        }
+        return new MappingRewriterController(config.getServletContext().getRealPath(rulesMappingResourcePath), buildClassList(rewriterClassNames), buildClassList(adaptorClassNames));
     }
     
     private Rewriter createRewriter(ServletConfig config, RewriterController rwc, String rewriterRulesResourcePath) throws Exception
@@ -352,7 +236,7 @@
         return rewriter;
     }
     
-    private HttpRoute buildHttpRoute(JSONObject route) throws Exception
+    private HttpRoute buildHttpRoute(Configuration routeConf) throws Exception
     {
         HttpRoute httpRoute = null;
         
@@ -365,50 +249,48 @@
         RouteInfo.TunnelType tunnelType = RouteInfo.TunnelType.PLAIN;
         RouteInfo.LayerType layerType = RouteInfo.LayerType.PLAIN;
         
-        targetHost = buildHttpHost(route.getJSONObject("target"));
+        targetHost = buildHttpHost(routeConf.subset("target"));
         
-        try 
+        String local = routeConf.getString("local");
+        
+        if (local != null)
         {
-            String local = route.getString("local");
-            
-            if (local != null)
+            try
             {
-                localAddress = InetAddress.getByAddress(local.getBytes());
+                localAddress = InetAddress.getByName(local);
             }
-        }
-        catch (Exception e)
-        {
-        }
-        
-        try 
-        {
-            JSONArray proxies = route.getJSONArray("proxies");
-            
-            if (proxies != null)
+            catch (Exception e)
             {
-                proxyHosts = new HttpHost[proxies.length()];
-                
-                for (int i = 0; i < proxies.length(); i++)
+                if (log.isDebugEnabled())
                 {
-                    proxyHosts[i] = buildHttpHost(proxies.getJSONObject(i));
+                    log.error("Failed to convert ip address: " + local, e);
+                }
+                else
+                {
+                    log.error("Failed to convert ip address: {}. {}", local, e);
                 }
             }
         }
-        catch (Exception e)
-        {
-        }
         
-        try 
-        {
-            secure = route.getBoolean("secure");
-        }
-        catch (Exception e)
+        Configuration proxiesConf = routeConf.subset("proxy");
+        
+        if (!proxiesConf.isEmpty())
         {
+            String [] proxyNames = proxiesConf.getStringArray("");
+            proxyHosts = new HttpHost[proxyNames.length];
+            
+            for (int i = 0; i < proxyNames.length; i++)
+            {
+                Configuration proxyConf = proxiesConf.subset(proxyNames[i]);
+                proxyHosts[i] = buildHttpHost(proxyConf);
+            }
         }
         
+        secure = routeConf.getBoolean("secure", false);
+        
         try 
         {
-            tunnelled = route.getString("tunnelled");
+            tunnelled = routeConf.getString("tunnelled");
             
             if (tunnelled != null)
             {
@@ -421,7 +303,7 @@
         
         try 
         {
-            layered = route.getString("layered");
+            layered = routeConf.getString("layered");
             
             if (layered != null)
             {
@@ -448,7 +330,7 @@
         return httpRoute;
     }
     
-    private HttpHost buildHttpHost(JSONObject host)
+    private HttpHost buildHttpHost(Configuration hostConf)
     {
         HttpHost httpHost = null;
         
@@ -456,13 +338,13 @@
         int port = 0;
         String scheme = null;
         
-        try { hostname = host.getString("hostname"); } catch (JSONException e) { }
-        try { port = host.getInt("port"); } catch (JSONException e) { }
-        try { scheme = host.getString("scheme"); } catch (JSONException e) { }
+        hostname = hostConf.getString("hostname");
+        port = hostConf.getInt("port", 0);
+        scheme = hostConf.getString("scheme");
         
-        if (hostname == null)
+        if (StringUtils.isBlank(hostname))
         {
-            throw new IllegalArgumentException("hostname is null: " + host);
+            throw new IllegalArgumentException("hostname is blank: " + hostConf);
         }
         
         if (port <= 0)
@@ -481,11 +363,9 @@
         return httpHost;
     }
     
-    private List<Class> buildClassList(String list)
+    private List<Class> buildClassList(String [] classNames)
     {
-        String [] classNames = StringUtils.split(list);
-        
-        if (classNames != null)
+        if (!ArrayUtils.isEmpty(classNames))
         {
             List<Class> classList = new ArrayList();
             
@@ -513,4 +393,63 @@
         
         return null;
     }
+    
+    private void loadConfiguration(ServletConfig servletConfig) throws ServletException
+    {
+        String configResourcePath = servletConfig.getInitParameter("reverseproxy.configuration");
+        
+        if (configResourcePath == null)
+        {
+            configResourcePath = "/WEB-INF/conf/reverseproxy.properties";
+        }
+        
+        InputStream configInput = null;
+        
+        try
+        {
+            configInput = servletConfig.getServletContext().getResourceAsStream(configResourcePath);
+            configuration = new PropertiesConfiguration();
+            ((PropertiesConfiguration) configuration).load(configInput);
+        }
+        catch (Exception e)
+        {
+            throw new ServletException("Failed to load configuration: " + configResourcePath);
+        }
+        finally
+        {
+            if (configInput != null)
+            {
+                IOUtils.closeQuietly(configInput);
+            }
+        }
+    }
+    
+    private void setBeanPropertiesByConfiguration(Object bean, Configuration conf)
+    {
+        for (Iterator it = conf.getKeys(); it.hasNext(); )
+        {
+            String propName = (String) it.next();
+            
+            if (!StringUtils.isBlank(propName))
+            {
+                String propValue = conf.getString(propName);
+                
+                try
+                {
+                    BeanUtils.setProperty(bean, propName, propValue);
+                }
+                catch (Exception e)
+                {
+                    if (log.isDebugEnabled())
+                    {
+                        log.error("Failed to set parameter named " + propName, e);
+                    }
+                    else
+                    {
+                        log.error("Failed to set parameter named {}. {}", propName, e);
+                    }
+                }
+            }
+        }
+    }
 }

Modified: portals/applications/webcontent/trunk/webcontent-jar/src/main/java/org/apache/portals/applications/webcontent/proxy/impl/RewritableHttpReverseProxyServiceImpl.java
URL: http://svn.apache.org/viewvc/portals/applications/webcontent/trunk/webcontent-jar/src/main/java/org/apache/portals/applications/webcontent/proxy/impl/RewritableHttpReverseProxyServiceImpl.java?rev=818597&r1=818596&r2=818597&view=diff
==============================================================================
--- portals/applications/webcontent/trunk/webcontent-jar/src/main/java/org/apache/portals/applications/webcontent/proxy/impl/RewritableHttpReverseProxyServiceImpl.java (original)
+++ portals/applications/webcontent/trunk/webcontent-jar/src/main/java/org/apache/portals/applications/webcontent/proxy/impl/RewritableHttpReverseProxyServiceImpl.java Thu Sep 24 19:19:21 2009
@@ -24,19 +24,23 @@
 import java.io.Reader;
 import java.io.Writer;
 import java.util.Enumeration;
+import java.util.Map;
 
 import javax.servlet.http.HttpServletRequest;
 import javax.servlet.http.HttpServletResponse;
+import javax.servlet.http.HttpSession;
 
 import org.apache.commons.io.IOUtils;
 import org.apache.http.Header;
 import org.apache.http.HttpEntity;
 import org.apache.http.HttpResponse;
-import org.apache.http.client.HttpClient;
+import org.apache.http.auth.AuthScope;
+import org.apache.http.auth.Credentials;
 import org.apache.http.client.methods.HttpGet;
 import org.apache.http.client.methods.HttpPost;
 import org.apache.http.client.methods.HttpRequestBase;
 import org.apache.http.client.params.ClientPNames;
+import org.apache.http.conn.ClientConnectionManager;
 import org.apache.http.conn.scheme.PlainSocketFactory;
 import org.apache.http.conn.scheme.Scheme;
 import org.apache.http.conn.scheme.SchemeRegistry;
@@ -46,7 +50,9 @@
 import org.apache.http.impl.conn.tsccm.ThreadSafeClientConnManager;
 import org.apache.http.params.BasicHttpParams;
 import org.apache.http.params.HttpParams;
+import org.apache.http.protocol.HTTP;
 import org.apache.http.util.EntityUtils;
+import org.apache.portals.applications.webcontent.proxy.HttpReverseProxyConstants;
 import org.apache.portals.applications.webcontent.proxy.HttpReverseProxyPathMapper;
 import org.apache.portals.applications.webcontent.proxy.HttpReverseProxyPathMapperProvider;
 import org.apache.portals.applications.webcontent.proxy.HttpReverseProxyService;
@@ -67,16 +73,6 @@
     
     private static Logger log = LoggerFactory.getLogger(RewritableHttpReverseProxyServiceImpl.class);
     
-    public static final String REVERSE_PROXY_PATH_MAPPER_ATTRIBUTE = "org.apache.jetspeed.proxy.reverseProxyPathMapper";
-    
-    public static final String REWRITER_CONTROLLER_ATTRIBUTE = "rewriterController";
-    
-    private static final String LOCATION_HEADER = "Location";
-    
-    private static final String CONTENT_LENGTH_HEADER = "Content-Length";
-    
-    private static final String HOST_HEADER = "Host";
-    
     /**
      * Proxy path mapper provider
      */
@@ -93,30 +89,20 @@
     private String localBaseURL;
     
     /**
-     * flag to force to prefix localBaseURL when it redirects
+     * The multithreaded connection manager for performance.
      */
-    private boolean prependLocalBaseURL;
+    private ClientConnectionManager connectionManager;
     
     /**
-     * The shared http client for performance.
+     * HTTP Connection Manager Parameters
      */
-    private HttpClient httpClient;
+    private HttpParams connectionManagerParams;
     
     /**
      * HTTP Client Parameters
      */
     private HttpParams clientParams;
     
-    /**
-     * HTTP Connection Manager Parameters
-     */
-    private HttpParams connectionManagerParams;
-
-    /**
-     * HTTP Request Parameters
-     */
-    private HttpParams requestParams;
-    
     public RewritableHttpReverseProxyServiceImpl(HttpReverseProxyPathMapperProvider proxyPathMapperProvider)
     {
         this.proxyPathMapperProvider = proxyPathMapperProvider;
@@ -132,11 +118,6 @@
         this.localBaseURL = localBaseURL;
     }
     
-    public void setPrependLocalBaseURL(boolean prependLocalBaseURL)
-    {
-        this.prependLocalBaseURL = prependLocalBaseURL;
-    }
-    
     public void setClientParams(HttpParams clientParams)
     {
         this.clientParams = clientParams;
@@ -147,22 +128,14 @@
         this.connectionManagerParams = connectionManagerParams;
     }
     
-    public void setRequestParams(HttpParams requestParams)
-    {
-        this.requestParams = requestParams;
-    }
-    
     public void initialize()
     {
-        if (clientParams == null && connectionManagerParams == null)
-        {
-            clientParams = connectionManagerParams = new BasicHttpParams();
-        }
-        else if (clientParams == null)
+        if (clientParams == null)
         {
             clientParams = new BasicHttpParams();
         }
-        else if (connectionManagerParams == null)
+        
+        if (connectionManagerParams == null)
         {
             connectionManagerParams = new BasicHttpParams();
         }
@@ -171,25 +144,21 @@
         schemeRegistry.register(new Scheme("http", PlainSocketFactory.getSocketFactory(), 80));
         schemeRegistry.register(new Scheme("https", SSLSocketFactory.getSocketFactory(), 443));
 
-        ThreadSafeClientConnManager connectionManager = new ThreadSafeClientConnManager(connectionManagerParams, schemeRegistry);
-        
-        httpClient = new DefaultHttpClient(connectionManager, clientParams);
+        connectionManager = new ThreadSafeClientConnManager(connectionManagerParams, schemeRegistry);
     }
     
     public void destroy()
     {
-        if (httpClient != null)
+        if (connectionManager != null)
         {
-            ((ThreadSafeClientConnManager) httpClient.getConnectionManager()).shutdown();
+            connectionManager.shutdown();
         }
-        
-        httpClient = null;
     }
     
     public void invoke(HttpServletRequest request, HttpServletResponse response) throws IOException
     {
         // proxyPathMapper can be injected by using request attribute.
-        HttpReverseProxyPathMapper proxyPathMapper = (HttpReverseProxyPathMapper) request.getAttribute(REVERSE_PROXY_PATH_MAPPER_ATTRIBUTE);
+        HttpReverseProxyPathMapper proxyPathMapper = (HttpReverseProxyPathMapper) request.getAttribute(HttpReverseProxyConstants.REVERSE_PROXY_PATH_MAPPER_ATTRIBUTE);
         
         String pathInfo = request.getPathInfo();
         
@@ -233,6 +202,13 @@
         {
             proxyTargetURL = new StringBuilder(proxyTargetURL.length() + 1 + queryString.length()).append(proxyTargetURL).append('?').append(queryString).toString();
         }
+
+        // create http client for each request...
+        DefaultHttpClient httpClient = new DefaultHttpClient(connectionManager, clientParams);
+        // redirection should be adjusted with local host header...
+        httpClient.getParams().setBooleanParameter(ClientPNames.HANDLE_REDIRECTS, false);
+        // set credentials for this user if available
+        retrieveCredentialsInfos(httpClient, request);
         
         String method = request.getMethod();
         boolean isGetMethod = "GET".equals(method);
@@ -255,23 +231,15 @@
             throw new IOException("Unsupported method: " + method);
         }
         
-        if (requestParams != null)
-        {
-            httpRequest.setParams(requestParams);
-        }
-        
-        // redirection should be adjusted with local host header...
-        httpRequest.getParams().setBooleanParameter(ClientPNames.HANDLE_REDIRECTS, false);
-        
         // pass most headers to proxy target...
         for (Enumeration enumHeaderNames = request.getHeaderNames(); enumHeaderNames.hasMoreElements(); ) 
         {
             String headerName = (String) enumHeaderNames.nextElement();
             
-            if (headerName.equalsIgnoreCase(CONTENT_LENGTH_HEADER))
+            if (headerName.equalsIgnoreCase(HTTP.CONTENT_LEN))
                 continue;
             
-            if (headerName.equalsIgnoreCase(HOST_HEADER))
+            if (headerName.equalsIgnoreCase(HTTP.TARGET_HOST))
                 continue;
             
             for (Enumeration enumHeaderValues = request.getHeaders(headerName); enumHeaderValues.hasMoreElements(); )
@@ -295,7 +263,7 @@
                 && statusCode < HttpServletResponse.SC_NOT_MODIFIED /* 304 */)
             {
                 String location = null;
-                Header locationHeader = httpResponse.getFirstHeader(LOCATION_HEADER);
+                Header locationHeader = httpResponse.getFirstHeader(HttpReverseProxyConstants.HTTP_HEADER_LOCATION);
                 
                 if (locationHeader != null)
                 {
@@ -304,7 +272,7 @@
                 
                 if (location == null)
                 {
-                    throw new IOException("Recieved status code: " + statusCode + " but no " + LOCATION_HEADER + " header was found in the response");
+                    throw new IOException("Recieved status code: " + statusCode + " but no " + HttpReverseProxyConstants.HTTP_HEADER_LOCATION + " header was found in the response");
                 }
                 
                 // Modify the redirect to go to this proxy servlet rather that the proxied host
@@ -336,7 +304,7 @@
                 }
                 else
                 {
-                    if (prependLocalBaseURL) {
+                    if (localBaseURL != null) {
                         redirectLocation = localBaseURL + localPath;
                     } else {
                         redirectLocation = request.getContextPath() + request.getServletPath() + localPath;
@@ -355,7 +323,7 @@
                 // header and the data on disk has not changed; server
                 // responds w/ a 304 saying I'm not going to send the
                 // body because the file has not changed.
-                response.setIntHeader(CONTENT_LENGTH_HEADER, 0);
+                response.setIntHeader(HTTP.CONTENT_LEN, 0);
                 response.setStatus(HttpServletResponse.SC_NOT_MODIFIED);
                 
                 return;
@@ -375,7 +343,7 @@
                         String headerName = header.getName();
                         String headerValue = header.getValue();
                         
-                        if (headerName.equalsIgnoreCase(HOST_HEADER))
+                        if (headerName.equalsIgnoreCase(HTTP.TARGET_HOST))
                         {
                             response.setHeader(headerName, hostHeaderValue);
                         }
@@ -518,5 +486,28 @@
         }
     }
     
+    private void retrieveCredentialsInfos(DefaultHttpClient httpClient, HttpServletRequest request)
+    {
+        Map<AuthScope, Credentials> authScopeCredentialsMap = (Map<AuthScope, Credentials>) request.getAttribute(HttpReverseProxyConstants.REVERSE_PROXY_AUTH_CREDS_MAP_ATTRIBUTE);
+        
+        if (authScopeCredentialsMap == null)
+        {
+            HttpSession session = request.getSession(false);
+            
+            if (session != null)
+            {
+                authScopeCredentialsMap = (Map<AuthScope, Credentials>) session.getAttribute(HttpReverseProxyConstants.REVERSE_PROXY_AUTH_CREDS_MAP_ATTRIBUTE);
+            }
+        }
+        
+        if (authScopeCredentialsMap != null && !authScopeCredentialsMap.isEmpty())
+        {
+            for (Map.Entry<AuthScope, Credentials> entry : authScopeCredentialsMap.entrySet())
+            {
+                httpClient.getCredentialsProvider().setCredentials(entry.getKey(), entry.getValue());
+            }
+        }
+    }
+    
 }
 

Added: portals/applications/webcontent/trunk/webcontent-jar/src/test/java/org/apache/portals/applications/webcontent/proxy/TestHttpClientAuth.java
URL: http://svn.apache.org/viewvc/portals/applications/webcontent/trunk/webcontent-jar/src/test/java/org/apache/portals/applications/webcontent/proxy/TestHttpClientAuth.java?rev=818597&view=auto
==============================================================================
--- portals/applications/webcontent/trunk/webcontent-jar/src/test/java/org/apache/portals/applications/webcontent/proxy/TestHttpClientAuth.java (added)
+++ portals/applications/webcontent/trunk/webcontent-jar/src/test/java/org/apache/portals/applications/webcontent/proxy/TestHttpClientAuth.java Thu Sep 24 19:19:21 2009
@@ -0,0 +1,243 @@
+/*
+ * 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.portals.applications.webcontent.proxy;
+
+import java.net.URI;
+
+import junit.framework.TestCase;
+
+import org.apache.commons.lang.StringUtils;
+import org.apache.http.HttpEntity;
+import org.apache.http.HttpResponse;
+import org.apache.http.auth.AuthScope;
+import org.apache.http.auth.Credentials;
+import org.apache.http.auth.UsernamePasswordCredentials;
+import org.apache.http.client.methods.HttpGet;
+import org.apache.http.client.params.ClientPNames;
+import org.apache.http.conn.ClientConnectionManager;
+import org.apache.http.conn.scheme.PlainSocketFactory;
+import org.apache.http.conn.scheme.Scheme;
+import org.apache.http.conn.scheme.SchemeRegistry;
+import org.apache.http.conn.ssl.SSLSocketFactory;
+import org.apache.http.impl.client.DefaultHttpClient;
+import org.apache.http.impl.conn.tsccm.ThreadSafeClientConnManager;
+import org.apache.http.params.BasicHttpParams;
+
+/**
+ * Example test case to show how to implement multi-threaded http client invocations with authentications.
+ * 
+ * @version $Id$
+ */
+public class TestHttpClientAuth extends TestCase
+{
+    private String authHost;
+    private int authPort = 80;
+    private String authRealm;
+    private String username;
+    private String password;
+    private String badusername = "bad_user_name_not_existing";
+    private String badpassword = "bad_user_password";
+    
+    private String targetURI;
+    private boolean targetURIAvailable;
+    
+    private AuthScope authScope;
+    private Credentials credentials;
+    private Credentials badcredentials;
+    
+    private ClientConnectionManager connectionManager;    
+    private int workersCount = 20;
+    
+    @Override
+    public void setUp()
+    {
+        targetURI = System.getProperty("TestHttpClientAuth.targetURI");
+        
+        if (targetURI == null)
+        {
+            System.out.println("Test skipped: You need to set a system property to run this test case as follows:\n\n" +
+                               "\t-DTestHttpClientAuth.targetURI=http://manager:manager@localhost:8080/manager/list\n");
+            return;
+        }
+        
+        URI theTargetURI = URI.create(targetURI);
+        targetURIAvailable = true;
+        
+        authHost = theTargetURI.getHost();
+        
+        if (theTargetURI.getPort() > 0)
+        {
+            authPort = theTargetURI.getPort();
+        }
+        
+        authRealm = "Tomcat Manager Application";
+        
+        String userInfo = theTargetURI.getUserInfo();
+        String [] userInfoArray = StringUtils.split(userInfo, ":");
+        username = userInfoArray[0];
+        password = userInfoArray[1];
+        
+        if (authRealm == null)
+        {
+            authScope = new AuthScope(authHost, authPort);
+        }
+        else
+        {
+            authScope = new AuthScope(authHost, authPort, authRealm);
+        }
+        
+        credentials = new UsernamePasswordCredentials(username, password);
+        badcredentials = new UsernamePasswordCredentials(badusername, badpassword);
+
+        SchemeRegistry schemeRegistry = new SchemeRegistry();
+        schemeRegistry.register(new Scheme("http", PlainSocketFactory.getSocketFactory(), 80));
+        schemeRegistry.register(new Scheme("https", SSLSocketFactory.getSocketFactory(), 443));
+
+        connectionManager = new ThreadSafeClientConnManager(new BasicHttpParams(), schemeRegistry);
+    }
+
+    @Override
+    public void tearDown()
+    {
+        // When HttpClient instance is no longer needed,
+        // shut down the connection manager to ensure
+        // immediate deallocation of all system resources
+        if (connectionManager != null)
+        {
+            connectionManager.shutdown();
+        }
+    }
+
+    public void testClientAuthentication() throws Exception
+    {
+        if (!targetURIAvailable)
+        {
+            return;
+        }
+        
+        Thread [] workers = new Thread[workersCount];
+        AuthRequestJob [] jobs = new AuthRequestJob[workersCount];
+        
+        for (int i = 0; i < workersCount; i++)
+        {
+            boolean isBadCredentials = (i % 2 != 0);
+            jobs[i] = new AuthRequestJob(targetURI, authScope, (isBadCredentials ? badcredentials : credentials), isBadCredentials);
+            workers[i] = new Thread(jobs[i], "WORKER-" + i);
+        }
+        
+        for (int i = 0; i < workersCount; i++)
+        {
+            workers[i].start();
+        }
+        
+        for (int i = 0; i < workersCount; i++)
+        {
+            workers[i].join();
+        }
+        
+        for (int i = 0; i < workersCount; i++)
+        {
+            assertNull("auth request job has exception.", jobs[i].getException());
+        }
+    }
+    
+    private void executeAuthRequest(String target, AuthScope targetAuthScope, Credentials targetCredentials, boolean isBadCredentials) throws Exception
+    {
+        HttpGet httpget = null;
+        HttpEntity entity = null;
+        
+        try
+        {
+            DefaultHttpClient httpclient = new DefaultHttpClient(connectionManager, new BasicHttpParams());
+            httpclient.getParams().setBooleanParameter(ClientPNames.HANDLE_REDIRECTS, false);
+
+            httpclient.getCredentialsProvider().setCredentials(targetAuthScope, targetCredentials);
+            
+            httpget = new HttpGet(target);
+            System.out.println(Thread.currentThread().getName() + ": executing request" + httpget.getRequestLine());
+            
+            HttpResponse response = httpclient.execute(httpget);
+            entity = response.getEntity();
+            
+            System.out.println(Thread.currentThread().getName() + ": Status Line: " + response.getStatusLine());
+            int statusCode = response.getStatusLine().getStatusCode();
+            
+            if (!isBadCredentials && (statusCode >= 400))
+            {
+                throw new RuntimeException("the status code shows it's not authorized automatically: " + statusCode);
+            }
+            else if (isBadCredentials && (statusCode < 400))
+            {
+                throw new RuntimeException("the status code shows it's authorized automatically for bad credentials: " + statusCode);
+            }
+            
+            //System.out.println(Thread.currentThread().getName() + ": " + EntityUtils.toString(entity));
+            
+            entity.consumeContent();
+        }
+        catch (Exception e)
+        {
+            httpget.abort();
+            entity = null;
+            throw e;
+        }
+        finally
+        {
+            if (entity != null)
+            {
+                entity.consumeContent();
+            }
+        }
+    }
+    
+    private class AuthRequestJob implements Runnable
+    {
+        private String target;
+        private AuthScope authScope;
+        private Credentials credentials;
+        private boolean isBadCredentials;
+        private Exception exception;
+        
+        private AuthRequestJob(String target, AuthScope authScope, Credentials credentials, boolean isBadCredentials)
+        {
+            this.target = target;
+            this.authScope = authScope;
+            this.credentials = credentials;
+            this.isBadCredentials = isBadCredentials;
+        }
+        
+        public Exception getException()
+        {
+            return exception;
+        }
+        
+        public void run()
+        {
+            try
+            {
+                executeAuthRequest(target, authScope, credentials, isBadCredentials);
+            }
+            catch (Exception e)
+            {
+                System.out.println(Thread.currentThread().getName() + ": " + e + ", " + credentials);
+                e.printStackTrace();
+                exception = e;
+            }
+        }
+    }
+    
+}

Propchange: portals/applications/webcontent/trunk/webcontent-jar/src/test/java/org/apache/portals/applications/webcontent/proxy/TestHttpClientAuth.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: portals/applications/webcontent/trunk/webcontent-jar/src/test/java/org/apache/portals/applications/webcontent/proxy/TestHttpClientAuth.java
------------------------------------------------------------------------------
    svn:keywords = Id

Propchange: portals/applications/webcontent/trunk/webcontent-jar/src/test/java/org/apache/portals/applications/webcontent/proxy/TestHttpClientAuth.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Added: portals/applications/webcontent/trunk/webcontent-war/src/main/webapp/WEB-INF/conf/reverseproxy.properties
URL: http://svn.apache.org/viewvc/portals/applications/webcontent/trunk/webcontent-war/src/main/webapp/WEB-INF/conf/reverseproxy.properties?rev=818597&view=auto
==============================================================================
--- portals/applications/webcontent/trunk/webcontent-war/src/main/webapp/WEB-INF/conf/reverseproxy.properties (added)
+++ portals/applications/webcontent/trunk/webcontent-war/src/main/webapp/WEB-INF/conf/reverseproxy.properties Thu Sep 24 19:19:21 2009
@@ -0,0 +1,96 @@
+# 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.
+# ------------------------------------------------------------------------
+#
+# Reverse Proxy Configuration
+#
+# $Id$
+#
+# ------------------------------------------------------------------------
+
+# Constant properties
+# ... Constant properties can be used in other property values by wrapping '${}'.
+defaults.htmlRewriter = org.apache.portals.applications.webcontent.rewriter.WebContentRewriter
+defaults.xmlRewriter = org.apache.portals.applications.webcontent.rewriter.WebContentRewriter
+defaults.htmlAdaptor = org.apache.portals.applications.webcontent.rewriter.html.neko.NekoParserAdaptor
+defaults.xmlAdaptor = org.apache.portals.applications.webcontent.rewriter.xml.SaxParserAdaptor
+defaults.ruleMappings = /WEB-INF/conf/rewriter-rules-mapping.xml
+defaults.rewriterRules = /WEB-INF/conf/default-rewriter-rules.xml
+
+# Proxy Host Configurations
+# ... Set the following when you want to force HOST header value forcefully.
+#proxy.server.hostname = www.localhost.com
+# ... Set the following when you to force to prepend the base url. 
+#proxy.server.baseurl = http://www.localhost.com/
+
+
+# Global HTTP Client parameters
+# ... You can set various http client parameters with prefix, 'proxy.http.client.param.'.
+# ... Refer to the javadoc of org.apache.http.client.params.ClientParamBean.
+proxy.http.client.param.allowCircularRedirects = false
+
+
+# Global HTTP ClientConnectionManager parameters
+# ... You can set various http client connection manager parameters with prefix, 'proxy.http.connManager.param.'.
+# ... Refer to the javadoc of org.apache.http.conn.params.ConnManagerParamBean.
+proxy.http.connManager.param.maxTotalConnections = 200
+proxy.http.connManager.param.timeout = 10000
+
+
+# HTTP Connection parameters per route
+# ... Put the route item names here.
+proxy.http.route = apache, portals, somewhere
+proxy.http.route.param.defaultMaxPerRoute = 20
+
+# ... Sets detail attirbutes for each route item. 
+
+proxy.http.route.apache.target.hostname = www.apache.org
+proxy.http.route.apache.maxConnections = 10
+
+proxy.http.route.portals.target.hostname = portals.apache.org
+proxy.http.route.portals.maxConnections = 40
+
+# ... 'somewhere' is just an example to show the full configurable items...
+proxy.http.route.somewhere.target.hostname = somewhere.localhost.com
+proxy.http.route.somewhere.maxConnections = 5
+proxy.http.route.somewhere.local = 111.111.111.111
+proxy.http.route.somewhere.secure = false
+proxy.http.route.somewhere.tunnelled = plain
+proxy.http.route.somewhere.layered = plain
+proxy.http.route.somewhere.proxy = proxyserver1, proxyserver2
+proxy.http.route.somewhere.proxy.proxyserver1.hostname = proxyserver1
+proxy.http.route.somewhere.proxy.proxyserver1.port = 10080
+proxy.http.route.somewhere.proxy.proxyserver2.hostname = proxyserver2
+proxy.http.route.somewhere.proxy.proxyserver2.port = 10081
+
+
+# Proxy Pass Reverse Mapping configurations for each category
+# ... Put the path item names here. Each path item will be evaluated by the order. 
+proxy.reverse.pass = apache, portals, somewhere 
+
+# ... Sets detail attributes for each path item.
+
+proxy.reverse.pass.apache.local = /apache/
+proxy.reverse.pass.apache.remote = http://www.apache.org/
+
+proxy.reverse.pass.portals.local = /portals/
+proxy.reverse.pass.portals.remote = http://portals.apache.org/
+
+# ... 'somewhere' is just an example to show the full configurable items...
+proxy.reverse.pass.somewhere.local = /somewhere/
+proxy.reverse.pass.somewhere.remote = http://somewhere.localhost.com/
+#proxy.reverse.pass.somewhere.rewriters = ${defaults.htmlRewriter}, ${defaults.xmlRewriter} 
+#proxy.reverse.pass.somewhere.adaptors = ${defaults.htmlAdaptor}, ${defaults.xmlAdaptor}
+#proxy.reverse.pass.somewhere.rules = ${defaults.ruleMappings}, ${defaults.rewriterRules}

Propchange: portals/applications/webcontent/trunk/webcontent-war/src/main/webapp/WEB-INF/conf/reverseproxy.properties
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: portals/applications/webcontent/trunk/webcontent-war/src/main/webapp/WEB-INF/conf/reverseproxy.properties
------------------------------------------------------------------------------
    svn:keywords = Id

Propchange: portals/applications/webcontent/trunk/webcontent-war/src/main/webapp/WEB-INF/conf/reverseproxy.properties
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Modified: portals/applications/webcontent/trunk/webcontent-war/src/main/webapp/WEB-INF/web.xml
URL: http://svn.apache.org/viewvc/portals/applications/webcontent/trunk/webcontent-war/src/main/webapp/WEB-INF/web.xml?rev=818597&r1=818596&r2=818597&view=diff
==============================================================================
--- portals/applications/webcontent/trunk/webcontent-war/src/main/webapp/WEB-INF/web.xml (original)
+++ portals/applications/webcontent/trunk/webcontent-war/src/main/webapp/WEB-INF/web.xml Thu Sep 24 19:19:21 2009
@@ -50,39 +50,10 @@
   <!-- Default Reverse Proxy Servlet -->
   <servlet>
     <servlet-name>ReverseProxyServlet</servlet-name>
-    <servlet-class>
-      org.apache.portals.applications.webcontent.proxy.impl.DefaultHttpReverseProxyServlet</servlet-class>
+    <servlet-class>org.apache.portals.applications.webcontent.proxy.impl.DefaultHttpReverseProxyServlet</servlet-class>
     <init-param>
-      <param-name>reverseproxy.urlmappings</param-name>
-      <param-value>/WEB-INF/conf/reverseproxy-urlmappings.properties</param-value>
-    </init-param>
-    <init-param>
-      <param-name>client.param.allowCircularRedirects</param-name>
-      <param-value>false</param-value>
-    </init-param>
-    <init-param>
-      <param-name>conn.manager.param.maxTotalConnections</param-name>
-      <param-value>200</param-value>
-    </init-param>
-    <init-param>
-      <param-name>conn.manager.param.timeout</param-name>
-      <param-value>10000</param-value>
-    </init-param>
-    <init-param>
-      <param-name>conn.per.route.param.defaultMaxPerRoute</param-name>
-      <param-value>20</param-value>
-    </init-param>
-    <init-param>
-      <param-name>conn.per.route.param.maxForRoutes</param-name>
-      <param-value>
-        {
-          "routes" : 
-          [
-            { "target" : { "hostname" : "portals.apache.org" }, "max" : 40 },
-            { "target" : { "hostname" : "www.apache.org" }, "max" : 20 }
-          ]
-        }
-      </param-value>
+      <param-name>reverseproxy.configuration</param-name>
+      <param-value>/WEB-INF/conf/reverseproxy.properties</param-value>
     </init-param>
     <load-on-startup>11</load-on-startup>
   </servlet>



Mime
View raw message