|
|
|
@ -40,6 +40,7 @@ import org.springframework.security.web.firewall.HttpStatusRequestRejectedHandle |
|
|
|
import org.springframework.security.web.firewall.RequestRejectedException; |
|
|
|
import org.springframework.security.web.firewall.RequestRejectedException; |
|
|
|
import org.springframework.security.web.firewall.RequestRejectedHandler; |
|
|
|
import org.springframework.security.web.firewall.RequestRejectedHandler; |
|
|
|
import org.springframework.security.web.firewall.StrictHttpFirewall; |
|
|
|
import org.springframework.security.web.firewall.StrictHttpFirewall; |
|
|
|
|
|
|
|
import org.springframework.security.web.util.ThrowableAnalyzer; |
|
|
|
import org.springframework.security.web.util.UrlUtils; |
|
|
|
import org.springframework.security.web.util.UrlUtils; |
|
|
|
import org.springframework.security.web.util.matcher.RequestMatcher; |
|
|
|
import org.springframework.security.web.util.matcher.RequestMatcher; |
|
|
|
import org.springframework.util.Assert; |
|
|
|
import org.springframework.util.Assert; |
|
|
|
@ -157,6 +158,8 @@ public class FilterChainProxy extends GenericFilterBean { |
|
|
|
|
|
|
|
|
|
|
|
private RequestRejectedHandler requestRejectedHandler = new HttpStatusRequestRejectedHandler(); |
|
|
|
private RequestRejectedHandler requestRejectedHandler = new HttpStatusRequestRejectedHandler(); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
private ThrowableAnalyzer throwableAnalyzer = new ThrowableAnalyzer(); |
|
|
|
|
|
|
|
|
|
|
|
public FilterChainProxy() { |
|
|
|
public FilterChainProxy() { |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
@ -185,8 +188,15 @@ public class FilterChainProxy extends GenericFilterBean { |
|
|
|
request.setAttribute(FILTER_APPLIED, Boolean.TRUE); |
|
|
|
request.setAttribute(FILTER_APPLIED, Boolean.TRUE); |
|
|
|
doFilterInternal(request, response, chain); |
|
|
|
doFilterInternal(request, response, chain); |
|
|
|
} |
|
|
|
} |
|
|
|
catch (RequestRejectedException ex) { |
|
|
|
catch (Exception ex) { |
|
|
|
this.requestRejectedHandler.handle((HttpServletRequest) request, (HttpServletResponse) response, ex); |
|
|
|
Throwable[] causeChain = this.throwableAnalyzer.determineCauseChain(ex); |
|
|
|
|
|
|
|
Throwable requestRejectedException = this.throwableAnalyzer |
|
|
|
|
|
|
|
.getFirstThrowableOfType(RequestRejectedException.class, causeChain); |
|
|
|
|
|
|
|
if (!(requestRejectedException instanceof RequestRejectedException)) { |
|
|
|
|
|
|
|
throw ex; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
this.requestRejectedHandler.handle((HttpServletRequest) request, (HttpServletResponse) response, |
|
|
|
|
|
|
|
(RequestRejectedException) requestRejectedException); |
|
|
|
} |
|
|
|
} |
|
|
|
finally { |
|
|
|
finally { |
|
|
|
this.securityContextHolderStrategy.clearContext(); |
|
|
|
this.securityContextHolderStrategy.clearContext(); |
|
|
|
|