Skip to content

Commit f94964c

Browse files
committed
Merge branch '1.1.x' into 1.2.x
2 parents 296ad71 + 9219125 commit f94964c

File tree

257 files changed

+11264
-9772
lines changed

Some content is hidden

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

257 files changed

+11264
-9772
lines changed

buildSrc/build.gradle

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ repositories {
1515
dependencies {
1616
implementation "com.github.ben-manes:gradle-versions-plugin:0.38.0"
1717
implementation "io.github.gradle-nexus:publish-plugin:1.1.0"
18-
implementation "io.spring.javaformat:spring-javaformat-gradle-plugin:0.0.31"
18+
implementation "io.spring.javaformat:spring-javaformat-gradle-plugin:0.0.41"
1919
implementation "io.spring.nohttp:nohttp-gradle:0.0.10"
2020
implementation "org.asciidoctor:asciidoctor-gradle-jvm:3.3.2"
2121
implementation "org.asciidoctor:asciidoctor-gradle-jvm-pdf:3.3.2"

buildSrc/src/main/java/org/springframework/gradle/checkstyle/SpringJavaCheckstylePlugin.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@
3737
public class SpringJavaCheckstylePlugin implements Plugin<Project> {
3838
private static final String CHECKSTYLE_DIR = "etc/checkstyle";
3939
private static final String SPRING_JAVAFORMAT_VERSION_PROPERTY = "springJavaformatVersion";
40-
private static final String DEFAULT_SPRING_JAVAFORMAT_VERSION = "0.0.31";
40+
private static final String DEFAULT_SPRING_JAVAFORMAT_VERSION = "0.0.41";
4141
private static final String NOHTTP_CHECKSTYLE_VERSION_PROPERTY = "nohttpCheckstyleVersion";
4242
private static final String DEFAULT_NOHTTP_CHECKSTYLE_VERSION = "0.0.10";
4343
private static final String CHECKSTYLE_TOOL_VERSION_PROPERTY = "checkstyleToolVersion";

gradle.properties

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,7 @@ org.gradle.parallel=true
44
org.gradle.caching=true
55
springFrameworkVersion=6.1.6
66
springSecurityVersion=6.2.4
7-
springJavaformatVersion=0.0.38
8-
springJavaformatExcludePackages=org/springframework/security/config org/springframework/security/oauth2
7+
springJavaformatVersion=0.0.41
98
checkstyleToolVersion=8.34
109
nohttpCheckstyleVersion=0.0.11
1110
jacocoToolVersion=0.8.7

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

Lines changed: 205 additions & 119 deletions
Large diffs are not rendered by default.

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

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,8 @@
2626
import org.springframework.util.Assert;
2727

2828
/**
29-
* An {@link OAuth2AuthorizationConsentService} that stores {@link OAuth2AuthorizationConsent}'s in-memory.
29+
* An {@link OAuth2AuthorizationConsentService} that stores
30+
* {@link OAuth2AuthorizationConsent}'s in-memory.
3031
*
3132
* <p>
3233
* <b>NOTE:</b> This implementation should ONLY be used during development/testing.
@@ -36,6 +37,7 @@
3637
* @see OAuth2AuthorizationConsentService
3738
*/
3839
public final class InMemoryOAuth2AuthorizationConsentService implements OAuth2AuthorizationConsentService {
40+
3941
private final Map<Integer, OAuth2AuthorizationConsent> authorizationConsents = new ConcurrentHashMap<>();
4042

4143
/**
@@ -46,17 +48,17 @@ public InMemoryOAuth2AuthorizationConsentService() {
4648
}
4749

4850
/**
49-
* Constructs an {@code InMemoryOAuth2AuthorizationConsentService} using the provided parameters.
50-
*
51+
* Constructs an {@code InMemoryOAuth2AuthorizationConsentService} using the provided
52+
* parameters.
5153
* @param authorizationConsents the authorization consent(s)
5254
*/
5355
public InMemoryOAuth2AuthorizationConsentService(OAuth2AuthorizationConsent... authorizationConsents) {
5456
this(Arrays.asList(authorizationConsents));
5557
}
5658

5759
/**
58-
* Constructs an {@code InMemoryOAuth2AuthorizationConsentService} using the provided parameters.
59-
*
60+
* Constructs an {@code InMemoryOAuth2AuthorizationConsentService} using the provided
61+
* parameters.
6062
* @param authorizationConsents the authorization consent(s)
6163
*/
6264
public InMemoryOAuth2AuthorizationConsentService(List<OAuth2AuthorizationConsent> authorizationConsents) {
@@ -66,8 +68,8 @@ public InMemoryOAuth2AuthorizationConsentService(List<OAuth2AuthorizationConsent
6668
int id = getId(authorizationConsent);
6769
Assert.isTrue(!this.authorizationConsents.containsKey(id),
6870
"The authorizationConsent must be unique. Found duplicate, with registered client id: ["
69-
+ authorizationConsent.getRegisteredClientId()
70-
+ "] and principal name: [" + authorizationConsent.getPrincipalName() + "]");
71+
+ authorizationConsent.getRegisteredClientId() + "] and principal name: ["
72+
+ authorizationConsent.getPrincipalName() + "]");
7173
this.authorizationConsents.put(id, authorizationConsent);
7274
});
7375
}

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

Lines changed: 32 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,8 @@
3333
import org.springframework.util.Assert;
3434

3535
/**
36-
* An {@link OAuth2AuthorizationService} that stores {@link OAuth2Authorization}'s in-memory.
36+
* An {@link OAuth2AuthorizationService} that stores {@link OAuth2Authorization}'s
37+
* in-memory.
3738
*
3839
* <p>
3940
* <b>NOTE:</b> This implementation should ONLY be used during development/testing.
@@ -44,15 +45,17 @@
4445
* @see OAuth2AuthorizationService
4546
*/
4647
public final class InMemoryOAuth2AuthorizationService implements OAuth2AuthorizationService {
48+
4749
private int maxInitializedAuthorizations = 100;
4850

4951
/*
50-
* Stores "initialized" (uncompleted) authorizations, where an access token has not yet been granted.
51-
* This state occurs with the authorization_code grant flow during the user consent step OR
52-
* when the code is returned in the authorization response but the access token request is not yet initiated.
52+
* Stores "initialized" (uncompleted) authorizations, where an access token has not
53+
* yet been granted. This state occurs with the authorization_code grant flow during
54+
* the user consent step OR when the code is returned in the authorization response
55+
* but the access token request is not yet initiated.
5356
*/
54-
private Map<String, OAuth2Authorization> initializedAuthorizations =
55-
Collections.synchronizedMap(new MaxSizeHashMap<>(this.maxInitializedAuthorizations));
57+
private Map<String, OAuth2Authorization> initializedAuthorizations = Collections
58+
.synchronizedMap(new MaxSizeHashMap<>(this.maxInitializedAuthorizations));
5659

5760
/*
5861
* Stores "completed" authorizations, where an access token has been granted.
@@ -64,7 +67,8 @@ public final class InMemoryOAuth2AuthorizationService implements OAuth2Authoriza
6467
*/
6568
InMemoryOAuth2AuthorizationService(int maxInitializedAuthorizations) {
6669
this.maxInitializedAuthorizations = maxInitializedAuthorizations;
67-
this.initializedAuthorizations = Collections.synchronizedMap(new MaxSizeHashMap<>(this.maxInitializedAuthorizations));
70+
this.initializedAuthorizations = Collections
71+
.synchronizedMap(new MaxSizeHashMap<>(this.maxInitializedAuthorizations));
6872
}
6973

7074
/**
@@ -75,17 +79,17 @@ public InMemoryOAuth2AuthorizationService() {
7579
}
7680

7781
/**
78-
* Constructs an {@code InMemoryOAuth2AuthorizationService} using the provided parameters.
79-
*
82+
* Constructs an {@code InMemoryOAuth2AuthorizationService} using the provided
83+
* parameters.
8084
* @param authorizations the authorization(s)
8185
*/
8286
public InMemoryOAuth2AuthorizationService(OAuth2Authorization... authorizations) {
8387
this(Arrays.asList(authorizations));
8488
}
8589

8690
/**
87-
* Constructs an {@code InMemoryOAuth2AuthorizationService} using the provided parameters.
88-
*
91+
* Constructs an {@code InMemoryOAuth2AuthorizationService} using the provided
92+
* parameters.
8993
* @param authorizations the authorization(s)
9094
*/
9195
public InMemoryOAuth2AuthorizationService(List<OAuth2Authorization> authorizations) {
@@ -103,7 +107,8 @@ public void save(OAuth2Authorization authorization) {
103107
Assert.notNull(authorization, "authorization cannot be null");
104108
if (isComplete(authorization)) {
105109
this.authorizations.put(authorization.getId(), authorization);
106-
} else {
110+
}
111+
else {
107112
this.initializedAuthorizations.put(authorization.getId(), authorization);
108113
}
109114
}
@@ -113,7 +118,8 @@ public void remove(OAuth2Authorization authorization) {
113118
Assert.notNull(authorization, "authorization cannot be null");
114119
if (isComplete(authorization)) {
115120
this.authorizations.remove(authorization.getId(), authorization);
116-
} else {
121+
}
122+
else {
117123
this.initializedAuthorizations.remove(authorization.getId(), authorization);
118124
}
119125
}
@@ -123,9 +129,7 @@ public void remove(OAuth2Authorization authorization) {
123129
public OAuth2Authorization findById(String id) {
124130
Assert.hasText(id, "id cannot be empty");
125131
OAuth2Authorization authorization = this.authorizations.get(id);
126-
return authorization != null ?
127-
authorization :
128-
this.initializedAuthorizations.get(id);
132+
return authorization != null ? authorization : this.initializedAuthorizations.get(id);
129133
}
130134

131135
@Nullable
@@ -149,7 +153,9 @@ private static boolean isComplete(OAuth2Authorization authorization) {
149153
return authorization.getAccessToken() != null;
150154
}
151155

152-
private static boolean hasToken(OAuth2Authorization authorization, String token, @Nullable OAuth2TokenType tokenType) {
156+
private static boolean hasToken(OAuth2Authorization authorization, String token,
157+
@Nullable OAuth2TokenType tokenType) {
158+
// @formatter:off
153159
if (tokenType == null) {
154160
return matchesState(authorization, token) ||
155161
matchesAuthorizationCode(authorization, token) ||
@@ -173,6 +179,7 @@ private static boolean hasToken(OAuth2Authorization authorization, String token,
173179
} else if (OAuth2ParameterNames.USER_CODE.equals(tokenType.getValue())) {
174180
return matchesUserCode(authorization, token);
175181
}
182+
// @formatter:on
176183
return false;
177184
}
178185

@@ -181,42 +188,38 @@ private static boolean matchesState(OAuth2Authorization authorization, String to
181188
}
182189

183190
private static boolean matchesAuthorizationCode(OAuth2Authorization authorization, String token) {
184-
OAuth2Authorization.Token<OAuth2AuthorizationCode> authorizationCode =
185-
authorization.getToken(OAuth2AuthorizationCode.class);
191+
OAuth2Authorization.Token<OAuth2AuthorizationCode> authorizationCode = authorization
192+
.getToken(OAuth2AuthorizationCode.class);
186193
return authorizationCode != null && authorizationCode.getToken().getTokenValue().equals(token);
187194
}
188195

189196
private static boolean matchesAccessToken(OAuth2Authorization authorization, String token) {
190-
OAuth2Authorization.Token<OAuth2AccessToken> accessToken =
191-
authorization.getToken(OAuth2AccessToken.class);
197+
OAuth2Authorization.Token<OAuth2AccessToken> accessToken = authorization.getToken(OAuth2AccessToken.class);
192198
return accessToken != null && accessToken.getToken().getTokenValue().equals(token);
193199
}
194200

195201
private static boolean matchesRefreshToken(OAuth2Authorization authorization, String token) {
196-
OAuth2Authorization.Token<OAuth2RefreshToken> refreshToken =
197-
authorization.getToken(OAuth2RefreshToken.class);
202+
OAuth2Authorization.Token<OAuth2RefreshToken> refreshToken = authorization.getToken(OAuth2RefreshToken.class);
198203
return refreshToken != null && refreshToken.getToken().getTokenValue().equals(token);
199204
}
200205

201206
private static boolean matchesIdToken(OAuth2Authorization authorization, String token) {
202-
OAuth2Authorization.Token<OidcIdToken> idToken =
203-
authorization.getToken(OidcIdToken.class);
207+
OAuth2Authorization.Token<OidcIdToken> idToken = authorization.getToken(OidcIdToken.class);
204208
return idToken != null && idToken.getToken().getTokenValue().equals(token);
205209
}
206210

207211
private static boolean matchesDeviceCode(OAuth2Authorization authorization, String token) {
208-
OAuth2Authorization.Token<OAuth2DeviceCode> deviceCode =
209-
authorization.getToken(OAuth2DeviceCode.class);
212+
OAuth2Authorization.Token<OAuth2DeviceCode> deviceCode = authorization.getToken(OAuth2DeviceCode.class);
210213
return deviceCode != null && deviceCode.getToken().getTokenValue().equals(token);
211214
}
212215

213216
private static boolean matchesUserCode(OAuth2Authorization authorization, String token) {
214-
OAuth2Authorization.Token<OAuth2UserCode> userCode =
215-
authorization.getToken(OAuth2UserCode.class);
217+
OAuth2Authorization.Token<OAuth2UserCode> userCode = authorization.getToken(OAuth2UserCode.class);
216218
return userCode != null && userCode.getToken().getTokenValue().equals(token);
217219
}
218220

219221
private static final class MaxSizeHashMap<K, V> extends LinkedHashMap<K, V> {
222+
220223
private final int maxSize;
221224

222225
private MaxSizeHashMap(int maxSize) {

0 commit comments

Comments
 (0)