1
0
mirror of synced 2026-08-04 09:17:02 +00:00

Make classes final where possible

Update classes that have private constructors so that they are also
declared final. In a few cases, inner-classes used private constructors
but were subclassed. These have now been changed to have package-private
constructors.

Issue gh-8945
This commit is contained in:
Phillip Webb
2020-07-24 19:03:31 -07:00
committed by Rob Winch
parent b5d499e2eb
commit 6894ff5d12
58 changed files with 229 additions and 226 deletions
@@ -87,7 +87,7 @@ final class WithUserDetailsSecurityContextFactory implements WithSecurityContext
}
}
private class ReactiveUserDetailsServiceAdapter implements UserDetailsService {
private final class ReactiveUserDetailsServiceAdapter implements UserDetailsService {
private final ReactiveUserDetailsService userDetailsService;
@@ -242,7 +242,10 @@ public class SecurityMockServerConfigurers {
return new CsrfMutator();
}
public static class CsrfMutator implements WebTestClientConfigurer, MockServerConfigurer {
public static final class CsrfMutator implements WebTestClientConfigurer, MockServerConfigurer {
private CsrfMutator() {
}
@Override
public void afterConfigurerAdded(WebTestClient.Builder builder,
@@ -262,9 +265,6 @@ public class SecurityMockServerConfigurers {
}
private CsrfMutator() {
}
}
/**
@@ -272,7 +272,7 @@ public class SecurityMockServerConfigurers {
* SecurityMockServerConfigurers#mockUser(UserDetails)}}. Defaults to use a password
* of "password" and granted authorities of "ROLE_USER".
*/
public static class UserExchangeMutator implements WebTestClientConfigurer, MockServerConfigurer {
public static final class UserExchangeMutator implements WebTestClientConfigurer, MockServerConfigurer {
private final User.UserBuilder userBuilder;
@@ -376,7 +376,7 @@ public class SecurityMockServerConfigurers {
}
private static class MutatorWebTestClientConfigurer implements WebTestClientConfigurer, MockServerConfigurer {
private static final class MutatorWebTestClientConfigurer implements WebTestClientConfigurer, MockServerConfigurer {
private final Supplier<Mono<SecurityContext>> context;
@@ -402,7 +402,7 @@ public class SecurityMockServerConfigurers {
}
private static class SetupMutatorFilter implements WebFilter {
private static final class SetupMutatorFilter implements WebFilter {
private final Supplier<Mono<SecurityContext>> context;
@@ -443,7 +443,7 @@ public class SecurityMockServerConfigurers {
* @author Josh Cummings
* @since 5.2
*/
public static class JwtMutator implements WebTestClientConfigurer, MockServerConfigurer {
public static final class JwtMutator implements WebTestClientConfigurer, MockServerConfigurer {
private Jwt jwt;
@@ -1149,7 +1149,7 @@ public class SecurityMockServerConfigurers {
* Used to wrap the {@link OAuth2AuthorizedClientManager} to provide support for
* testing when the request is wrapped
*/
private static class TestReactiveOAuth2AuthorizedClientManager
private static final class TestReactiveOAuth2AuthorizedClientManager
implements ReactiveOAuth2AuthorizedClientManager {
final static String TOKEN_ATTR_NAME = TestReactiveOAuth2AuthorizedClientManager.class.getName()
@@ -1186,10 +1186,13 @@ public class SecurityMockServerConfigurers {
}
private static class OAuth2ClientServerTestUtils {
private static final class OAuth2ClientServerTestUtils {
private static final ServerOAuth2AuthorizedClientRepository DEFAULT_CLIENT_REPO = new WebSessionServerOAuth2AuthorizedClientRepository();
private OAuth2ClientServerTestUtils() {
}
/**
* Gets the {@link ReactiveOAuth2AuthorizedClientManager} for the specified
* {@link ServerWebExchange}. If one is not found, one based off of
@@ -1278,9 +1281,6 @@ public class SecurityMockServerConfigurers {
}
private OAuth2ClientServerTestUtils() {
}
}
}
@@ -457,7 +457,7 @@ public final class SecurityMockMvcRequestPostProcessors {
/**
* Populates the X509Certificate instances onto the request
*/
private static class X509RequestPostProcessor implements RequestPostProcessor {
private static final class X509RequestPostProcessor implements RequestPostProcessor {
private final X509Certificate[] certificates;
@@ -480,12 +480,15 @@ public final class SecurityMockMvcRequestPostProcessors {
* @author Rob Winch
* @since 4.0
*/
public static class CsrfRequestPostProcessor implements RequestPostProcessor {
public static final class CsrfRequestPostProcessor implements RequestPostProcessor {
private boolean asHeader;
private boolean useInvalidToken;
private CsrfRequestPostProcessor() {
}
/*
* (non-Javadoc)
*
@@ -531,9 +534,6 @@ public final class SecurityMockMvcRequestPostProcessors {
return this;
}
private CsrfRequestPostProcessor() {
}
/**
* Used to wrap the CsrfTokenRepository to provide support for testing when the
* request is wrapped (i.e. Spring Session is in use).
@@ -759,7 +759,7 @@ public final class SecurityMockMvcRequestPostProcessors {
* Used to wrap the SecurityContextRepository to provide support for testing in
* stateless mode
*/
static class TestSecurityContextRepository implements SecurityContextRepository {
static final class TestSecurityContextRepository implements SecurityContextRepository {
private final static String ATTR_NAME = TestSecurityContextRepository.class.getName().concat(".REPO");
@@ -1035,7 +1035,7 @@ public final class SecurityMockMvcRequestPostProcessors {
}
private static class HttpBasicRequestPostProcessor implements RequestPostProcessor {
private static final class HttpBasicRequestPostProcessor implements RequestPostProcessor {
private String headerValue;
@@ -1648,7 +1648,7 @@ public final class SecurityMockMvcRequestPostProcessors {
* Used to wrap the {@link OAuth2AuthorizedClientManager} to provide support for
* testing when the request is wrapped
*/
private static class TestOAuth2AuthorizedClientManager implements OAuth2AuthorizedClientManager {
private static final class TestOAuth2AuthorizedClientManager implements OAuth2AuthorizedClientManager {
final static String TOKEN_ATTR_NAME = TestOAuth2AuthorizedClientManager.class.getName().concat(".TOKEN");
@@ -1682,7 +1682,7 @@ public final class SecurityMockMvcRequestPostProcessors {
}
private static class OAuth2ClientServletTestUtils {
private static final class OAuth2ClientServletTestUtils {
private static final OAuth2AuthorizedClientRepository DEFAULT_CLIENT_REPO = new HttpSessionOAuth2AuthorizedClientRepository();