Author: remy.maucherat(a)jboss.com
Date: 2010-02-03 10:17:04 -0500 (Wed, 03 Feb 2010)
New Revision: 1379
Modified:
trunk/java/org/apache/catalina/valves/RemoteIpValve.java
trunk/java/org/apache/naming/NamingContext.java
trunk/webapps/docs/changelog.xml
Log:
- Port IP valve update.
- createSubcontext oops fix.
Modified: trunk/java/org/apache/catalina/valves/RemoteIpValve.java
===================================================================
--- trunk/java/org/apache/catalina/valves/RemoteIpValve.java 2010-02-02 15:20:12 UTC (rev
1378)
+++ trunk/java/org/apache/catalina/valves/RemoteIpValve.java 2010-02-03 15:17:04 UTC (rev
1379)
@@ -26,10 +26,14 @@
import java.util.regex.PatternSyntaxException;
import javax.servlet.ServletException;
+import javax.servlet.ServletRequest;
+import org.apache.tomcat.util.res.StringManager;
import org.apache.catalina.connector.Request;
import org.apache.catalina.connector.Response;
-import org.apache.tomcat.util.res.StringManager;
+import org.apache.catalina.valves.Constants;
+import org.apache.catalina.valves.RequestFilterValve;
+import org.apache.catalina.valves.ValveBase;
/**
* <p>
@@ -121,6 +125,19 @@
* <td><code>https</code></td>
* </tr>
* <tr>
+ * <td>httpServerPort</td>
+ * <td>Value returned by {@link ServletRequest#getServerPort()} when the
<code>protocolHeader</code> indicates <code>http</code>
protocol</td>
+ * <td>N/A</td>
+ * <td>integer</td>
+ * <td>80</td>
+ * </tr>
+ * <tr>
+ * <td>httpsServerPort</td>
+ * <td>Value returned by {@link ServletRequest#getServerPort()} when the
<code>protocolHeader</code> indicates <code>https</code>
protocol</td>
+ * <td>N/A</td>
+ * <td>integer</td>
+ * <td>443</td>
+ * </tr>
* </table>
* </p>
* <p>
@@ -348,7 +365,7 @@
/**
* The StringManager for this package.
*/
- protected static StringManager sm = StringManager.getManager(Constants.Package);
+ protected static final StringManager sm =
StringManager.getManager(Constants.Package);
/**
* Convert a given comma delimited list of regular expressions into an array of
compiled {@link Pattern}
@@ -411,6 +428,11 @@
}
/**
+ * @see #setHttpServerPort(int)
+ */
+ private int httpServerPort = 80;
+
+ /**
* @see #setHttpsServerPort(int)
*/
private int httpsServerPort = 443;
@@ -452,6 +474,10 @@
return httpsServerPort;
}
+ public int getHttpServerPort() {
+ return httpServerPort;
+ }
+
/**
* Return descriptive information about this Valve implementation.
*/
@@ -503,7 +529,7 @@
public String getRemoteIpHeader() {
return remoteIpHeader;
}
-
+
/**
* @see #setTrustedProxies(String)
* @return comma delimited list of trusted proxies
@@ -576,12 +602,21 @@
if (protocolHeader != null) {
String protocolHeaderValue = request.getHeader(protocolHeader);
- if (protocolHeaderValue != null &&
protocolHeaderHttpsValue.equalsIgnoreCase(protocolHeaderValue)) {
+ if (protocolHeaderValue == null) {
+ // don't modify the secure,scheme and serverPort attributes
+ // of the request
+ } else if
(protocolHeaderHttpsValue.equalsIgnoreCase(protocolHeaderValue)) {
request.setSecure(true);
// use request.coyoteRequest.scheme instead of request.setScheme()
because request.setScheme() is no-op in Tomcat 6.0
request.getCoyoteRequest().scheme().setString("https");
request.setServerPort(httpsServerPort);
+ } else {
+ request.setSecure(false);
+ // use request.coyoteRequest.scheme instead of request.setScheme()
because request.setScheme() is no-op in Tomcat 6.0
+ request.getCoyoteRequest().scheme().setString("http");
+
+ request.setServerPort(httpServerPort);
}
}
@@ -609,6 +644,18 @@
/**
* <p>
+ * Server Port value if the {@link #protocolHeader} is not
<code>null</code> and does not indicate HTTP
+ * </p>
+ * <p>
+ * Default value : 80
+ * </p>
+ */
+ public void setHttpServerPort(int httpServerPort) {
+ this.httpServerPort = httpServerPort;
+ }
+
+ /**
+ * <p>
* Server Port value if the {@link #protocolHeader} indicates HTTPS
* </p>
* <p>
@@ -687,7 +734,7 @@
* Default value : <code>X-Forwarded-For</code>
* </p>
*
- * @param remoteIPHeader
+ * @param remoteIpHeader
*/
public void setRemoteIpHeader(String remoteIpHeader) {
this.remoteIpHeader = remoteIpHeader;
@@ -695,7 +742,7 @@
/**
* <p>
- * Comma delimited list of proxies that are trusted when they appear in the {@link
#remoteIPHeader} header. Can be expressed as a
+ * Comma delimited list of proxies that are trusted when they appear in the {@link
#remoteIpHeader} header. Can be expressed as a
* regular expression.
* </p>
* <p>
Modified: trunk/java/org/apache/naming/NamingContext.java
===================================================================
--- trunk/java/org/apache/naming/NamingContext.java 2010-02-02 15:20:12 UTC (rev 1378)
+++ trunk/java/org/apache/naming/NamingContext.java 2010-02-03 15:17:04 UTC (rev 1379)
@@ -516,7 +516,7 @@
throws NamingException {
checkWritable();
- Context newContext = new NamingContext(env, this.name);
+ Context newContext = new NamingContext(env, name.get(name.size() - 1));
bind(name, newContext);
return newContext;
Modified: trunk/webapps/docs/changelog.xml
===================================================================
--- trunk/webapps/docs/changelog.xml 2010-02-02 15:20:12 UTC (rev 1378)
+++ trunk/webapps/docs/changelog.xml 2010-02-03 15:17:04 UTC (rev 1379)
@@ -25,6 +25,10 @@
<fix>
Add LDAP connection timeout in JNDI realm. (markt)
</fix>
+ <fix>
+ <bug>48050</bug>: createSubcontext method returns Context with wrong
name. Based on a
+ suggestion by gingyang.xu. (markt)
+ </fix>
</changelog>
</subsection>
<subsection name="Coyote">
Show replies by date