1
0
mirror of synced 2026-08-05 17:57:15 +00:00

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:
Phillip Webb
2020-07-27 21:34:26 -07:00
committed by Rob Winch
parent 9a3fa6e812
commit e9130489a6
252 changed files with 2216 additions and 2222 deletions
@@ -28,6 +28,8 @@ import reactor.util.context.Context;
import org.springframework.security.access.AccessDeniedException;
import org.springframework.security.authentication.AuthenticationCredentialsNotFoundException;
import org.springframework.security.authentication.TestingAuthenticationToken;
import org.springframework.security.authorization.AuthenticatedReactiveAuthorizationManager;
import org.springframework.security.authorization.AuthorityReactiveAuthorizationManager;
import org.springframework.security.authorization.ReactiveAuthorizationManager;
import org.springframework.security.core.context.ReactiveSecurityContextHolder;
import org.springframework.security.rsocket.api.PayloadExchange;
@@ -35,8 +37,6 @@ import org.springframework.security.rsocket.api.PayloadInterceptorChain;
import static org.mockito.ArgumentMatchers.any;
import static org.mockito.BDDMockito.given;
import static org.springframework.security.authorization.AuthenticatedReactiveAuthorizationManager.authenticated;
import static org.springframework.security.authorization.AuthorityReactiveAuthorizationManager.hasRole;
/**
* @author Rob Winch
@@ -61,7 +61,8 @@ public class AuthorizationPayloadInterceptorTests {
public void interceptWhenAuthenticationEmptyAndSubscribedThenException() {
given(this.chain.next(any())).willReturn(this.chainResult.mono());
AuthorizationPayloadInterceptor interceptor = new AuthorizationPayloadInterceptor(authenticated());
AuthorizationPayloadInterceptor interceptor = new AuthorizationPayloadInterceptor(
AuthenticatedReactiveAuthorizationManager.authenticated());
StepVerifier.create(interceptor.intercept(this.exchange, this.chain))
.then(() -> this.chainResult.assertWasNotSubscribed())
@@ -83,7 +84,8 @@ public class AuthorizationPayloadInterceptorTests {
public void interceptWhenNotAuthorizedThenException() {
given(this.chain.next(any())).willReturn(this.chainResult.mono());
AuthorizationPayloadInterceptor interceptor = new AuthorizationPayloadInterceptor(hasRole("USER"));
AuthorizationPayloadInterceptor interceptor = new AuthorizationPayloadInterceptor(
AuthorityReactiveAuthorizationManager.hasRole("USER"));
Context userContext = ReactiveSecurityContextHolder
.withAuthentication(new TestingAuthenticationToken("user", "password"));
@@ -97,7 +99,8 @@ public class AuthorizationPayloadInterceptorTests {
public void interceptWhenAuthorizedThenContinues() {
given(this.chain.next(any())).willReturn(this.chainResult.mono());
AuthorizationPayloadInterceptor interceptor = new AuthorizationPayloadInterceptor(authenticated());
AuthorizationPayloadInterceptor interceptor = new AuthorizationPayloadInterceptor(
AuthenticatedReactiveAuthorizationManager.authenticated());
Context userContext = ReactiveSecurityContextHolder
.withAuthentication(new TestingAuthenticationToken("user", "password", "ROLE_USER"));