I have SecurityAuthorisationFilter and the following part of the code:
for(String anonymousRequestURI : anonymousRequestURIs) {
if(httpRequest.getRequestURI().equals(anonymousRequestURI)) {
//allow request
}
}
String authToken = getTokenFromRequest(httpRequest);
If equals is true I need to skip all next filter operations and send request to controller. But, if I write filterChain.doFilter(servletRequest, servletResponse), there is no result. The filter continue operations to find a token. How can I break out of the filter?
As I understand from your comment, you wish to "break out" of the current filter if the condition about anonymous request URI is true. You could simply return; after calling chain.doFilter():
for ( String uri : anonURIs ) {
if ( ... ) {
chain.doFilter( ... );
return;
}
}
String authToken = getTokenFromRequest( httpRequest );
...
Cheers,
Well if breakdoesn't give you what you need you can change your loop like this:
int i=0;
do {
anonymousRequestURI = anonymousRequestURIs[i];
i++;
while(!httpRequest.getRequestURI().equals(anonymousRequestURI) && i<anonymousRequestURIs.length);
String authToken = getTokenFromRequest(httpRequest);
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With