1
0
mirror of synced 2026-05-22 21:33:16 +00:00

Reduce method visibility when possible

Reduce method visibility for package private classes when possible.

In the case of abstract classes that will eventually be made public,
the class has been made public and a package-private constructor has
been added.

Issue gh-8945
This commit is contained in:
Phillip Webb
2020-07-29 22:05:08 -07:00
committed by Rob Winch
parent ec6a4cb3f0
commit 8d3f039f76
155 changed files with 508 additions and 477 deletions
@@ -186,11 +186,11 @@ public class WithSecurityContextTestExecutionListener extends AbstractTestExecut
this.testExecutionEvent = testExecutionEvent;
}
public Supplier<SecurityContext> getSecurityContextSupplier() {
Supplier<SecurityContext> getSecurityContextSupplier() {
return this.securityContextSupplier;
}
public TestExecutionEvent getTestExecutionEvent() {
TestExecutionEvent getTestExecutionEvent() {
return this.testExecutionEvent;
}
@@ -77,7 +77,7 @@ final class WithUserDetailsSecurityContextFactory implements WithSecurityContext
: this.beans.getBean(UserDetailsService.class);
}
public UserDetailsService findAndAdaptReactiveUserDetailsService(String beanName) {
UserDetailsService findAndAdaptReactiveUserDetailsService(String beanName) {
try {
ReactiveUserDetailsService reactiveUserDetailsService = StringUtils.hasLength(beanName)
? this.beans.getBean(beanName, ReactiveUserDetailsService.class)
@@ -1178,11 +1178,11 @@ public final class SecurityMockServerConfigurers {
}
}
public static void enable(ServerWebExchange exchange) {
static void enable(ServerWebExchange exchange) {
exchange.getAttributes().put(ENABLED_ATTR_NAME, Boolean.TRUE);
}
public boolean isEnabled(ServerWebExchange exchange) {
boolean isEnabled(ServerWebExchange exchange) {
return Boolean.TRUE.equals(exchange.getAttribute(ENABLED_ATTR_NAME));
}
@@ -1204,8 +1204,7 @@ public final class SecurityMockServerConfigurers {
* @return the {@link ReactiveOAuth2AuthorizedClientManager} for the specified
* {@link ServerWebExchange}
*/
public static ReactiveOAuth2AuthorizedClientManager getOAuth2AuthorizedClientManager(
ServerWebExchange exchange) {
static ReactiveOAuth2AuthorizedClientManager getOAuth2AuthorizedClientManager(ServerWebExchange exchange) {
OAuth2AuthorizedClientArgumentResolver resolver = findResolver(exchange,
OAuth2AuthorizedClientArgumentResolver.class);
if (resolver == null) {
@@ -1223,7 +1222,7 @@ public final class SecurityMockServerConfigurers {
* {@link ReactiveOAuth2AuthorizedClientManager}
* @param manager the {@link ReactiveOAuth2AuthorizedClientManager} to set
*/
public static void setOAuth2AuthorizedClientManager(ServerWebExchange exchange,
static void setOAuth2AuthorizedClientManager(ServerWebExchange exchange,
ReactiveOAuth2AuthorizedClientManager manager) {
OAuth2AuthorizedClientArgumentResolver resolver = findResolver(exchange,
OAuth2AuthorizedClientArgumentResolver.class);
@@ -568,11 +568,11 @@ public final class SecurityMockMvcRequestPostProcessors {
}
}
public static void enable(HttpServletRequest request) {
static void enable(HttpServletRequest request) {
request.setAttribute(ENABLED_ATTR_NAME, Boolean.TRUE);
}
public boolean isEnabled(HttpServletRequest request) {
boolean isEnabled(HttpServletRequest request) {
return Boolean.TRUE.equals(request.getAttribute(ENABLED_ATTR_NAME));
}
@@ -1659,11 +1659,11 @@ public final class SecurityMockMvcRequestPostProcessors {
}
}
public static void enable(HttpServletRequest request) {
static void enable(HttpServletRequest request) {
request.setAttribute(ENABLED_ATTR_NAME, Boolean.TRUE);
}
public boolean isEnabled(HttpServletRequest request) {
boolean isEnabled(HttpServletRequest request) {
return Boolean.TRUE.equals(request.getAttribute(ENABLED_ATTR_NAME));
}
@@ -1673,6 +1673,9 @@ public final class SecurityMockMvcRequestPostProcessors {
private static final OAuth2AuthorizedClientRepository DEFAULT_CLIENT_REPO = new HttpSessionOAuth2AuthorizedClientRepository();
private OAuth2ClientServletTestUtils() {
}
/**
* Gets the {@link OAuth2AuthorizedClientManager} for the specified
* {@link HttpServletRequest}. If one is not found, one based off of
@@ -1682,7 +1685,7 @@ public final class SecurityMockMvcRequestPostProcessors {
* @return the {@link OAuth2AuthorizedClientManager} for the specified
* {@link HttpServletRequest}
*/
public static OAuth2AuthorizedClientManager getOAuth2AuthorizedClientManager(HttpServletRequest request) {
static OAuth2AuthorizedClientManager getOAuth2AuthorizedClientManager(HttpServletRequest request) {
OAuth2AuthorizedClientArgumentResolver resolver = findResolver(request,
OAuth2AuthorizedClientArgumentResolver.class);
if (resolver == null) {
@@ -1700,7 +1703,7 @@ public final class SecurityMockMvcRequestPostProcessors {
* {@link OAuth2AuthorizedClientManager}
* @param manager the {@link OAuth2AuthorizedClientManager} to set
*/
public static void setOAuth2AuthorizedClientManager(HttpServletRequest request,
static void setOAuth2AuthorizedClientManager(HttpServletRequest request,
OAuth2AuthorizedClientManager manager) {
OAuth2AuthorizedClientArgumentResolver resolver = findResolver(request,
OAuth2AuthorizedClientArgumentResolver.class);
@@ -1755,9 +1758,6 @@ public final class SecurityMockMvcRequestPostProcessors {
}
private OAuth2ClientServletTestUtils() {
}
}
}
@@ -51,7 +51,7 @@ public class WithMockUserParentTests extends WithMockUserParent {
static class Config {
@Autowired
public void configureGlobal(AuthenticationManagerBuilder auth) throws Exception {
void configureGlobal(AuthenticationManagerBuilder auth) throws Exception {
// @formatter:off
auth
.inMemoryAuthentication()
@@ -81,7 +81,7 @@ public class WithMockUserTests {
static class Config {
@Autowired
public void configureGlobal(AuthenticationManagerBuilder auth) throws Exception {
void configureGlobal(AuthenticationManagerBuilder auth) throws Exception {
// @formatter:off
auth
.inMemoryAuthentication()
@@ -86,15 +86,12 @@ public class WithUserDetailsTests {
static class Config {
@Autowired
public void configureGlobal(AuthenticationManagerBuilder auth) throws Exception {
// @formatter:off
auth
.userDetailsService(myUserDetailsService());
// @formatter:on
void configureGlobal(AuthenticationManagerBuilder auth) throws Exception {
auth.userDetailsService(myUserDetailsService());
}
@Bean
public UserDetailsService myUserDetailsService() {
UserDetailsService myUserDetailsService() {
return new CustomUserDetailsService();
}
@@ -163,12 +163,11 @@ public class WithSecurityContextTestExcecutionListenerTests {
static class FakeTest {
public void testNoAnnotation() {
void testNoAnnotation() {
}
@WithMockUser
public void testWithMockUser() {
void testWithMockUser() {
}
}
@@ -133,7 +133,7 @@ public class Sec2935Tests {
}
@Autowired
public void configureGlobal(AuthenticationManagerBuilder auth) throws Exception {
void configureGlobal(AuthenticationManagerBuilder auth) throws Exception {
auth.inMemoryAuthentication();
}
@@ -85,7 +85,7 @@ public class SecurityMockMvcRequestPostProcessorsAuthenticationStatelessTests {
}
@Autowired
public void configureGlobal(AuthenticationManagerBuilder auth) throws Exception {
void configureGlobal(AuthenticationManagerBuilder auth) throws Exception {
// @formatter:off
auth
.inMemoryAuthentication();
@@ -96,7 +96,7 @@ public class SecurityMockMvcRequestPostProcessorsAuthenticationStatelessTests {
static class Controller {
@RequestMapping
public String hello() {
String hello() {
return "Hello";
}
@@ -83,18 +83,15 @@ public class SecurityMockMvcRequestPostProcessorsTestSecurityContextStatelessTes
}
@Autowired
public void configureGlobal(AuthenticationManagerBuilder auth) throws Exception {
// @formatter:off
auth
.inMemoryAuthentication();
// @formatter:on
void configureGlobal(AuthenticationManagerBuilder auth) throws Exception {
auth.inMemoryAuthentication();
}
@RestController
static class Controller {
@RequestMapping
public String hello() {
String hello() {
return "Hello";
}
@@ -113,7 +113,7 @@ public class SecurityMockMvcResultMatchersTests {
static class Controller {
@RequestMapping("/")
public String ok() {
String ok() {
return "ok";
}
@@ -93,7 +93,7 @@ public class SecurityMockWithAuthoritiesMvcResultMatchersTests {
static class Controller {
@RequestMapping("/")
public String ok() {
String ok() {
return "ok";
}
@@ -78,7 +78,7 @@ public class CsrfShowcaseTests {
}
@Autowired
public void configureGlobal(AuthenticationManagerBuilder auth) throws Exception {
void configureGlobal(AuthenticationManagerBuilder auth) throws Exception {
// @formatter:off
auth
.inMemoryAuthentication()
@@ -86,7 +86,7 @@ public class CustomCsrfShowcaseTests {
}
@Autowired
public void configureGlobal(AuthenticationManagerBuilder auth) throws Exception {
void configureGlobal(AuthenticationManagerBuilder auth) throws Exception {
// @formatter:off
auth
.inMemoryAuthentication()
@@ -95,7 +95,7 @@ public class CustomCsrfShowcaseTests {
}
@Bean
public CsrfTokenRepository repo() {
CsrfTokenRepository repo() {
HttpSessionCsrfTokenRepository repo = new HttpSessionCsrfTokenRepository();
repo.setParameterName("custom_csrf");
return repo;
@@ -75,7 +75,7 @@ public class DefaultCsrfShowcaseTests {
}
@Autowired
public void configureGlobal(AuthenticationManagerBuilder auth) throws Exception {
void configureGlobal(AuthenticationManagerBuilder auth) throws Exception {
// @formatter:off
auth
.inMemoryAuthentication()
@@ -117,7 +117,7 @@ public class CustomConfigAuthenticationTests {
// @formatter:on
@Bean
public SecurityContextRepository securityContextRepository() {
SecurityContextRepository securityContextRepository() {
HttpSessionSecurityContextRepository repo = new HttpSessionSecurityContextRepository();
repo.setSpringSecurityContextKey("CUSTOM");
return repo;
@@ -101,7 +101,7 @@ public class DefaultfSecurityRequestsTests {
}
@Autowired
public void configureGlobal(AuthenticationManagerBuilder auth) throws Exception {
void configureGlobal(AuthenticationManagerBuilder auth) throws Exception {
// @formatter:off
auth
.inMemoryAuthentication()
@@ -118,7 +118,7 @@ public class SecurityRequestsTests {
}
@Autowired
public void configureGlobal(AuthenticationManagerBuilder auth) throws Exception {
void configureGlobal(AuthenticationManagerBuilder auth) throws Exception {
// @formatter:off
auth
.inMemoryAuthentication()
@@ -102,7 +102,7 @@ public class WithUserAuthenticationTests {
}
@Autowired
public void configureGlobal(AuthenticationManagerBuilder auth) throws Exception {
void configureGlobal(AuthenticationManagerBuilder auth) throws Exception {
// @formatter:off
auth
.inMemoryAuthentication()
@@ -102,7 +102,7 @@ public class WithUserClassLevelAuthenticationTests {
}
@Autowired
public void configureGlobal(AuthenticationManagerBuilder auth) throws Exception {
void configureGlobal(AuthenticationManagerBuilder auth) throws Exception {
// @formatter:off
auth
.inMemoryAuthentication()
@@ -99,7 +99,7 @@ public class WithUserDetailsAuthenticationTests {
}
@Autowired
public void configureGlobal(AuthenticationManagerBuilder auth) throws Exception {
void configureGlobal(AuthenticationManagerBuilder auth) throws Exception {
// @formatter:off
auth
.inMemoryAuthentication()
@@ -98,7 +98,7 @@ public class WithUserDetailsClassLevelAuthenticationTests {
}
@Autowired
public void configureGlobal(AuthenticationManagerBuilder auth) throws Exception {
void configureGlobal(AuthenticationManagerBuilder auth) throws Exception {
// @formatter:off
auth
.inMemoryAuthentication()