Skip to content

Commit 8a43c60

Browse files
gmazzajgrandja
authored andcommitted
Add Assert.notNull() for AuthenticationProvider additions
Closes spring-projectsgh-530
1 parent a1ef5ba commit 8a43c60

File tree

4 files changed

+11
-3
lines changed

4 files changed

+11
-3
lines changed

oauth2-authorization-server/src/main/java/org/springframework/security/config/annotation/web/configurers/oauth2/server/authorization/OAuth2AuthorizationEndpointConfigurer.java

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2020-2021 the original author or authors.
2+
* Copyright 2020-2022 the original author or authors.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -39,6 +39,7 @@
3939
import org.springframework.security.web.util.matcher.AntPathRequestMatcher;
4040
import org.springframework.security.web.util.matcher.OrRequestMatcher;
4141
import org.springframework.security.web.util.matcher.RequestMatcher;
42+
import org.springframework.util.Assert;
4243
import org.springframework.util.StringUtils;
4344

4445
/**
@@ -83,6 +84,7 @@ public OAuth2AuthorizationEndpointConfigurer authorizationRequestConverter(Authe
8384
* @return the {@link OAuth2AuthorizationEndpointConfigurer} for further configuration
8485
*/
8586
public OAuth2AuthorizationEndpointConfigurer authenticationProvider(AuthenticationProvider authenticationProvider) {
87+
Assert.notNull(authenticationProvider, "authenticationProvider cannot be null");
8688
this.authenticationProviders.add(authenticationProvider);
8789
return this;
8890
}

oauth2-authorization-server/src/main/java/org/springframework/security/config/annotation/web/configurers/oauth2/server/authorization/OAuth2ClientAuthenticationConfigurer.java

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2020-2021 the original author or authors.
2+
* Copyright 2020-2022 the original author or authors.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -39,6 +39,7 @@
3939
import org.springframework.security.web.util.matcher.AntPathRequestMatcher;
4040
import org.springframework.security.web.util.matcher.OrRequestMatcher;
4141
import org.springframework.security.web.util.matcher.RequestMatcher;
42+
import org.springframework.util.Assert;
4243

4344
/**
4445
* Configurer for OAuth 2.0 Client Authentication.
@@ -81,6 +82,7 @@ public OAuth2ClientAuthenticationConfigurer authenticationConverter(Authenticati
8182
* @return the {@link OAuth2ClientAuthenticationConfigurer} for further configuration
8283
*/
8384
public OAuth2ClientAuthenticationConfigurer authenticationProvider(AuthenticationProvider authenticationProvider) {
85+
Assert.notNull(authenticationProvider, "authenticationProvider cannot be null");
8486
this.authenticationProviders.add(authenticationProvider);
8587
return this;
8688
}

oauth2-authorization-server/src/main/java/org/springframework/security/config/annotation/web/configurers/oauth2/server/authorization/OAuth2TokenEndpointConfigurer.java

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2020-2021 the original author or authors.
2+
* Copyright 2020-2022 the original author or authors.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -45,6 +45,7 @@
4545
import org.springframework.security.web.authentication.AuthenticationSuccessHandler;
4646
import org.springframework.security.web.util.matcher.AntPathRequestMatcher;
4747
import org.springframework.security.web.util.matcher.RequestMatcher;
48+
import org.springframework.util.Assert;
4849

4950
/**
5051
* Configurer for the OAuth 2.0 Token Endpoint.
@@ -87,6 +88,7 @@ public OAuth2TokenEndpointConfigurer accessTokenRequestConverter(AuthenticationC
8788
* @return the {@link OAuth2TokenEndpointConfigurer} for further configuration
8889
*/
8990
public OAuth2TokenEndpointConfigurer authenticationProvider(AuthenticationProvider authenticationProvider) {
91+
Assert.notNull(authenticationProvider, "authenticationProvider cannot be null");
9092
this.authenticationProviders.add(authenticationProvider);
9193
return this;
9294
}

oauth2-authorization-server/src/main/java/org/springframework/security/config/annotation/web/configurers/oauth2/server/authorization/OAuth2TokenRevocationEndpointConfigurer.java

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,7 @@
3838
import org.springframework.security.web.authentication.AuthenticationSuccessHandler;
3939
import org.springframework.security.web.util.matcher.AntPathRequestMatcher;
4040
import org.springframework.security.web.util.matcher.RequestMatcher;
41+
import org.springframework.util.Assert;
4142

4243
/**
4344
* Configurer for the OAuth 2.0 Token Revocation Endpoint.
@@ -80,6 +81,7 @@ public OAuth2TokenRevocationEndpointConfigurer revocationRequestConverter(Authen
8081
* @return the {@link OAuth2TokenRevocationEndpointConfigurer} for further configuration
8182
*/
8283
public OAuth2TokenRevocationEndpointConfigurer authenticationProvider(AuthenticationProvider authenticationProvider) {
84+
Assert.notNull(authenticationProvider, "authenticationProvider cannot be null");
8385
this.authenticationProviders.add(authenticationProvider);
8486
return this;
8587
}

0 commit comments

Comments
 (0)