Skip to content

Commit 9e8d7fc

Browse files
committed
Preserve manual formatting
Issue gh-1616
1 parent 5505572 commit 9e8d7fc

23 files changed

+71
-29
lines changed

oauth2-authorization-server/src/main/java/org/springframework/security/oauth2/server/authorization/AbstractOAuth2AuthorizationServerMetadata.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,8 @@ protected Map<String, Object> getClaims() {
7474

7575
@SuppressWarnings("unchecked")
7676
protected final B getThis() {
77-
return (B) this; // avoid unchecked casts in subclasses by using "getThis()" instead of "(B) this"
77+
// avoid unchecked casts in subclasses by using "getThis()" instead of "(B) this"
78+
return (B) this;
7879
}
7980

8081
/**

oauth2-authorization-server/src/main/java/org/springframework/security/oauth2/server/authorization/InMemoryOAuth2AuthorizationService.java

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -150,6 +150,7 @@ private static boolean isComplete(OAuth2Authorization authorization) {
150150
}
151151

152152
private static boolean hasToken(OAuth2Authorization authorization, String token, @Nullable OAuth2TokenType tokenType) {
153+
// @formatter:off
153154
if (tokenType == null) {
154155
return matchesState(authorization, token) ||
155156
matchesAuthorizationCode(authorization, token) ||
@@ -173,6 +174,7 @@ private static boolean hasToken(OAuth2Authorization authorization, String token,
173174
} else if (OAuth2ParameterNames.USER_CODE.equals(tokenType.getValue())) {
174175
return matchesUserCode(authorization, token);
175176
}
177+
// @formatter:on
176178
return false;
177179
}
178180

oauth2-authorization-server/src/main/java/org/springframework/security/oauth2/server/authorization/authentication/ClientSecretAuthenticationProvider.java

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -88,10 +88,12 @@ public Authentication authenticate(Authentication authentication) throws Authent
8888
OAuth2ClientAuthenticationToken clientAuthentication =
8989
(OAuth2ClientAuthenticationToken) authentication;
9090

91+
// @formatter:off
9192
if (!ClientAuthenticationMethod.CLIENT_SECRET_BASIC.equals(clientAuthentication.getClientAuthenticationMethod()) &&
9293
!ClientAuthenticationMethod.CLIENT_SECRET_POST.equals(clientAuthentication.getClientAuthenticationMethod())) {
9394
return null;
9495
}
96+
// @formatter:on
9597

9698
String clientId = clientAuthentication.getPrincipal().toString();
9799
RegisteredClient registeredClient = this.registeredClientRepository.findByClientId(clientId);

oauth2-authorization-server/src/main/java/org/springframework/security/oauth2/server/authorization/authentication/CodeVerifierAuthenticator.java

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -125,9 +125,11 @@ private boolean authenticate(OAuth2ClientAuthenticationToken clientAuthenticatio
125125
}
126126

127127
private static boolean authorizationCodeGrant(Map<String, Object> parameters) {
128+
// @formatter:off
128129
return AuthorizationGrantType.AUTHORIZATION_CODE.getValue().equals(
129130
parameters.get(OAuth2ParameterNames.GRANT_TYPE)) &&
130131
parameters.get(OAuth2ParameterNames.CODE) != null;
132+
// @formatter:on
131133
}
132134

133135
private static boolean codeVerifierValid(String codeVerifier, String codeChallenge, String codeChallengeMethod) {

oauth2-authorization-server/src/main/java/org/springframework/security/oauth2/server/authorization/authentication/JwtClientAssertionAuthenticationProvider.java

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -92,10 +92,12 @@ public Authentication authenticate(Authentication authentication) throws Authent
9292
this.logger.trace("Retrieved registered client");
9393
}
9494

95+
// @formatter:off
9596
if (!registeredClient.getClientAuthenticationMethods().contains(ClientAuthenticationMethod.PRIVATE_KEY_JWT) &&
9697
!registeredClient.getClientAuthenticationMethods().contains(ClientAuthenticationMethod.CLIENT_SECRET_JWT)) {
9798
throwInvalidClient("authentication_method");
9899
}
100+
// @formatter:on
99101

100102
if (clientAuthentication.getCredentials() == null) {
101103
throwInvalidClient("credentials");
@@ -116,10 +118,12 @@ public Authentication authenticate(Authentication authentication) throws Authent
116118
// Validate the "code_verifier" parameter for the confidential client, if available
117119
this.codeVerifierAuthenticator.authenticateIfAvailable(clientAuthentication, registeredClient);
118120

121+
// @formatter:off
119122
ClientAuthenticationMethod clientAuthenticationMethod =
120123
registeredClient.getClientSettings().getTokenEndpointAuthenticationSigningAlgorithm() instanceof SignatureAlgorithm ?
121124
ClientAuthenticationMethod.PRIVATE_KEY_JWT :
122125
ClientAuthenticationMethod.CLIENT_SECRET_JWT;
126+
// @formatter:on
123127

124128
if (this.logger.isTraceEnabled()) {
125129
this.logger.trace("Authenticated client assertion");

oauth2-authorization-server/src/main/java/org/springframework/security/oauth2/server/authorization/authentication/OAuth2AuthorizationCodeAuthenticationProvider.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -213,8 +213,8 @@ public Authentication authenticate(Authentication authentication) throws Authent
213213

214214
// ----- Refresh token -----
215215
OAuth2RefreshToken refreshToken = null;
216+
// Do not issue refresh token to public client
216217
if (registeredClient.getAuthorizationGrantTypes().contains(AuthorizationGrantType.REFRESH_TOKEN) &&
217-
// Do not issue refresh token to public client
218218
!clientPrincipal.getClientAuthenticationMethod().equals(ClientAuthenticationMethod.NONE)) {
219219

220220
tokenContext = tokenContextBuilder.tokenType(OAuth2TokenType.REFRESH_TOKEN).build();

oauth2-authorization-server/src/main/java/org/springframework/security/oauth2/server/authorization/client/JdbcRegisteredClientRepository.java

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -306,7 +306,8 @@ private static AuthorizationGrantType resolveAuthorizationGrantType(String autho
306306
} else if (AuthorizationGrantType.REFRESH_TOKEN.getValue().equals(authorizationGrantType)) {
307307
return AuthorizationGrantType.REFRESH_TOKEN;
308308
}
309-
return new AuthorizationGrantType(authorizationGrantType); // Custom authorization grant type
309+
// Custom authorization grant type
310+
return new AuthorizationGrantType(authorizationGrantType);
310311
}
311312

312313
private static ClientAuthenticationMethod resolveClientAuthenticationMethod(String clientAuthenticationMethod) {
@@ -317,7 +318,8 @@ private static ClientAuthenticationMethod resolveClientAuthenticationMethod(Stri
317318
} else if (ClientAuthenticationMethod.NONE.getValue().equals(clientAuthenticationMethod)) {
318319
return ClientAuthenticationMethod.NONE;
319320
}
320-
return new ClientAuthenticationMethod(clientAuthenticationMethod); // Custom client authentication method
321+
// Custom client authentication method
322+
return new ClientAuthenticationMethod(clientAuthenticationMethod);
321323
}
322324

323325
}

oauth2-authorization-server/src/main/java/org/springframework/security/oauth2/server/authorization/oidc/authentication/OidcLogoutAuthenticationProvider.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -97,8 +97,8 @@ public Authentication authenticate(Authentication authentication) throws Authent
9797
}
9898

9999
OAuth2Authorization.Token<OidcIdToken> authorizedIdToken = authorization.getToken(OidcIdToken.class);
100-
if (authorizedIdToken.isInvalidated() ||
101-
authorizedIdToken.isBeforeUse()) { // Expired ID Token should be accepted
100+
if (authorizedIdToken.isInvalidated() || authorizedIdToken.isBeforeUse()) {
101+
// Expired ID Token should be accepted
102102
throwError(OAuth2ErrorCodes.INVALID_TOKEN, "id_token_hint");
103103
}
104104

oauth2-authorization-server/src/main/java/org/springframework/security/oauth2/server/authorization/oidc/authentication/OidcUserInfoAuthenticationProvider.java

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -149,6 +149,7 @@ public void setUserInfoMapper(Function<OidcUserInfoAuthenticationContext, OidcUs
149149

150150
private static final class DefaultOidcUserInfoMapper implements Function<OidcUserInfoAuthenticationContext, OidcUserInfo> {
151151

152+
// @formatter:off
152153
private static final List<String> EMAIL_CLAIMS = Arrays.asList(
153154
StandardClaimNames.EMAIL,
154155
StandardClaimNames.EMAIL_VERIFIED
@@ -173,6 +174,7 @@ private static final class DefaultOidcUserInfoMapper implements Function<OidcUse
173174
StandardClaimNames.LOCALE,
174175
StandardClaimNames.UPDATED_AT
175176
);
177+
// @formatter:on
176178

177179
@Override
178180
public OidcUserInfo apply(OidcUserInfoAuthenticationContext authenticationContext) {

oauth2-authorization-server/src/main/java/org/springframework/security/oauth2/server/authorization/oidc/web/OidcLogoutEndpointFilter.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -200,7 +200,8 @@ private void performLogout(HttpServletRequest request, HttpServletResponse respo
200200
OAuth2ParameterNames.STATE,
201201
UriUtils.encode(oidcLogoutAuthentication.getState(), StandardCharsets.UTF_8));
202202
}
203-
redirectUri = uriBuilder.build(true).toUriString(); // build(true) -> Components are explicitly encoded
203+
// build(true) -> Components are explicitly encoded
204+
redirectUri = uriBuilder.build(true).toUriString();
204205
this.redirectStrategy.sendRedirect(request, response, redirectUri);
205206
} else {
206207
// Perform default redirect

0 commit comments

Comments
 (0)