mirror of https://github.com/apache/activemq.git
https://issues.apache.org/activemq/browse/AMQ-2600 - jetty 7 - fileserver app fixed
git-svn-id: https://svn.apache.org/repos/asf/activemq/trunk@908476 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
25f476624f
commit
47b09a2a89
|
@ -38,7 +38,7 @@
|
||||||
<version>${jetty-version}</version>
|
<version>${jetty-version}</version>
|
||||||
<configuration>
|
<configuration>
|
||||||
<connectors>
|
<connectors>
|
||||||
<connector implementation="org.eclipse.jetty.nio.SelectChannelConnector">
|
<connector implementation="org.eclipse.jetty.server.nio.SelectChannelConnector">
|
||||||
<port>${jetty.port}</port>
|
<port>${jetty.port}</port>
|
||||||
<maxIdleTime>60000</maxIdleTime>
|
<maxIdleTime>60000</maxIdleTime>
|
||||||
</connector>
|
</connector>
|
||||||
|
|
|
@ -27,10 +27,14 @@ import javax.servlet.ServletResponse;
|
||||||
import javax.servlet.http.HttpServletRequest;
|
import javax.servlet.http.HttpServletRequest;
|
||||||
import javax.servlet.http.HttpServletRequestWrapper;
|
import javax.servlet.http.HttpServletRequestWrapper;
|
||||||
|
|
||||||
import org.eclipse.jetty.util.log.Log;
|
import org.apache.commons.logging.Log;
|
||||||
|
import org.apache.commons.logging.LogFactory;
|
||||||
|
|
||||||
|
|
||||||
public class FilenameGuardFilter implements Filter {
|
public class FilenameGuardFilter implements Filter {
|
||||||
|
|
||||||
|
private static final Log LOG = LogFactory.getLog(FilenameGuardFilter.class);
|
||||||
|
|
||||||
public void destroy() {
|
public void destroy() {
|
||||||
// nothing to destroy
|
// nothing to destroy
|
||||||
}
|
}
|
||||||
|
@ -57,8 +61,8 @@ public class FilenameGuardFilter implements Filter {
|
||||||
|
|
||||||
private String guard(String filename) {
|
private String guard(String filename) {
|
||||||
String guarded = filename.replace(":", "_");
|
String guarded = filename.replace(":", "_");
|
||||||
if (Log.isDebugEnabled()) {
|
if (LOG.isDebugEnabled()) {
|
||||||
Log.debug("guarded " + filename + " to " + guarded);
|
LOG.debug("guarded " + filename + " to " + guarded);
|
||||||
}
|
}
|
||||||
return guarded;
|
return guarded;
|
||||||
}
|
}
|
||||||
|
|
|
@ -36,9 +36,11 @@ import javax.servlet.UnavailableException;
|
||||||
import javax.servlet.http.HttpServletRequest;
|
import javax.servlet.http.HttpServletRequest;
|
||||||
import javax.servlet.http.HttpServletResponse;
|
import javax.servlet.http.HttpServletResponse;
|
||||||
|
|
||||||
|
import org.apache.commons.logging.Log;
|
||||||
|
import org.apache.commons.logging.LogFactory;
|
||||||
import org.eclipse.jetty.util.IO;
|
import org.eclipse.jetty.util.IO;
|
||||||
import org.eclipse.jetty.util.URIUtil;
|
import org.eclipse.jetty.util.URIUtil;
|
||||||
import org.eclipse.jetty.util.log.Log;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* <p>
|
* <p>
|
||||||
|
@ -50,6 +52,7 @@ import org.eclipse.jetty.util.log.Log;
|
||||||
* @author Aleksi Kallio
|
* @author Aleksi Kallio
|
||||||
*/
|
*/
|
||||||
public class RestFilter implements Filter {
|
public class RestFilter implements Filter {
|
||||||
|
private static final Log LOG = LogFactory.getLog(RestFilter.class);
|
||||||
|
|
||||||
private static final String HTTP_HEADER_DESTINATION = "Destination";
|
private static final String HTTP_HEADER_DESTINATION = "Destination";
|
||||||
private static final String HTTP_METHOD_MOVE = "MOVE";
|
private static final String HTTP_METHOD_MOVE = "MOVE";
|
||||||
|
@ -73,8 +76,8 @@ public class RestFilter implements Filter {
|
||||||
|
|
||||||
public void doFilter(ServletRequest request, ServletResponse response, FilterChain chain) throws IOException, ServletException {
|
public void doFilter(ServletRequest request, ServletResponse response, FilterChain chain) throws IOException, ServletException {
|
||||||
if (!(request instanceof HttpServletRequest && response instanceof HttpServletResponse)) {
|
if (!(request instanceof HttpServletRequest && response instanceof HttpServletResponse)) {
|
||||||
if (Log.isDebugEnabled()) {
|
if (LOG.isDebugEnabled()) {
|
||||||
Log.debug("request not HTTP, can not understand: " + request.toString());
|
LOG.debug("request not HTTP, can not understand: " + request.toString());
|
||||||
}
|
}
|
||||||
chain.doFilter(request, response);
|
chain.doFilter(request, response);
|
||||||
return;
|
return;
|
||||||
|
@ -100,8 +103,8 @@ public class RestFilter implements Filter {
|
||||||
}
|
}
|
||||||
|
|
||||||
protected void doMove(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
|
protected void doMove(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
|
||||||
if (Log.isDebugEnabled()) {
|
if (LOG.isDebugEnabled()) {
|
||||||
Log.debug("RESTful file access: MOVE request for " + request.getRequestURI());
|
LOG.debug("RESTful file access: MOVE request for " + request.getRequestURI());
|
||||||
}
|
}
|
||||||
|
|
||||||
if (writePermissionRole != null && !request.isUserInRole(writePermissionRole)) {
|
if (writePermissionRole != null && !request.isUserInRole(writePermissionRole)) {
|
||||||
|
@ -135,8 +138,8 @@ public class RestFilter implements Filter {
|
||||||
}
|
}
|
||||||
|
|
||||||
protected boolean checkGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
|
protected boolean checkGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
|
||||||
if (Log.isDebugEnabled()) {
|
if (LOG.isDebugEnabled()) {
|
||||||
Log.debug("RESTful file access: GET request for " + request.getRequestURI());
|
LOG.debug("RESTful file access: GET request for " + request.getRequestURI());
|
||||||
}
|
}
|
||||||
|
|
||||||
if (readPermissionRole != null && !request.isUserInRole(readPermissionRole)) {
|
if (readPermissionRole != null && !request.isUserInRole(readPermissionRole)) {
|
||||||
|
@ -148,8 +151,8 @@ public class RestFilter implements Filter {
|
||||||
}
|
}
|
||||||
|
|
||||||
protected void doPut(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
|
protected void doPut(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
|
||||||
if (Log.isDebugEnabled()) {
|
if (LOG.isDebugEnabled()) {
|
||||||
Log.debug("RESTful file access: PUT request for " + request.getRequestURI());
|
LOG.debug("RESTful file access: PUT request for " + request.getRequestURI());
|
||||||
}
|
}
|
||||||
|
|
||||||
if (writePermissionRole != null && !request.isUserInRole(writePermissionRole)) {
|
if (writePermissionRole != null && !request.isUserInRole(writePermissionRole)) {
|
||||||
|
@ -177,7 +180,7 @@ public class RestFilter implements Filter {
|
||||||
try {
|
try {
|
||||||
IO.copy(request.getInputStream(), out);
|
IO.copy(request.getInputStream(), out);
|
||||||
} catch (IOException e) {
|
} catch (IOException e) {
|
||||||
Log.warn(Log.EXCEPTION, e); // is this obsolete?
|
LOG.warn("Exception occured" , e);
|
||||||
out.close();
|
out.close();
|
||||||
throw e;
|
throw e;
|
||||||
}
|
}
|
||||||
|
@ -187,8 +190,8 @@ public class RestFilter implements Filter {
|
||||||
}
|
}
|
||||||
|
|
||||||
protected void doDelete(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
|
protected void doDelete(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
|
||||||
if (Log.isDebugEnabled()) {
|
if (LOG.isDebugEnabled()) {
|
||||||
Log.debug("RESTful file access: DELETE request for " + request.getRequestURI());
|
LOG.debug("RESTful file access: DELETE request for " + request.getRequestURI());
|
||||||
}
|
}
|
||||||
|
|
||||||
if (writePermissionRole != null && !request.isUserInRole(writePermissionRole)) {
|
if (writePermissionRole != null && !request.isUserInRole(writePermissionRole)) {
|
||||||
|
|
|
@ -25,7 +25,7 @@
|
||||||
|
|
||||||
<servlet>
|
<servlet>
|
||||||
<servlet-name>DefaultServlet</servlet-name>
|
<servlet-name>DefaultServlet</servlet-name>
|
||||||
<servlet-class>org.mortbay.jetty.servlet.DefaultServlet</servlet-class>
|
<servlet-class>org.eclipse.jetty.servlet.DefaultServlet</servlet-class>
|
||||||
</servlet>
|
</servlet>
|
||||||
|
|
||||||
<servlet-mapping>
|
<servlet-mapping>
|
||||||
|
|
|
@ -58,13 +58,11 @@
|
||||||
<property name="resourceBase" value="${activemq.base}/webapps/demo"/>
|
<property name="resourceBase" value="${activemq.base}/webapps/demo"/>
|
||||||
<property name="logUrlOnStart" value="true"/>
|
<property name="logUrlOnStart" value="true"/>
|
||||||
</bean>
|
</bean>
|
||||||
<!--
|
|
||||||
<bean class="org.eclipse.jetty.webapp.WebAppContext">
|
<bean class="org.eclipse.jetty.webapp.WebAppContext">
|
||||||
<property name="contextPath" value="/fileserver"/>
|
<property name="contextPath" value="/fileserver"/>
|
||||||
<property name="resourceBase" value="${activemq.base}/webapps/fileserver"/>
|
<property name="resourceBase" value="${activemq.base}/webapps/fileserver"/>
|
||||||
<property name="logUrlOnStart" value="true"/>
|
<property name="logUrlOnStart" value="true"/>
|
||||||
</bean>
|
</bean>
|
||||||
-->
|
|
||||||
<bean id="defaultHandler" class="org.eclipse.jetty.server.handler.DefaultHandler"/>
|
<bean id="defaultHandler" class="org.eclipse.jetty.server.handler.DefaultHandler"/>
|
||||||
</list>
|
</list>
|
||||||
</property>
|
</property>
|
||||||
|
|
Loading…
Reference in New Issue