* @see #setRemoteIpHeader(String)
*/
private String remoteIpHeader = "X-Forwarded-For";
-
+
+ /**
+ * @see #setRequestAttributesEnabled(boolean)
+ */
+ private boolean requestAttributesEnabled = true;
+
/**
* @see RemoteIpValve#setTrustedProxies(String)
*/
}
/**
+ * @see #setRequestAttributesEnabled(boolean)
+ * @return <code>true</code> if the attributes will be logged, otherwise
+ * <code>false</code>
+ */
+ public boolean getRequestAttributesEnabled() {
+ return requestAttributesEnabled;
+ }
+
+ /**
* @see #setTrustedProxies(String)
* @return Regular expression that defines the trusted proxies
*/
+ request.getRemoteAddr() + "'");
}
}
+ if (requestAttributesEnabled) {
+ request.setAttribute("org.apache.catalina.RemoteAddr",
+ request.getRemoteAddr());
+ request.setAttribute("org.apache.catalina.RemoteHost",
+ request.getRemoteHost());
+ request.setAttribute("org.apache.catalina.Protocol",
+ request.getProtocol());
+ request.setAttribute("org.apache.catalina.ServerPort",
+ Integer.valueOf(request.getServerPort()));
+ }
try {
getNext().invoke(request, response);
} finally {
}
/**
+ * Should this valve set request attributes for IP address, Hostname,
+ * protocol and port used for the request? This are typically used in
+ * conjunction with the {@link AccessLogValve} which will otherwise log the
+ * original values. Default is <code>true</code>.
+ *
+ * The attributes set are:
+ * <ul>
+ * <li>org.apache.catalina.RemoteAddr</li>
+ * <li>org.apache.catalina.RemoteHost</li>
+ * <li>org.apache.catalina.Protocol</li>
+ * <li>org.apache.catalina.ServerPost</li>
+ * </ul>
+ *
+ * @param requestAttributesEnabled <code>true</code> causes the attributes
+ * to be set, <code>false</code> disables
+ * the setting of the attributes.
+ */
+ public void setRequestAttributesEnabled(boolean requestAttributesEnabled) {
+ this.requestAttributesEnabled = requestAttributesEnabled;
+ }
+
+ /**
* <p>
* Regular expression defining proxies that are trusted when they appear in
* the {@link #remoteIpHeader} header.