Skip to content

Commit 6c3e0ff

Browse files
authored
Merge pull request #3 from paychex/feature/client-assertion-auth
Fixing Checkstyle issues.
2 parents 5252f00 + fff08fc commit 6c3e0ff

11 files changed

+34
-43
lines changed

oauth2/oauth2-client/src/main/java/org/springframework/security/oauth2/client/endpoint/AbstractWebClientReactiveOAuth2AccessTokenResponseClient.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -126,7 +126,7 @@ BodyInserters.FormInserter<String> populateTokenRequestBody(T grantRequest, Body
126126
if (ClientAuthenticationMethod.POST.equals(clientRegistration.getClientAuthenticationMethod())) {
127127
body.with(OAuth2ParameterNames.CLIENT_SECRET, clientRegistration.getClientSecret());
128128
}
129-
if(ClientAuthenticationMethod.SECRET_JWT.equals(clientRegistration.getClientAuthenticationMethod())){
129+
if (ClientAuthenticationMethod.SECRET_JWT.equals(clientRegistration.getClientAuthenticationMethod())){
130130
body.with(ClientAssertionParameterNames.CLIENT_ASSERTION_TYPE, ClientAssertionParameterValues.CLIENT_ASSERTION_TYPE_JWT_BEARER);
131131
body.with(ClientAssertionParameterNames.CLIENT_ASSERTION, OAuth2AuthorizationGrantRequestEntityUtils.getClientSecretAssertion(clientRegistration).serialize());
132132

oauth2/oauth2-client/src/main/java/org/springframework/security/oauth2/client/endpoint/OAuth2AuthorizationCodeGrantRequestEntityConverter.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -88,7 +88,7 @@ private MultiValueMap<String, String> buildFormParameters(OAuth2AuthorizationCod
8888
if (ClientAuthenticationMethod.POST.equals(clientRegistration.getClientAuthenticationMethod())) {
8989
formParameters.add(OAuth2ParameterNames.CLIENT_SECRET, clientRegistration.getClientSecret());
9090
}
91-
if(ClientAuthenticationMethod.SECRET_JWT.equals(clientRegistration.getClientAuthenticationMethod())){
91+
if (ClientAuthenticationMethod.SECRET_JWT.equals(clientRegistration.getClientAuthenticationMethod())){
9292
formParameters.add(ClientAssertionParameterNames.CLIENT_ASSERTION_TYPE, ClientAssertionParameterValues.CLIENT_ASSERTION_TYPE_JWT_BEARER);
9393
formParameters.add(ClientAssertionParameterNames.CLIENT_ASSERTION, OAuth2AuthorizationGrantRequestEntityUtils.getClientSecretAssertion(clientRegistration).serialize());
9494
}

oauth2/oauth2-client/src/main/java/org/springframework/security/oauth2/client/endpoint/OAuth2AuthorizationGrantRequestEntityUtils.java

+5-5
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,7 @@ static JWT getClientSecretAssertion(ClientRegistration clientRegistration){
7777

7878
JWT clientAssertion = null;
7979

80-
if(ClientAuthenticationMethod.SECRET_JWT.equals(clientRegistration.getClientAuthenticationMethod())) {
80+
if (ClientAuthenticationMethod.SECRET_JWT.equals(clientRegistration.getClientAuthenticationMethod())) {
8181

8282
try {
8383
ClientID clientID = new ClientID(clientRegistration.getClientId());
@@ -92,13 +92,13 @@ static JWT getClientSecretAssertion(ClientRegistration clientRegistration){
9292
, secret).getClientAssertion();
9393
} catch (JOSEException e) {
9494
OAuth2Error oauth2Error = new OAuth2Error("Client_secret_jwt",
95-
"Encountered an error generating a client secret JWT",null);
96-
throw new OAuth2AuthenticationException(oauth2Error,e.getMessage());
95+
"Encountered an error generating a client secret JWT", null);
96+
throw new OAuth2AuthenticationException(oauth2Error, e.getMessage());
9797

9898
} catch(URISyntaxException e){
9999
OAuth2Error oauth2Error = new OAuth2Error("token_endpoint",
100-
"The token endpoint provided or configured doesn't conform to a standard URI Pattern",null);
101-
throw new OAuth2AuthenticationException(oauth2Error,e.getMessage());
100+
"The token endpoint provided or configured doesn't conform to a standard URI Pattern", null);
101+
throw new OAuth2AuthenticationException(oauth2Error, e.getMessage());
102102
}
103103
}
104104

oauth2/oauth2-client/src/main/java/org/springframework/security/oauth2/client/endpoint/OAuth2ClientCredentialsGrantRequestEntityConverter.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,7 @@ private MultiValueMap<String, String> buildFormParameters(OAuth2ClientCredential
8383
formParameters.add(OAuth2ParameterNames.CLIENT_ID, clientRegistration.getClientId());
8484
formParameters.add(OAuth2ParameterNames.CLIENT_SECRET, clientRegistration.getClientSecret());
8585
}
86-
if(ClientAuthenticationMethod.SECRET_JWT.equals(clientRegistration.getClientAuthenticationMethod())){
86+
if (ClientAuthenticationMethod.SECRET_JWT.equals(clientRegistration.getClientAuthenticationMethod())){
8787
formParameters.add(ClientAssertionParameterNames.CLIENT_ASSERTION_TYPE, ClientAssertionParameterValues.CLIENT_ASSERTION_TYPE_JWT_BEARER);
8888
formParameters.add(ClientAssertionParameterNames.CLIENT_ASSERTION, OAuth2AuthorizationGrantRequestEntityUtils.getClientSecretAssertion(clientRegistration).serialize());
8989
}

oauth2/oauth2-client/src/main/java/org/springframework/security/oauth2/client/endpoint/OAuth2PasswordGrantRequestEntityConverter.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,7 @@ private MultiValueMap<String, String> buildFormParameters(OAuth2PasswordGrantReq
8585
formParameters.add(OAuth2ParameterNames.CLIENT_ID, clientRegistration.getClientId());
8686
formParameters.add(OAuth2ParameterNames.CLIENT_SECRET, clientRegistration.getClientSecret());
8787
}
88-
if(ClientAuthenticationMethod.SECRET_JWT.equals(clientRegistration.getClientAuthenticationMethod())){
88+
if (ClientAuthenticationMethod.SECRET_JWT.equals(clientRegistration.getClientAuthenticationMethod())){
8989
formParameters.add(ClientAssertionParameterNames.CLIENT_ASSERTION_TYPE, ClientAssertionParameterValues.CLIENT_ASSERTION_TYPE_JWT_BEARER);
9090
formParameters.add(ClientAssertionParameterNames.CLIENT_ASSERTION, OAuth2AuthorizationGrantRequestEntityUtils.getClientSecretAssertion(clientRegistration).serialize());
9191
}

oauth2/oauth2-client/src/main/java/org/springframework/security/oauth2/client/endpoint/OAuth2RefreshTokenGrantRequestEntityConverter.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,7 @@ private MultiValueMap<String, String> buildFormParameters(OAuth2RefreshTokenGran
8585
formParameters.add(OAuth2ParameterNames.CLIENT_ID, clientRegistration.getClientId());
8686
formParameters.add(OAuth2ParameterNames.CLIENT_SECRET, clientRegistration.getClientSecret());
8787
}
88-
if(ClientAuthenticationMethod.SECRET_JWT.equals(clientRegistration.getClientAuthenticationMethod())){
88+
if (ClientAuthenticationMethod.SECRET_JWT.equals(clientRegistration.getClientAuthenticationMethod())){
8989
formParameters.add(ClientAssertionParameterNames.CLIENT_ASSERTION_TYPE, ClientAssertionParameterValues.CLIENT_ASSERTION_TYPE_JWT_BEARER);
9090
formParameters.add(ClientAssertionParameterNames.CLIENT_ASSERTION, OAuth2AuthorizationGrantRequestEntityUtils.getClientSecretAssertion(clientRegistration).serialize());
9191
}

oauth2/oauth2-client/src/main/java/org/springframework/security/oauth2/client/jackson2/StdConverters.java

+2-2
Original file line numberDiff line numberDiff line change
@@ -50,8 +50,8 @@ public ClientAuthenticationMethod convert(JsonNode jsonNode) {
5050
if (ClientAuthenticationMethod.BASIC.getValue().equalsIgnoreCase(value)) {
5151
return ClientAuthenticationMethod.BASIC;
5252
} else if (ClientAuthenticationMethod.POST.getValue().equalsIgnoreCase(value)) {
53-
return ClientAuthenticationMethod.POST;}
54-
else if (ClientAuthenticationMethod.SECRET_JWT.getValue().equalsIgnoreCase(value)) {
53+
return ClientAuthenticationMethod.POST;
54+
} else if (ClientAuthenticationMethod.SECRET_JWT.getValue().equalsIgnoreCase(value)) {
5555
return ClientAuthenticationMethod.SECRET_JWT;
5656
} else if (ClientAuthenticationMethod.NONE.getValue().equalsIgnoreCase(value)) {
5757
return ClientAuthenticationMethod.NONE;

oauth2/oauth2-client/src/main/java/org/springframework/security/oauth2/client/registration/ClientRegistration.java

-1
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,6 @@
1515
*/
1616
package org.springframework.security.oauth2.client.registration;
1717

18-
import com.nimbusds.jose.JWSAlgorithm;
1918
import java.io.Serializable;
2019
import java.util.Arrays;
2120
import java.util.Collection;

oauth2/oauth2-client/src/test/java/org/springframework/security/oauth2/client/endpoint/OAuth2AuthorizationCodeGrantRequestEntityConverterTests.java

+2-4
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,6 @@
3434
import org.springframework.security.oauth2.core.endpoint.OAuth2AuthorizationResponse;
3535
import org.springframework.security.oauth2.core.endpoint.OAuth2ParameterNames;
3636
import org.springframework.security.oauth2.core.endpoint.PkceParameterNames;
37-
import org.springframework.security.oauth2.jose.jws.JwsAlgorithms;
3837
import org.springframework.util.MultiValueMap;
3938

4039
import java.util.Arrays;
@@ -44,7 +43,6 @@
4443
import java.util.Date;
4544

4645
import static org.assertj.core.api.Assertions.assertThat;
47-
import static org.junit.Assert.assertTrue;
4846
import static org.springframework.http.MediaType.APPLICATION_FORM_URLENCODED_VALUE;
4947

5048
/**
@@ -199,7 +197,7 @@ public void convertWhenGrantRequestValidThenConverts() {
199197
.isEqualTo(ClientAssertionParameterValues.CLIENT_ASSERTION_TYPE_JWT_BEARER);
200198
assertThat(formParameters.getFirst(ClientAssertionParameterNames.CLIENT_ASSERTION))
201199
.isNotEmpty();
202-
assertTrue(validateJWTSecret(formParameters.getFirst(ClientAssertionParameterNames.CLIENT_ASSERTION),clientRegistration));
200+
assertThat(validateJWTSecret(formParameters.getFirst(ClientAssertionParameterNames.CLIENT_ASSERTION), clientRegistration)).isTrue();
203201

204202
}
205203

@@ -240,7 +238,7 @@ public void convertWhenGrantRequestInValidSecretLengthThenConvertFails() {
240238
RequestEntity<?> requestEntity = this.converter.convert(authorizationCodeGrantRequest);
241239
}
242240

243-
private boolean validateJWTSecret(String jwt,ClientRegistration registration ){
241+
private boolean validateJWTSecret(String jwt, ClientRegistration registration ){
244242

245243
boolean success;
246244

oauth2/oauth2-core/src/main/java/org/springframework/security/oauth2/core/endpoint/ClientAssertionParameterNames.java

+10-13
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,17 @@
11
/*
2+
* Copyright 2002-2019 the original author or authors.
23
*
4+
* Licensed under the Apache License, Version 2.0 (the "License");
5+
* you may not use this file except in compliance with the License.
6+
* You may obtain a copy of the License at
37
*
4-
* * Copyright 2020 Paychex, Inc.
5-
* *
6-
* * Licensed under the Apache License, Version 2.0 (the "License");
7-
* * you may not use this file except in compliance with the License.
8-
* * You may obtain a copy of the License at
9-
* *
10-
* * https://www.apache.org/licenses/LICENSE-2.0
11-
* *
12-
* * Unless required by applicable law or agreed to in writing, software
13-
* * distributed under the License is distributed on an "AS IS" BASIS,
14-
* * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15-
* * See the License for the specific language governing permissions and
16-
* * limitations under the License.
8+
* https://www.apache.org/licenses/LICENSE-2.0
179
*
10+
* Unless required by applicable law or agreed to in writing, software
11+
* distributed under the License is distributed on an "AS IS" BASIS,
12+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
* See the License for the specific language governing permissions and
14+
* limitations under the License.
1815
*/
1916

2017
package org.springframework.security.oauth2.core.endpoint;

oauth2/oauth2-core/src/main/java/org/springframework/security/oauth2/core/endpoint/ClientAssertionParameterValues.java

+10-13
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,17 @@
11
/*
2+
* Copyright 2002-2019 the original author or authors.
23
*
4+
* Licensed under the Apache License, Version 2.0 (the "License");
5+
* you may not use this file except in compliance with the License.
6+
* You may obtain a copy of the License at
37
*
4-
* * Copyright 2020 Paychex, Inc.
5-
* *
6-
* * Licensed under the Apache License, Version 2.0 (the "License");
7-
* * you may not use this file except in compliance with the License.
8-
* * You may obtain a copy of the License at
9-
* *
10-
* * https://www.apache.org/licenses/LICENSE-2.0
11-
* *
12-
* * Unless required by applicable law or agreed to in writing, software
13-
* * distributed under the License is distributed on an "AS IS" BASIS,
14-
* * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15-
* * See the License for the specific language governing permissions and
16-
* * limitations under the License.
8+
* https://www.apache.org/licenses/LICENSE-2.0
179
*
10+
* Unless required by applicable law or agreed to in writing, software
11+
* distributed under the License is distributed on an "AS IS" BASIS,
12+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
* See the License for the specific language governing permissions and
14+
* limitations under the License.
1815
*/
1916

2017
package org.springframework.security.oauth2.core.endpoint;

0 commit comments

Comments
 (0)