板桥,这算不算一个问题?

04-02-01 agilejava

请看这里

wes109
2004-02-01 13:37

package com.jdon.webpage.control;

import java.io.IOException;

import java.util.*;

import javax.servlet.*;

import javax.servlet.http.*;

public class ContextSecurityFilter

implements Filter

{

public static final String module;

public FilterConfig config;

public ContextSecurityFilter()

{

}

public void init(FilterConfig config)

{

this.config = config;

}

public void setFilterConfig(FilterConfig config)

{

this.config = config;

}

public FilterConfig getFilterConfig()

{

return config;

}

public void doFilter(ServletRequest request, ServletResponse response, FilterChain chain)

throws ServletException, IOException

{

HttpServletRequest httpRequest = (HttpServletRequest)request;

HttpServletResponseWrapper wrapper = new HttpServletResponseWrapper((HttpServletResponse)response);

String allowedPath = config.getInitParameter("allowedPaths");

String redirectPath = config.getInitParameter("redirectPath");

String errorCode = config.getInitParameter("errorCode");

String allows[] = allowedPath.split(":");

List allowList = new ArrayList();

allowList.addAll(Arrays.asList(allows));

allowList.add("/");

allowList.add("");

String requestPath = httpRequest.getServletPath();

if(requestPath == null)

{

requestPath = "";

}

if(requestPath.lastIndexOf("/") > 0)

{

if(requestPath.indexOf("/") == 0)

{

requestPath = "/".concat(String.valueOf(String.valueOf(requestPath.substring(1, requestPath.indexOf("/", 1)))));

} else

{

requestPath = requestPath.substring(1, requestPath.indexOf("/"));

}

}

String requestInfo = httpRequest.getServletPath();

if(requestInfo == null)

{

requestInfo = "";

}

if(requestInfo.lastIndexOf("/") >= 0)

{

requestInfo = String.valueOf(String.valueOf(requestInfo.substring(0, requestInfo.lastIndexOf("/")))).concat("/*");

}

StringBuffer contextUriBuffer = new StringBuffer();

if(httpRequest.getContextPath() != null)

{

contextUriBuffer.append(httpRequest.getContextPath());

}

if(httpRequest.getServletPath() != null)

{

contextUriBuffer.append(httpRequest.getServletPath());

}

if(httpRequest.getPathInfo() != null)

{

contextUriBuffer.append(httpRequest.getPathInfo());

}

String contextUri = contextUriBuffer.toString();

if(!allowList.contains(requestPath) && !allowList.contains(requestInfo) && !allowList.contains(httpRequest.getServletPath()))

{

String filterMessage = "[Filtered request]: ".concat(String.valueOf(String.valueOf(contextUri)));

if(redirectPath == null || redirectPath.equals(""))

{

int error;

try

{

error = Integer.parseInt(errorCode);

}

catch(NumberFormatException nfe)

{

error = 404;

}

filterMessage = String.valueOf(String.valueOf((new StringBuffer(String.valueOf(String.valueOf(filterMessage)))).append(" (").append(error).append(")")));

wrapper.sendError(error, contextUri);

} else

{

filterMessage = String.valueOf(String.valueOf((new StringBuffer(String.valueOf(String.valueOf(filterMessage)))).append(" (").append(redirectPath).append(")")));

wrapper.sendRedirect(String.valueOf(httpRequest.getContextPath()) + String.valueOf(redirectPath));

}

return;

} else

{

chain.doFilter(request, response);

return;

}

}

public void destroy()

{

config = null;

}

static Class _mthclass$(String x$0)

{

try

{

return Class.forName(x$0);

}

catch(ClassNotFoundException x$0)

{

throw new NoClassDefFoundError(x$0.getMessage());

}

}

static

{

module = (com.jdon.webpage.control.ContextSecurityFilter.class).getName();

}

}

agilejava
2004-02-01 13:44

你这是从哪儿搞下来的?:)

wes109
2004-02-01 13:44

agilejava
2004-02-01 13:46

这个我也发现了,我已经给板桥发邮件了:)

3Go 1 2 3 下一页