List of usage examples for org.springframework.web.util WebUtils isIncludeRequest
public static boolean isIncludeRequest(ServletRequest request)
From source file:arena.utils.ServletUtils.java
public static String canonicalizeURI(String uri, String webrootPath, HttpServletRequest request, boolean isPublicURI) { boolean isInclude = WebUtils.isIncludeRequest(request); boolean isForward = (request.getAttribute(WebUtils.FORWARD_PATH_INFO_ATTRIBUTE) != null); // Check it's not an illegal URL File webroot = new File(webrootPath); File configFile = new File(webroot, uri); // build a canonical version if we can String canonicalURI = FileUtils.constructOurCanonicalVersion(configFile, webroot); if (!FileUtils.isDescendant(webroot, configFile, webroot)) { return null; // illegal } else if (isPublicURI && !isInclude && !isForward && FileUtils.isDescendant(new File(webroot, "WEB-INF"), configFile, webroot)) { return null; // don't allow direct access to web-inf } else if (isPublicURI && !isInclude && !isForward && FileUtils.isDescendant(new File(webroot, "META-INF"), configFile, webroot)) { return null; // don't allow direct access to meta-inf } else {// w w w . j av a2s.c om return canonicalURI; } }
From source file:net.paoding.rose.web.RequestPath.java
public RequestPath(HttpServletRequest request) { // method//from w ww .j av a 2s .co m setMethod(parseMethod(request)); // ctxpath setCtxpath(request.getContextPath()); String invocationCtxpath = null; // includeinvocationCtxPathincludectxpath // dispather, uri, ctxpath String uri; if (WebUtils.isIncludeRequest(request)) { setDispatcher(Dispatcher.INCLUDE); uri = (String) request.getAttribute(WebUtils.INCLUDE_REQUEST_URI_ATTRIBUTE); invocationCtxpath = ((String) request.getAttribute(WebUtils.INCLUDE_CONTEXT_PATH_ATTRIBUTE)); setRosePath((String) request.getAttribute(WebUtils.INCLUDE_SERVLET_PATH_ATTRIBUTE)); } else { uri = request.getRequestURI(); this.setRosePath(request.getServletPath()); if (request.getAttribute(WebUtils.FORWARD_REQUEST_URI_ATTRIBUTE) == null) { this.setDispatcher(Dispatcher.REQUEST); } else { this.setDispatcher(Dispatcher.FORWARD); } } if (uri.startsWith("http://") || uri.startsWith("https://")) { int start = uri.indexOf('/', 9); if (start == -1) { uri = ""; } else { uri = uri.substring(start); } } if (uri.indexOf('%') != -1) { try { String encoding = request.getCharacterEncoding(); if (encoding == null || encoding.length() == 0) { encoding = "UTF-8"; } uri = URLDecoder.decode(uri, encoding); } catch (UnsupportedEncodingException e) { e.printStackTrace(); } } this.setUri(uri); // requestPathctxpathincludeinvocationCtxpath if (getCtxpath().length() <= 1) { setRosePath(getUri()); } else { setRosePath( getUri().substring((invocationCtxpath == null ? getCtxpath() : invocationCtxpath).length())); } }
From source file:com.sinosoft.one.mvc.web.RequestPath.java
public RequestPath(HttpServletRequest request) { // method/*from w w w.j av a 2s . co m*/ setMethod(parseMethod(request)); // ctxpath setCtxpath(request.getContextPath()); String invocationCtxpath = null; // includeinvocationCtxPathincludectxpath // dispather, uri, ctxpath String uri; if (WebUtils.isIncludeRequest(request)) { setDispatcher(Dispatcher.INCLUDE); uri = (String) request.getAttribute(WebUtils.INCLUDE_REQUEST_URI_ATTRIBUTE); invocationCtxpath = ((String) request.getAttribute(WebUtils.INCLUDE_CONTEXT_PATH_ATTRIBUTE)); setMvcPath((String) request.getAttribute(WebUtils.INCLUDE_SERVLET_PATH_ATTRIBUTE)); } else { if (request.getAttribute(MvcConstants.WINDOW_REQUEST_URI) != null) { uri = (String) request.getAttribute(MvcConstants.WINDOW_REQUEST_URI); request.removeAttribute(MvcConstants.WINDOW_REQUEST_URI); request.setAttribute(MvcConstants.IS_WINDOW_REQUEST, "1"); } else { uri = request.getRequestURI(); request.removeAttribute(MvcConstants.IS_WINDOW_REQUEST); } this.setMvcPath(request.getServletPath()); if (request.getAttribute(WebUtils.FORWARD_REQUEST_URI_ATTRIBUTE) == null) { this.setDispatcher(Dispatcher.REQUEST); } else { this.setDispatcher(Dispatcher.FORWARD); } } if (uri.startsWith("http://") || uri.startsWith("https://")) { int start = uri.indexOf('/', 9); if (start == -1) { uri = ""; } else { uri = uri.substring(start); } } if (uri.indexOf('%') != -1) { try { String encoding = request.getCharacterEncoding(); if (encoding == null || encoding.length() == 0) { encoding = "UTF-8"; } uri = URLDecoder.decode(uri, encoding); } catch (UnsupportedEncodingException e) { e.printStackTrace(); } } this.setUri(uri); // requestPathctxpathincludeinvocationCtxpath if (getCtxpath().length() <= 1) { setMvcPath(getUri()); } else { setMvcPath(getUri().substring((invocationCtxpath == null ? getCtxpath() : invocationCtxpath).length())); } }
From source file:com.epam.ta.reportportal.commons.exception.rest.RestExceptionHandler.java
private void applyStatusIfPossible(ServletWebRequest webRequest, HttpStatus status) { if (!WebUtils.isIncludeRequest(webRequest.getRequest())) { webRequest.getResponse().setStatus(status.value()); }// www.j a va 2 s . c om }
From source file:org.bremersee.common.spring.autoconfigure.WebMvcExceptionResolver.java
void applyStatusCodeIfPossible(HttpServletRequest request, HttpServletResponse response, int statusCode) { if (!WebUtils.isIncludeRequest(request)) { if (log.isDebugEnabled()) { log.debug("Applying HTTP status code " + statusCode); }//from w w w . j a v a2 s. c om response.setStatus(statusCode); request.setAttribute(WebUtils.ERROR_STATUS_CODE_ATTRIBUTE, statusCode); } }
From source file:it.unitn.disi.smatch.web.server.api.handlers.ExceptionDetailsExceptionResolver.java
private void applyStatusIfPossible(ServletWebRequest webRequest, ExceptionDetails error) { if (!WebUtils.isIncludeRequest(webRequest.getRequest())) { webRequest.getResponse().setStatus(error.getStatus()); }/*w w w. j av a 2s.co m*/ }
From source file:com.oolong.platform.web.error.RestExceptionHandler.java
private void applyStatusIfPossible(ServletWebRequest webRequest, RestError error) { if (!WebUtils.isIncludeRequest(webRequest.getRequest())) { webRequest.getResponse().setStatus(error.getStatus().value()); }//w ww.j av a2 s . c o m // TODO support response.sendError ? }
From source file:com.novation.eligibility.rest.spring.web.servlet.handler.RestExceptionHandler.java
private void applyStatusIfPossible(ServletWebRequest webRequest, RestError error) { if (!WebUtils.isIncludeRequest(webRequest.getRequest())) { webRequest.getResponse().setStatus(error.getStatus().value()); }/*from w ww . j a v a 2 s .c om*/ //TODO support response.sendError ? }
From source file:org.jlot.web.api.error.RestExceptionHandler.java
private void applyStatusIfPossible(ServletWebRequest webRequest, RestError error) { if (!WebUtils.isIncludeRequest(webRequest.getRequest())) { webRequest.getResponse().setStatus(error.getStatusCode()); }/* w w w. j a v a 2 s. c o m*/ // TODO support response.sendError ? }