Skip to content

Commit 38de737

Browse files
larsgreferrwinch
authored andcommitted
Java 8: Statement lambda can be replaced with expression lambda
1 parent 7b2a784 commit 38de737

File tree

7 files changed

+18
-32
lines changed

7 files changed

+18
-32
lines changed

config/src/main/java/org/springframework/security/config/web/server/ServerHttpSecurity.java

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1184,9 +1184,7 @@ private Map<String, String> getLinks() {
11841184
return Collections.emptyMap();
11851185
}
11861186
Map<String, String> result = new HashMap<>();
1187-
registrations.iterator().forEachRemaining(r -> {
1188-
result.put("/oauth2/authorization/" + r.getRegistrationId(), r.getClientName());
1189-
});
1187+
registrations.iterator().forEachRemaining(r -> result.put("/oauth2/authorization/" + r.getRegistrationId(), r.getClientName()));
11901188
return result;
11911189
}
11921190

oauth2/oauth2-client/src/main/java/org/springframework/security/oauth2/client/userinfo/DefaultReactiveOAuth2UserService.java

Lines changed: 8 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -117,16 +117,14 @@ public Mono<OAuth2User> loadUser(OAuth2UserRequest userRequest)
117117
}
118118
Mono<Map<String, Object>> userAttributes = requestHeadersSpec
119119
.retrieve()
120-
.onStatus(s -> s != HttpStatus.OK, response -> {
121-
return parse(response).map(userInfoErrorResponse -> {
122-
String description = userInfoErrorResponse.getErrorObject().getDescription();
123-
OAuth2Error oauth2Error = new OAuth2Error(
124-
INVALID_USER_INFO_RESPONSE_ERROR_CODE, description,
125-
null);
126-
throw new OAuth2AuthenticationException(oauth2Error,
127-
oauth2Error.toString());
128-
});
129-
})
120+
.onStatus(s -> s != HttpStatus.OK, response -> parse(response).map(userInfoErrorResponse -> {
121+
String description = userInfoErrorResponse.getErrorObject().getDescription();
122+
OAuth2Error oauth2Error = new OAuth2Error(
123+
INVALID_USER_INFO_RESPONSE_ERROR_CODE, description,
124+
null);
125+
throw new OAuth2AuthenticationException(oauth2Error,
126+
oauth2Error.toString());
127+
}))
130128
.bodyToMono(typeReference);
131129

132130
return userAttributes.map(attrs -> {

oauth2/oauth2-client/src/main/java/org/springframework/security/oauth2/client/web/reactive/function/client/ServletOAuth2AuthorizedClientExchangeFilterFunction.java

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -255,12 +255,10 @@ public Consumer<WebClient.Builder> oauth2Configuration() {
255255
* @return the {@link Consumer} to populate the attributes
256256
*/
257257
public Consumer<WebClient.RequestHeadersSpec<?>> defaultRequest() {
258-
return spec -> {
259-
spec.attributes(attrs -> {
260-
populateDefaultRequestResponse(attrs);
261-
populateDefaultAuthentication(attrs);
262-
});
263-
};
258+
return spec -> spec.attributes(attrs -> {
259+
populateDefaultRequestResponse(attrs);
260+
populateDefaultAuthentication(attrs);
261+
});
264262
}
265263

266264
/**

oauth2/oauth2-client/src/main/java/org/springframework/security/oauth2/client/web/server/OAuth2AuthorizationRequestRedirectWebFilter.java

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -114,10 +114,8 @@ public void setRequestCache(ServerRequestCache requestCache) {
114114
public Mono<Void> filter(ServerWebExchange exchange, WebFilterChain chain) {
115115
return this.authorizationRequestResolver.resolve(exchange)
116116
.switchIfEmpty(chain.filter(exchange).then(Mono.empty()))
117-
.onErrorResume(ClientAuthorizationRequiredException.class, e -> {
118-
return this.requestCache.saveRequest(exchange)
119-
.then(this.authorizationRequestResolver.resolve(exchange, e.getClientRegistrationId()));
120-
})
117+
.onErrorResume(ClientAuthorizationRequiredException.class, e -> this.requestCache.saveRequest(exchange)
118+
.then(this.authorizationRequestResolver.resolve(exchange, e.getClientRegistrationId())))
121119
.flatMap(clientRegistration -> sendRedirectForAuthorization(exchange, clientRegistration));
122120
}
123121

oauth2/oauth2-client/src/main/java/org/springframework/security/oauth2/client/web/server/UnAuthenticatedServerOAuth2AuthorizedClientRepository.java

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -69,9 +69,7 @@ public Mono<Void> removeAuthorizedClient(String clientRegistrationId, Authentica
6969
Assert.notNull(clientRegistrationId, "clientRegistrationId cannot be null");
7070
Assert.isNull(serverWebExchange, "serverWebExchange " + serverWebExchange + "must be null");
7171
Assert.isTrue(isUnauthenticated(authentication), "The user " + authentication + " should not be authenticated");
72-
return Mono.fromRunnable(() -> {
73-
this.clientRegistrationIdToAuthorizedClient.remove(clientRegistrationId);
74-
});
72+
return Mono.fromRunnable(() -> this.clientRegistrationIdToAuthorizedClient.remove(clientRegistrationId));
7573
}
7674

7775
private boolean isUnauthenticated(Authentication authentication) {

test/src/main/java/org/springframework/security/test/web/reactive/server/SecurityMockServerConfigurers.java

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -67,9 +67,7 @@ public class SecurityMockServerConfigurers {
6767
public static MockServerConfigurer springSecurity() {
6868
return new MockServerConfigurer() {
6969
public void beforeServerCreated(WebHttpHandlerBuilder builder) {
70-
builder.filters( filters -> {
71-
filters.add(0, new MutatorFilter());
72-
});
70+
builder.filters( filters -> filters.add(0, new MutatorFilter()));
7371
}
7472
};
7573
}

web/src/main/java/org/springframework/security/web/authentication/logout/CookieClearingLogoutHandler.java

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -62,9 +62,7 @@ public CookieClearingLogoutHandler(Cookie... cookiesToClear) {
6262
List<Function<HttpServletRequest, Cookie>> cookieList = new ArrayList<>();
6363
for (Cookie cookie : cookiesToClear) {
6464
Assert.isTrue(cookie.getMaxAge() == 0, "Cookie maxAge must be 0");
65-
Function<HttpServletRequest, Cookie> f = (request) -> {
66-
return cookie;
67-
};
65+
Function<HttpServletRequest, Cookie> f = (request) -> cookie;
6866
cookieList.add(f);
6967
}
7068
this.cookiesToClear = cookieList;

0 commit comments

Comments
 (0)