Skip to content

Commit 6894ff5

Browse files
philwebbrwinch
authored andcommitted
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
1 parent b5d499e commit 6894ff5

File tree

58 files changed

+229
-226
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

58 files changed

+229
-226
lines changed

acl/src/test/java/org/springframework/security/acls/jdbc/JdbcMutableAclServiceTests.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -550,7 +550,7 @@ public void testProcessingCustomSid() {
550550
*/
551551
private class CustomJdbcMutableAclService extends JdbcMutableAclService {
552552

553-
private CustomJdbcMutableAclService(DataSource dataSource, LookupStrategy lookupStrategy, AclCache aclCache) {
553+
CustomJdbcMutableAclService(DataSource dataSource, LookupStrategy lookupStrategy, AclCache aclCache) {
554554
super(dataSource, lookupStrategy, aclCache);
555555
}
556556

config/src/main/java/org/springframework/security/config/annotation/authentication/configurers/provisioning/UserDetailsManagerConfigurer.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -104,7 +104,7 @@ public final UserDetailsBuilder withUser(String username) {
104104
* Builds the user to be added. At minimum the username, password, and authorities
105105
* should provided. The remaining attributes have reasonable defaults.
106106
*/
107-
public class UserDetailsBuilder {
107+
public final class UserDetailsBuilder {
108108

109109
private UserBuilder user;
110110

config/src/main/java/org/springframework/security/config/annotation/rsocket/RSocketSecurity.java

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -164,7 +164,7 @@ public RSocketSecurity simpleAuthentication(Customizer<SimpleAuthenticationSpec>
164164
/**
165165
* @since 5.3
166166
*/
167-
public class SimpleAuthenticationSpec {
167+
public final class SimpleAuthenticationSpec {
168168

169169
private ReactiveAuthenticationManager authenticationManager;
170170

@@ -208,7 +208,7 @@ public RSocketSecurity basicAuthentication(Customizer<BasicAuthenticationSpec> b
208208
return this;
209209
}
210210

211-
public class BasicAuthenticationSpec {
211+
public final class BasicAuthenticationSpec {
212212

213213
private ReactiveAuthenticationManager authenticationManager;
214214

@@ -244,7 +244,7 @@ public RSocketSecurity jwt(Customizer<JwtSpec> jwt) {
244244
return this;
245245
}
246246

247-
public class JwtSpec {
247+
public final class JwtSpec {
248248

249249
private ReactiveAuthenticationManager authenticationManager;
250250

@@ -370,7 +370,7 @@ public Access matcher(PayloadExchangeMatcher matcher) {
370370
return new Access(matcher);
371371
}
372372

373-
public class Access {
373+
public final class Access {
374374

375375
private final PayloadExchangeMatcher matcher;
376376

config/src/main/java/org/springframework/security/config/annotation/web/builders/HttpSecurity.java

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2942,10 +2942,7 @@ public class RequestMatcherConfigurer extends AbstractRequestMatcherRegistry<Req
29422942

29432943
protected List<RequestMatcher> matchers = new ArrayList<>();
29442944

2945-
/**
2946-
* @param context
2947-
*/
2948-
private RequestMatcherConfigurer(ApplicationContext context) {
2945+
RequestMatcherConfigurer(ApplicationContext context) {
29492946
setApplicationContext(context);
29502947
}
29512948

config/src/main/java/org/springframework/security/config/annotation/web/builders/WebSecurity.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -337,7 +337,7 @@ public IgnoredRequestConfigurer servletPath(String servletPath) {
337337
*/
338338
public class IgnoredRequestConfigurer extends AbstractRequestMatcherRegistry<IgnoredRequestConfigurer> {
339339

340-
private IgnoredRequestConfigurer(ApplicationContext context) {
340+
IgnoredRequestConfigurer(ApplicationContext context) {
341341
setApplicationContext(context);
342342
}
343343

config/src/main/java/org/springframework/security/config/annotation/web/configurers/ChannelSecurityConfigurer.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -220,7 +220,7 @@ public class RequiresChannelUrl {
220220

221221
protected List<? extends RequestMatcher> requestMatchers;
222222

223-
private RequiresChannelUrl(List<? extends RequestMatcher> requestMatchers) {
223+
RequiresChannelUrl(List<? extends RequestMatcher> requestMatchers) {
224224
this.requestMatchers = requestMatchers;
225225
}
226226

config/src/main/java/org/springframework/security/config/annotation/web/configurers/CsrfConfigurer.java

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -303,8 +303,8 @@ private AccessDeniedHandler createAccessDeniedHandler(H http) {
303303
* @since 5.2
304304
*/
305305
private SessionAuthenticationStrategy getSessionAuthenticationStrategy() {
306-
if (sessionAuthenticationStrategy != null) {
307-
return sessionAuthenticationStrategy;
306+
if (this.sessionAuthenticationStrategy != null) {
307+
return this.sessionAuthenticationStrategy;
308308
}
309309
else {
310310
return new CsrfAuthenticationStrategy(this.csrfTokenRepository);
@@ -321,10 +321,7 @@ private SessionAuthenticationStrategy getSessionAuthenticationStrategy() {
321321
*/
322322
private class IgnoreCsrfProtectionRegistry extends AbstractRequestMatcherRegistry<IgnoreCsrfProtectionRegistry> {
323323

324-
/**
325-
* @param context
326-
*/
327-
private IgnoreCsrfProtectionRegistry(ApplicationContext context) {
324+
IgnoreCsrfProtectionRegistry(ApplicationContext context) {
328325
setApplicationContext(context);
329326
}
330327

config/src/main/java/org/springframework/security/config/annotation/web/configurers/ExpressionUrlAuthorizationConfigurer.java

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -109,7 +109,7 @@ public ExpressionInterceptUrlRegistry getRegistry() {
109109
return REGISTRY;
110110
}
111111

112-
public class ExpressionInterceptUrlRegistry extends
112+
public final class ExpressionInterceptUrlRegistry extends
113113
ExpressionUrlAuthorizationConfigurer<H>.AbstractInterceptUrlRegistry<ExpressionInterceptUrlRegistry, AuthorizedUrl> {
114114

115115
/**
@@ -130,7 +130,7 @@ public MvcMatchersAuthorizedUrl mvcMatchers(String... patterns) {
130130
}
131131

132132
@Override
133-
protected final AuthorizedUrl chainRequestMatchersInternal(List<RequestMatcher> requestMatchers) {
133+
protected AuthorizedUrl chainRequestMatchersInternal(List<RequestMatcher> requestMatchers) {
134134
return new AuthorizedUrl(requestMatchers);
135135
}
136136

@@ -267,7 +267,7 @@ private static String hasIpAddress(String ipAddressExpression) {
267267
*
268268
* @author Rob Winch
269269
*/
270-
public class MvcMatchersAuthorizedUrl extends AuthorizedUrl {
270+
public final class MvcMatchersAuthorizedUrl extends AuthorizedUrl {
271271

272272
/**
273273
* Creates a new instance
@@ -296,7 +296,7 @@ public class AuthorizedUrl {
296296
* Creates a new instance
297297
* @param requestMatchers the {@link RequestMatcher} instances to map
298298
*/
299-
private AuthorizedUrl(List<? extends RequestMatcher> requestMatchers) {
299+
AuthorizedUrl(List<? extends RequestMatcher> requestMatchers) {
300300
this.requestMatchers = requestMatchers;
301301
}
302302

config/src/main/java/org/springframework/security/config/annotation/web/configurers/UrlAuthorizationConfigurer.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -113,7 +113,7 @@ public UrlAuthorizationConfigurer<H> withObjectPostProcessor(ObjectPostProcessor
113113
return this;
114114
}
115115

116-
public class StandardInterceptUrlRegistry extends
116+
public final class StandardInterceptUrlRegistry extends
117117
ExpressionUrlAuthorizationConfigurer<H>.AbstractInterceptUrlRegistry<StandardInterceptUrlRegistry, AuthorizedUrl> {
118118

119119
/**
@@ -134,7 +134,7 @@ public MvcMatchersAuthorizedUrl mvcMatchers(String... patterns) {
134134
}
135135

136136
@Override
137-
protected final AuthorizedUrl chainRequestMatchersInternal(List<RequestMatcher> requestMatchers) {
137+
protected AuthorizedUrl chainRequestMatchersInternal(List<RequestMatcher> requestMatchers) {
138138
return new AuthorizedUrl(requestMatchers);
139139
}
140140

@@ -275,7 +275,7 @@ public class AuthorizedUrl {
275275
* @param requestMatchers the {@link RequestMatcher} instances to map to some
276276
* {@link ConfigAttribute} instances.
277277
*/
278-
private AuthorizedUrl(List<? extends RequestMatcher> requestMatchers) {
278+
AuthorizedUrl(List<? extends RequestMatcher> requestMatchers) {
279279
Assert.notEmpty(requestMatchers, "requestMatchers must contain at least one value");
280280
this.requestMatchers = requestMatchers;
281281
}

config/src/main/java/org/springframework/security/config/annotation/web/configurers/oauth2/client/OAuth2ClientConfigurer.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -154,7 +154,7 @@ public OAuth2ClientConfigurer<B> authorizationCodeGrant(
154154
/**
155155
* Configuration options for the OAuth 2.0 Authorization Code Grant.
156156
*/
157-
public class AuthorizationCodeGrantConfigurer {
157+
public final class AuthorizationCodeGrantConfigurer {
158158

159159
private OAuth2AuthorizationRequestResolver authorizationRequestResolver;
160160

0 commit comments

Comments
 (0)