Skip to content

Commit 5bd47b6

Browse files
committed
Polish gh-1907
1 parent 2e9fe7e commit 5bd47b6

File tree

10 files changed

+27
-33
lines changed

10 files changed

+27
-33
lines changed

Diff for: docs/src/main/java/sample/extgrant/CustomCodeGrantAuthenticationProvider.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2020-2023 the original author or authors.
2+
* Copyright 2020-2025 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.

Diff for: oauth2-authorization-server/src/main/java/org/springframework/security/oauth2/server/authorization/web/OAuth2AuthorizationEndpointFilter.java

+4-5
Original file line numberDiff line numberDiff line change
@@ -173,9 +173,8 @@ protected void doFilterInternal(HttpServletRequest request, HttpServletResponse
173173

174174
try {
175175
Authentication authentication = this.authenticationConverter.convert(request);
176-
if (authentication instanceof AbstractAuthenticationToken abstractAuthenticationToken) {
177-
abstractAuthenticationToken
178-
.setDetails(this.authenticationDetailsSource.buildDetails(request));
176+
if (authentication instanceof AbstractAuthenticationToken authenticationToken) {
177+
authenticationToken.setDetails(this.authenticationDetailsSource.buildDetails(request));
179178
}
180179
Authentication authenticationResult = this.authenticationManager.authenticate(authentication);
181180

@@ -188,13 +187,13 @@ protected void doFilterInternal(HttpServletRequest request, HttpServletResponse
188187
return;
189188
}
190189

191-
if (authenticationResult instanceof OAuth2AuthorizationConsentAuthenticationToken oAuth2AuthorizationConsentAuthenticationToken) {
190+
if (authenticationResult instanceof OAuth2AuthorizationConsentAuthenticationToken authorizationConsentAuthenticationToken) {
192191
if (this.logger.isTraceEnabled()) {
193192
this.logger.trace("Authorization consent is required");
194193
}
195194
sendAuthorizationConsent(request, response,
196195
(OAuth2AuthorizationCodeRequestAuthenticationToken) authentication,
197-
oAuth2AuthorizationConsentAuthenticationToken);
196+
authorizationConsentAuthenticationToken);
198197
return;
199198
}
200199

Diff for: oauth2-authorization-server/src/main/java/org/springframework/security/oauth2/server/authorization/web/OAuth2ClientAuthenticationFilter.java

+3-4
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2020-2024 the original author or authors.
2+
* Copyright 2020-2025 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.
@@ -132,9 +132,8 @@ protected void doFilterInternal(HttpServletRequest request, HttpServletResponse
132132

133133
try {
134134
Authentication authenticationRequest = this.authenticationConverter.convert(request);
135-
if (authenticationRequest instanceof AbstractAuthenticationToken abstractAuthenticationToken) {
136-
abstractAuthenticationToken
137-
.setDetails(this.authenticationDetailsSource.buildDetails(request));
135+
if (authenticationRequest instanceof AbstractAuthenticationToken authenticationToken) {
136+
authenticationToken.setDetails(this.authenticationDetailsSource.buildDetails(request));
138137
}
139138
if (authenticationRequest != null) {
140139
validateClientIdentifier(authenticationRequest);

Diff for: oauth2-authorization-server/src/main/java/org/springframework/security/oauth2/server/authorization/web/OAuth2DeviceAuthorizationEndpointFilter.java

+3-4
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2020-2024 the original author or authors.
2+
* Copyright 2020-2025 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.
@@ -129,9 +129,8 @@ protected void doFilterInternal(HttpServletRequest request, HttpServletResponse
129129

130130
try {
131131
Authentication deviceAuthorizationRequestAuthentication = this.authenticationConverter.convert(request);
132-
if (deviceAuthorizationRequestAuthentication instanceof AbstractAuthenticationToken abstractAuthenticationToken) {
133-
abstractAuthenticationToken
134-
.setDetails(this.authenticationDetailsSource.buildDetails(request));
132+
if (deviceAuthorizationRequestAuthentication instanceof AbstractAuthenticationToken authenticationToken) {
133+
authenticationToken.setDetails(this.authenticationDetailsSource.buildDetails(request));
135134
}
136135

137136
Authentication deviceAuthorizationRequestAuthenticationResult = this.authenticationManager

Diff for: oauth2-authorization-server/src/main/java/org/springframework/security/oauth2/server/authorization/web/OAuth2DeviceVerificationEndpointFilter.java

+3-4
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2020-2024 the original author or authors.
2+
* Copyright 2020-2025 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.
@@ -155,9 +155,8 @@ protected void doFilterInternal(HttpServletRequest request, HttpServletResponse
155155

156156
try {
157157
Authentication authentication = this.authenticationConverter.convert(request);
158-
if (authentication instanceof AbstractAuthenticationToken abstractAuthenticationToken) {
159-
abstractAuthenticationToken
160-
.setDetails(this.authenticationDetailsSource.buildDetails(request));
158+
if (authentication instanceof AbstractAuthenticationToken authenticationToken) {
159+
authenticationToken.setDetails(this.authenticationDetailsSource.buildDetails(request));
161160
}
162161

163162
Authentication authenticationResult = this.authenticationManager.authenticate(authentication);

Diff for: oauth2-authorization-server/src/main/java/org/springframework/security/oauth2/server/authorization/web/OAuth2TokenEndpointFilter.java

+3-4
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2020-2024 the original author or authors.
2+
* Copyright 2020-2025 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.
@@ -161,9 +161,8 @@ protected void doFilterInternal(HttpServletRequest request, HttpServletResponse
161161
if (authorizationGrantAuthentication == null) {
162162
throwError(OAuth2ErrorCodes.UNSUPPORTED_GRANT_TYPE, OAuth2ParameterNames.GRANT_TYPE);
163163
}
164-
if (authorizationGrantAuthentication instanceof AbstractAuthenticationToken abstractAuthenticationToken) {
165-
abstractAuthenticationToken
166-
.setDetails(this.authenticationDetailsSource.buildDetails(request));
164+
if (authorizationGrantAuthentication instanceof AbstractAuthenticationToken authenticationToken) {
165+
authenticationToken.setDetails(this.authenticationDetailsSource.buildDetails(request));
167166
}
168167

169168
OAuth2AccessTokenAuthenticationToken accessTokenAuthentication = (OAuth2AccessTokenAuthenticationToken) this.authenticationManager

Diff for: oauth2-authorization-server/src/main/java/org/springframework/security/oauth2/server/authorization/web/OAuth2TokenRevocationEndpointFilter.java

+3-4
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2020-2024 the original author or authors.
2+
* Copyright 2020-2025 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.
@@ -114,9 +114,8 @@ protected void doFilterInternal(HttpServletRequest request, HttpServletResponse
114114

115115
try {
116116
Authentication tokenRevocationAuthentication = this.authenticationConverter.convert(request);
117-
if (tokenRevocationAuthentication instanceof AbstractAuthenticationToken abstractAuthenticationToken) {
118-
abstractAuthenticationToken
119-
.setDetails(this.authenticationDetailsSource.buildDetails(request));
117+
if (tokenRevocationAuthentication instanceof AbstractAuthenticationToken authenticationToken) {
118+
authenticationToken.setDetails(this.authenticationDetailsSource.buildDetails(request));
120119
}
121120

122121
Authentication tokenRevocationAuthenticationResult = this.authenticationManager

Diff for: oauth2-authorization-server/src/main/java/org/springframework/security/oauth2/server/authorization/web/authentication/OAuth2ErrorAuthenticationFailureHandler.java

+3-3
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2020-2023 the original author or authors.
2+
* Copyright 2020-2025 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.
@@ -55,8 +55,8 @@ public void onAuthenticationFailure(HttpServletRequest request, HttpServletRespo
5555
ServletServerHttpResponse httpResponse = new ServletServerHttpResponse(response);
5656
httpResponse.setStatusCode(HttpStatus.BAD_REQUEST);
5757

58-
if (authenticationException instanceof OAuth2AuthenticationException oAuth2AuthenticationException) {
59-
OAuth2Error error = oAuth2AuthenticationException.getError();
58+
if (authenticationException instanceof OAuth2AuthenticationException oauth2AuthenticationException) {
59+
OAuth2Error error = oauth2AuthenticationException.getError();
6060
this.errorResponseConverter.write(error, null, httpResponse);
6161
}
6262
else {

Diff for: samples/demo-authorizationserver/src/main/java/sample/federation/FederatedIdentityAuthenticationSuccessHandler.java

+3-3
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2020-2023 the original author or authors.
2+
* Copyright 2020-2025 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.
@@ -52,8 +52,8 @@ public void onAuthenticationSuccess(HttpServletRequest request, HttpServletRespo
5252
if (authentication instanceof OAuth2AuthenticationToken) {
5353
if (authentication.getPrincipal() instanceof OidcUser oidcUser) {
5454
this.oidcUserHandler.accept(oidcUser);
55-
} else if (authentication.getPrincipal() instanceof OAuth2User oAuth2User) {
56-
this.oauth2UserHandler.accept(oAuth2User);
55+
} else if (authentication.getPrincipal() instanceof OAuth2User oauth2User) {
56+
this.oauth2UserHandler.accept(oauth2User);
5757
}
5858
}
5959

Diff for: samples/demo-authorizationserver/src/main/java/sample/federation/FederatedIdentityIdTokenCustomizer.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2020-2023 the original author or authors.
2+
* Copyright 2020-2025 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.

0 commit comments

Comments
 (0)