Remove restricted static imports
Replace static imports with class referenced methods. With the exception of a few well known static imports, checkstyle restricts the static imports that a class can use. For example, `asList(...)` would be replaced with `Arrays.asList(...)`. Issue gh-8945
This commit is contained in:
@@ -21,6 +21,7 @@ import java.util.Base64;
|
||||
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
|
||||
import org.springframework.http.HttpHeaders;
|
||||
import org.springframework.security.authentication.AuthenticationDetailsSource;
|
||||
import org.springframework.security.authentication.BadCredentialsException;
|
||||
import org.springframework.security.authentication.UsernamePasswordAuthenticationToken;
|
||||
@@ -29,8 +30,6 @@ import org.springframework.security.web.authentication.WebAuthenticationDetailsS
|
||||
import org.springframework.util.Assert;
|
||||
import org.springframework.util.StringUtils;
|
||||
|
||||
import static org.springframework.http.HttpHeaders.AUTHORIZATION;
|
||||
|
||||
/**
|
||||
* Converts from a HttpServletRequest to {@link UsernamePasswordAuthenticationToken} that
|
||||
* can be authenticated. Null authentication possible if there was no Authorization header
|
||||
@@ -76,7 +75,7 @@ public class BasicAuthenticationConverter implements AuthenticationConverter {
|
||||
|
||||
@Override
|
||||
public UsernamePasswordAuthenticationToken convert(HttpServletRequest request) {
|
||||
String header = request.getHeader(AUTHORIZATION);
|
||||
String header = request.getHeader(HttpHeaders.AUTHORIZATION);
|
||||
if (header == null) {
|
||||
return null;
|
||||
}
|
||||
|
||||
@@ -35,8 +35,6 @@ import org.springframework.security.web.util.matcher.RequestMatcher;
|
||||
import org.springframework.util.Assert;
|
||||
import org.springframework.web.filter.OncePerRequestFilter;
|
||||
|
||||
import static java.lang.Boolean.TRUE;
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* Applies
|
||||
@@ -91,7 +89,7 @@ public final class CsrfFilter extends OncePerRequestFilter {
|
||||
|
||||
@Override
|
||||
protected boolean shouldNotFilter(HttpServletRequest request) throws ServletException {
|
||||
return TRUE.equals(request.getAttribute(SHOULD_NOT_FILTER));
|
||||
return Boolean.TRUE.equals(request.getAttribute(SHOULD_NOT_FILTER));
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -135,7 +133,7 @@ public final class CsrfFilter extends OncePerRequestFilter {
|
||||
}
|
||||
|
||||
public static void skipRequest(HttpServletRequest request) {
|
||||
request.setAttribute(SHOULD_NOT_FILTER, TRUE);
|
||||
request.setAttribute(SHOULD_NOT_FILTER, Boolean.TRUE);
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -23,9 +23,6 @@ import org.springframework.security.web.server.util.matcher.ServerWebExchangeMat
|
||||
import org.springframework.util.Assert;
|
||||
import org.springframework.web.server.ServerWebExchange;
|
||||
|
||||
import static org.springframework.security.web.server.util.matcher.ServerWebExchangeMatcher.MatchResult.match;
|
||||
import static org.springframework.security.web.server.util.matcher.ServerWebExchangeMatcher.MatchResult.notMatch;
|
||||
|
||||
/**
|
||||
* Matches if the {@link ServerAuthenticationConverter} can convert a
|
||||
* {@link ServerWebExchange} to an {@link Authentication}.
|
||||
@@ -46,8 +43,8 @@ public final class AuthenticationConverterServerWebExchangeMatcher implements Se
|
||||
|
||||
@Override
|
||||
public Mono<MatchResult> matches(ServerWebExchange exchange) {
|
||||
return this.serverAuthenticationConverter.convert(exchange).flatMap(a -> match()).onErrorResume(e -> notMatch())
|
||||
.switchIfEmpty(notMatch());
|
||||
return this.serverAuthenticationConverter.convert(exchange).flatMap(a -> MatchResult.match())
|
||||
.onErrorResume(e -> MatchResult.notMatch()).switchIfEmpty(MatchResult.notMatch());
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -36,8 +36,6 @@ import org.springframework.web.server.ServerWebExchange;
|
||||
import org.springframework.web.server.WebFilter;
|
||||
import org.springframework.web.server.WebFilterChain;
|
||||
|
||||
import static java.lang.Boolean.TRUE;
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* Applies
|
||||
@@ -114,7 +112,7 @@ public class CsrfWebFilter implements WebFilter {
|
||||
|
||||
@Override
|
||||
public Mono<Void> filter(ServerWebExchange exchange, WebFilterChain chain) {
|
||||
if (TRUE.equals(exchange.getAttribute(SHOULD_NOT_FILTER))) {
|
||||
if (Boolean.TRUE.equals(exchange.getAttribute(SHOULD_NOT_FILTER))) {
|
||||
return chain.filter(exchange).then(Mono.empty());
|
||||
}
|
||||
|
||||
@@ -126,7 +124,7 @@ public class CsrfWebFilter implements WebFilter {
|
||||
}
|
||||
|
||||
public static void skipExchange(ServerWebExchange exchange) {
|
||||
exchange.getAttributes().put(SHOULD_NOT_FILTER, TRUE);
|
||||
exchange.getAttributes().put(SHOULD_NOT_FILTER, Boolean.TRUE);
|
||||
}
|
||||
|
||||
private Mono<Void> validateToken(ServerWebExchange exchange) {
|
||||
|
||||
@@ -25,14 +25,13 @@ import org.springframework.security.web.PortMapperImpl;
|
||||
import org.springframework.security.web.server.DefaultServerRedirectStrategy;
|
||||
import org.springframework.security.web.server.ServerRedirectStrategy;
|
||||
import org.springframework.security.web.server.util.matcher.ServerWebExchangeMatcher;
|
||||
import org.springframework.security.web.server.util.matcher.ServerWebExchangeMatchers;
|
||||
import org.springframework.util.Assert;
|
||||
import org.springframework.web.server.ServerWebExchange;
|
||||
import org.springframework.web.server.WebFilter;
|
||||
import org.springframework.web.server.WebFilterChain;
|
||||
import org.springframework.web.util.UriComponentsBuilder;
|
||||
|
||||
import static org.springframework.security.web.server.util.matcher.ServerWebExchangeMatchers.anyExchange;
|
||||
|
||||
/**
|
||||
* Redirects any non-HTTPS request to its HTTPS equivalent.
|
||||
*
|
||||
@@ -48,7 +47,7 @@ public final class HttpsRedirectWebFilter implements WebFilter {
|
||||
|
||||
private PortMapper portMapper = new PortMapperImpl();
|
||||
|
||||
private ServerWebExchangeMatcher requiresHttpsRedirectMatcher = anyExchange();
|
||||
private ServerWebExchangeMatcher requiresHttpsRedirectMatcher = ServerWebExchangeMatchers.anyExchange();
|
||||
|
||||
private final ServerRedirectStrategy redirectStrategy = new DefaultServerRedirectStrategy();
|
||||
|
||||
|
||||
Reference in New Issue
Block a user