Use parenthesis with single-arg lambdas
Use regular expression search/replace to ensure all single-arg lambdas have parenthesis. This aligns with the style used in Spring Boot and ensure that single-arg and multi-arg lambdas are consistent. Issue gh-8945
This commit is contained in:
@@ -233,7 +233,7 @@ public class ExceptionTranslationFilter extends GenericFilterBean {
|
||||
protected void initExtractorMap() {
|
||||
super.initExtractorMap();
|
||||
|
||||
registerExtractor(ServletException.class, throwable -> {
|
||||
registerExtractor(ServletException.class, (throwable) -> {
|
||||
ThrowableAnalyzer.verifyThrowableHierarchy(throwable, ServletException.class);
|
||||
return ((ServletException) throwable).getRootCause();
|
||||
});
|
||||
|
||||
@@ -77,7 +77,7 @@ public class AuthenticationFilter extends OncePerRequestFilter {
|
||||
|
||||
public AuthenticationFilter(AuthenticationManager authenticationManager,
|
||||
AuthenticationConverter authenticationConverter) {
|
||||
this((AuthenticationManagerResolver<HttpServletRequest>) r -> authenticationManager, authenticationConverter);
|
||||
this((AuthenticationManagerResolver<HttpServletRequest>) (r) -> authenticationManager, authenticationConverter);
|
||||
}
|
||||
|
||||
public AuthenticationFilter(AuthenticationManagerResolver<HttpServletRequest> authenticationManagerResolver,
|
||||
|
||||
@@ -73,7 +73,7 @@ public final class CookieClearingLogoutHandler implements LogoutHandler {
|
||||
|
||||
@Override
|
||||
public void logout(HttpServletRequest request, HttpServletResponse response, Authentication authentication) {
|
||||
this.cookiesToClear.forEach(f -> response.addCookie(f.apply(request)));
|
||||
this.cookiesToClear.forEach((f) -> response.addCookie(f.apply(request)));
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -87,7 +87,7 @@ public class DefaultLoginPageGeneratingFilter extends GenericFilterBean {
|
||||
|
||||
private Map<String, String> saml2AuthenticationUrlToProviderName;
|
||||
|
||||
private Function<HttpServletRequest, Map<String, String>> resolveHiddenInputs = request -> Collections.emptyMap();
|
||||
private Function<HttpServletRequest, Map<String, String>> resolveHiddenInputs = (request) -> Collections.emptyMap();
|
||||
|
||||
public DefaultLoginPageGeneratingFilter() {
|
||||
}
|
||||
|
||||
@@ -41,7 +41,7 @@ public class DefaultLogoutPageGeneratingFilter extends OncePerRequestFilter {
|
||||
|
||||
private RequestMatcher matcher = new AntPathRequestMatcher("/logout", "GET");
|
||||
|
||||
private Function<HttpServletRequest, Map<String, String>> resolveHiddenInputs = request -> Collections.emptyMap();
|
||||
private Function<HttpServletRequest, Map<String, String>> resolveHiddenInputs = (request) -> Collections.emptyMap();
|
||||
|
||||
@Override
|
||||
protected void doFilterInternal(HttpServletRequest request, HttpServletResponse response, FilterChain filterChain)
|
||||
|
||||
@@ -112,13 +112,13 @@ public class StrictHttpFirewall implements HttpFirewall {
|
||||
|
||||
private Set<String> allowedHttpMethods = createDefaultAllowedHttpMethods();
|
||||
|
||||
private Predicate<String> allowedHostnames = hostname -> true;
|
||||
private Predicate<String> allowedHostnames = (hostname) -> true;
|
||||
|
||||
private static final Pattern ASSIGNED_AND_NOT_ISO_CONTROL_PATTERN = Pattern
|
||||
.compile("[\\p{IsAssigned}&&[^\\p{IsControl}]]*");
|
||||
|
||||
private static final Predicate<String> ASSIGNED_AND_NOT_ISO_CONTROL_PREDICATE = s -> ASSIGNED_AND_NOT_ISO_CONTROL_PATTERN
|
||||
.matcher(s).matches();
|
||||
private static final Predicate<String> ASSIGNED_AND_NOT_ISO_CONTROL_PREDICATE = (
|
||||
s) -> ASSIGNED_AND_NOT_ISO_CONTROL_PATTERN.matcher(s).matches();
|
||||
|
||||
private Predicate<String> allowedHeaderNames = ASSIGNED_AND_NOT_ISO_CONTROL_PREDICATE;
|
||||
|
||||
@@ -126,7 +126,7 @@ public class StrictHttpFirewall implements HttpFirewall {
|
||||
|
||||
private Predicate<String> allowedParameterNames = ASSIGNED_AND_NOT_ISO_CONTROL_PREDICATE;
|
||||
|
||||
private Predicate<String> allowedParameterValues = value -> true;
|
||||
private Predicate<String> allowedParameterValues = (value) -> true;
|
||||
|
||||
public StrictHttpFirewall() {
|
||||
urlBlocklistsAddAll(FORBIDDEN_SEMICOLON);
|
||||
|
||||
@@ -46,7 +46,7 @@ public class CompositeHeaderWriter implements HeaderWriter {
|
||||
|
||||
@Override
|
||||
public void writeHeaders(HttpServletRequest request, HttpServletResponse response) {
|
||||
this.headerWriters.forEach(headerWriter -> headerWriter.writeHeaders(request, response));
|
||||
this.headerWriters.forEach((headerWriter) -> headerWriter.writeHeaders(request, response));
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -37,7 +37,7 @@ public final class SecurityHeaders {
|
||||
*/
|
||||
public static Consumer<HttpHeaders> bearerToken(String bearerTokenValue) {
|
||||
Assert.hasText(bearerTokenValue, "bearerTokenValue cannot be null");
|
||||
return headers -> headers.set(HttpHeaders.AUTHORIZATION, "Bearer " + bearerTokenValue);
|
||||
return (headers) -> headers.set(HttpHeaders.AUTHORIZATION, "Bearer " + bearerTokenValue);
|
||||
}
|
||||
|
||||
private SecurityHeaders() {
|
||||
|
||||
@@ -72,7 +72,7 @@ public class AuthenticationPrincipalArgumentResolver extends HandlerMethodArgume
|
||||
public Mono<Object> resolveArgument(MethodParameter parameter, BindingContext bindingContext,
|
||||
ServerWebExchange exchange) {
|
||||
ReactiveAdapter adapter = getAdapterRegistry().getAdapter(parameter.getParameterType());
|
||||
return ReactiveSecurityContextHolder.getContext().map(SecurityContext::getAuthentication).flatMap(a -> {
|
||||
return ReactiveSecurityContextHolder.getContext().map(SecurityContext::getAuthentication).flatMap((a) -> {
|
||||
Object p = resolvePrincipal(parameter, a.getPrincipal());
|
||||
Mono<Object> principal = Mono.justOrEmpty(p);
|
||||
return adapter == null ? principal : Mono.just(adapter.fromPublisher(principal));
|
||||
|
||||
@@ -84,7 +84,7 @@ public class CurrentSecurityContextArgumentResolver extends HandlerMethodArgumen
|
||||
if (reactiveSecurityContext == null) {
|
||||
return null;
|
||||
}
|
||||
return reactiveSecurityContext.flatMap(a -> {
|
||||
return reactiveSecurityContext.flatMap((a) -> {
|
||||
Object p = resolveSecurityContext(parameter, a);
|
||||
Mono<Object> o = Mono.justOrEmpty(p);
|
||||
return adapter == null ? o : Mono.just(adapter.fromPublisher(o));
|
||||
|
||||
@@ -170,7 +170,7 @@ public class DefaultSavedRequest implements SavedRequest {
|
||||
}
|
||||
|
||||
private void addHeader(String name, String value) {
|
||||
List<String> values = this.headers.computeIfAbsent(name, k -> new ArrayList<>());
|
||||
List<String> values = this.headers.computeIfAbsent(name, (k) -> new ArrayList<>());
|
||||
|
||||
values.add(value);
|
||||
}
|
||||
|
||||
@@ -60,16 +60,16 @@ public class DelegatingServerAuthenticationEntryPoint implements ServerAuthentic
|
||||
|
||||
@Override
|
||||
public Mono<Void> commence(ServerWebExchange exchange, AuthenticationException ex) {
|
||||
return Flux.fromIterable(this.entryPoints).filterWhen(entry -> isMatch(exchange, entry)).next()
|
||||
.map(entry -> entry.getEntryPoint()).doOnNext(it -> {
|
||||
return Flux.fromIterable(this.entryPoints).filterWhen((entry) -> isMatch(exchange, entry)).next()
|
||||
.map((entry) -> entry.getEntryPoint()).doOnNext((it) -> {
|
||||
if (logger.isDebugEnabled()) {
|
||||
logger.debug("Match found! Executing " + it);
|
||||
}
|
||||
}).switchIfEmpty(Mono.just(this.defaultEntryPoint).doOnNext(it -> {
|
||||
}).switchIfEmpty(Mono.just(this.defaultEntryPoint).doOnNext((it) -> {
|
||||
if (logger.isDebugEnabled()) {
|
||||
logger.debug("No match found. Using default entry point " + this.defaultEntryPoint);
|
||||
}
|
||||
})).flatMap(entryPoint -> entryPoint.commence(exchange, ex));
|
||||
})).flatMap((entryPoint) -> entryPoint.commence(exchange, ex));
|
||||
}
|
||||
|
||||
private Mono<Boolean> isMatch(ServerWebExchange exchange, DelegateEntry entry) {
|
||||
@@ -77,7 +77,7 @@ public class DelegatingServerAuthenticationEntryPoint implements ServerAuthentic
|
||||
if (logger.isDebugEnabled()) {
|
||||
logger.debug("Trying to match using " + matcher);
|
||||
}
|
||||
return matcher.matches(exchange).map(result -> result.isMatch());
|
||||
return matcher.matches(exchange).map((result) -> result.isMatch());
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -48,7 +48,7 @@ public class MatcherSecurityWebFilterChain implements SecurityWebFilterChain {
|
||||
|
||||
@Override
|
||||
public Mono<Boolean> matches(ServerWebExchange exchange) {
|
||||
return this.matcher.matches(exchange).map(m -> m.isMatch());
|
||||
return this.matcher.matches(exchange).map((m) -> m.isMatch());
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -46,7 +46,7 @@ public class ServerFormLoginAuthenticationConverter implements Function<ServerWe
|
||||
@Override
|
||||
@Deprecated
|
||||
public Mono<Authentication> apply(ServerWebExchange exchange) {
|
||||
return exchange.getFormData().map(data -> createAuthentication(data));
|
||||
return exchange.getFormData().map((data) -> createAuthentication(data));
|
||||
}
|
||||
|
||||
private UsernamePasswordAuthenticationToken createAuthentication(MultiValueMap<String, String> data) {
|
||||
|
||||
@@ -49,12 +49,12 @@ public class WebFilterChainProxy implements WebFilter {
|
||||
@Override
|
||||
public Mono<Void> filter(ServerWebExchange exchange, WebFilterChain chain) {
|
||||
return Flux.fromIterable(this.filters)
|
||||
.filterWhen(securityWebFilterChain -> securityWebFilterChain.matches(exchange)).next()
|
||||
.filterWhen((securityWebFilterChain) -> securityWebFilterChain.matches(exchange)).next()
|
||||
.switchIfEmpty(chain.filter(exchange).then(Mono.empty()))
|
||||
.flatMap(securityWebFilterChain -> securityWebFilterChain.getWebFilters().collectList())
|
||||
.map(filters -> new FilteringWebHandler(webHandler -> chain.filter(webHandler), filters))
|
||||
.map(handler -> new DefaultWebFilterChain(handler))
|
||||
.flatMap(securedChain -> securedChain.filter(exchange));
|
||||
.flatMap((securityWebFilterChain) -> securityWebFilterChain.getWebFilters().collectList())
|
||||
.map((filters) -> new FilteringWebHandler((webHandler) -> chain.filter(webHandler), filters))
|
||||
.map((handler) -> new DefaultWebFilterChain(handler))
|
||||
.flatMap((securedChain) -> securedChain.filter(exchange));
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -86,7 +86,7 @@ public class AnonymousAuthenticationWebFilter implements WebFilter {
|
||||
return chain.filter(exchange)
|
||||
.subscriberContext(ReactiveSecurityContextHolder.withSecurityContext(Mono.just(securityContext)))
|
||||
.then(Mono.empty());
|
||||
})).flatMap(securityContext -> {
|
||||
})).flatMap((securityContext) -> {
|
||||
if (logger.isDebugEnabled()) {
|
||||
logger.debug("SecurityContext contains anonymous token: '" + securityContext.getAuthentication() + "'");
|
||||
}
|
||||
|
||||
@@ -43,8 +43,8 @@ public final class AuthenticationConverterServerWebExchangeMatcher implements Se
|
||||
|
||||
@Override
|
||||
public Mono<MatchResult> matches(ServerWebExchange exchange) {
|
||||
return this.serverAuthenticationConverter.convert(exchange).flatMap(a -> MatchResult.match())
|
||||
.onErrorResume(e -> MatchResult.notMatch()).switchIfEmpty(MatchResult.notMatch());
|
||||
return this.serverAuthenticationConverter.convert(exchange).flatMap((a) -> MatchResult.match())
|
||||
.onErrorResume((e) -> MatchResult.notMatch()).switchIfEmpty(MatchResult.notMatch());
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -91,7 +91,7 @@ public class AuthenticationWebFilter implements WebFilter {
|
||||
*/
|
||||
public AuthenticationWebFilter(ReactiveAuthenticationManager authenticationManager) {
|
||||
Assert.notNull(authenticationManager, "authenticationManager cannot be null");
|
||||
this.authenticationManagerResolver = request -> Mono.just(authenticationManager);
|
||||
this.authenticationManagerResolver = (request) -> Mono.just(authenticationManager);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -107,22 +107,22 @@ public class AuthenticationWebFilter implements WebFilter {
|
||||
|
||||
@Override
|
||||
public Mono<Void> filter(ServerWebExchange exchange, WebFilterChain chain) {
|
||||
return this.requiresAuthenticationMatcher.matches(exchange).filter(matchResult -> matchResult.isMatch())
|
||||
.flatMap(matchResult -> this.authenticationConverter.convert(exchange))
|
||||
return this.requiresAuthenticationMatcher.matches(exchange).filter((matchResult) -> matchResult.isMatch())
|
||||
.flatMap((matchResult) -> this.authenticationConverter.convert(exchange))
|
||||
.switchIfEmpty(chain.filter(exchange).then(Mono.empty()))
|
||||
.flatMap(token -> authenticate(exchange, chain, token))
|
||||
.onErrorResume(AuthenticationException.class, e -> this.authenticationFailureHandler
|
||||
.flatMap((token) -> authenticate(exchange, chain, token))
|
||||
.onErrorResume(AuthenticationException.class, (e) -> this.authenticationFailureHandler
|
||||
.onAuthenticationFailure(new WebFilterExchange(exchange, chain), e));
|
||||
}
|
||||
|
||||
private Mono<Void> authenticate(ServerWebExchange exchange, WebFilterChain chain, Authentication token) {
|
||||
return this.authenticationManagerResolver.resolve(exchange)
|
||||
.flatMap(authenticationManager -> authenticationManager.authenticate(token))
|
||||
.flatMap((authenticationManager) -> authenticationManager.authenticate(token))
|
||||
.switchIfEmpty(Mono.defer(
|
||||
() -> Mono.error(new IllegalStateException("No provider found for " + token.getClass()))))
|
||||
.flatMap(authentication -> onAuthenticationSuccess(authentication,
|
||||
.flatMap((authentication) -> onAuthenticationSuccess(authentication,
|
||||
new WebFilterExchange(exchange, chain)))
|
||||
.doOnError(AuthenticationException.class, e -> {
|
||||
.doOnError(AuthenticationException.class, (e) -> {
|
||||
if (logger.isDebugEnabled()) {
|
||||
logger.debug("Authentication failed: " + e.getMessage());
|
||||
}
|
||||
|
||||
@@ -45,7 +45,7 @@ public class DelegatingServerAuthenticationSuccessHandler implements ServerAuthe
|
||||
@Override
|
||||
public Mono<Void> onAuthenticationSuccess(WebFilterExchange exchange, Authentication authentication) {
|
||||
return Flux.fromIterable(this.delegates)
|
||||
.concatMap(delegate -> delegate.onAuthenticationSuccess(exchange, authentication)).then();
|
||||
.concatMap((delegate) -> delegate.onAuthenticationSuccess(exchange, authentication)).then();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -61,7 +61,7 @@ public class ReactivePreAuthenticatedAuthenticationManager implements ReactiveAu
|
||||
return Mono.just(authentication).filter(this::supports).map(Authentication::getName)
|
||||
.flatMap(this.userDetailsService::findByUsername)
|
||||
.switchIfEmpty(Mono.error(() -> new UsernameNotFoundException("User not found")))
|
||||
.doOnNext(this.userDetailsChecker::check).map(ud -> {
|
||||
.doOnNext(this.userDetailsChecker::check).map((ud) -> {
|
||||
PreAuthenticatedAuthenticationToken result = new PreAuthenticatedAuthenticationToken(ud,
|
||||
authentication.getCredentials(), ud.getAuthorities());
|
||||
result.setDetails(authentication.getDetails());
|
||||
|
||||
@@ -73,7 +73,7 @@ public class RedirectServerAuthenticationSuccessHandler implements ServerAuthent
|
||||
public Mono<Void> onAuthenticationSuccess(WebFilterExchange webFilterExchange, Authentication authentication) {
|
||||
ServerWebExchange exchange = webFilterExchange.getExchange();
|
||||
return this.requestCache.getRedirectUri(exchange).defaultIfEmpty(this.location)
|
||||
.flatMap(location -> this.redirectStrategy.sendRedirect(exchange, location));
|
||||
.flatMap((location) -> this.redirectStrategy.sendRedirect(exchange, location));
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -168,8 +168,8 @@ public class SwitchUserWebFilter implements WebFilter {
|
||||
|
||||
return switchUser(webFilterExchange).switchIfEmpty(Mono.defer(() -> exitSwitchUser(webFilterExchange)))
|
||||
.switchIfEmpty(Mono.defer(() -> chain.filter(exchange).then(Mono.empty())))
|
||||
.flatMap(authentication -> onAuthenticationSuccess(authentication, webFilterExchange))
|
||||
.onErrorResume(SwitchUserAuthenticationException.class, exception -> Mono.empty());
|
||||
.flatMap((authentication) -> onAuthenticationSuccess(authentication, webFilterExchange))
|
||||
.onErrorResume(SwitchUserAuthenticationException.class, (exception) -> Mono.empty());
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -183,11 +183,11 @@ public class SwitchUserWebFilter implements WebFilter {
|
||||
protected Mono<Authentication> switchUser(WebFilterExchange webFilterExchange) {
|
||||
return this.switchUserMatcher.matches(webFilterExchange.getExchange())
|
||||
.filter(ServerWebExchangeMatcher.MatchResult::isMatch)
|
||||
.flatMap(matchResult -> ReactiveSecurityContextHolder.getContext())
|
||||
.map(SecurityContext::getAuthentication).flatMap(currentAuthentication -> {
|
||||
.flatMap((matchResult) -> ReactiveSecurityContextHolder.getContext())
|
||||
.map(SecurityContext::getAuthentication).flatMap((currentAuthentication) -> {
|
||||
final String username = getUsername(webFilterExchange.getExchange());
|
||||
return attemptSwitchUser(currentAuthentication, username);
|
||||
}).onErrorResume(AuthenticationException.class, e -> onAuthenticationFailure(e, webFilterExchange)
|
||||
}).onErrorResume(AuthenticationException.class, (e) -> onAuthenticationFailure(e, webFilterExchange)
|
||||
.then(Mono.error(new SwitchUserAuthenticationException(e))));
|
||||
}
|
||||
|
||||
@@ -202,7 +202,7 @@ public class SwitchUserWebFilter implements WebFilter {
|
||||
protected Mono<Authentication> exitSwitchUser(WebFilterExchange webFilterExchange) {
|
||||
return this.exitUserMatcher.matches(webFilterExchange.getExchange())
|
||||
.filter(ServerWebExchangeMatcher.MatchResult::isMatch)
|
||||
.flatMap(matchResult -> ReactiveSecurityContextHolder.getContext()
|
||||
.flatMap((matchResult) -> ReactiveSecurityContextHolder.getContext()
|
||||
.map(SecurityContext::getAuthentication)
|
||||
.switchIfEmpty(Mono.error(this::noCurrentUserException)))
|
||||
.map(this::attemptExitUser);
|
||||
@@ -228,7 +228,7 @@ public class SwitchUserWebFilter implements WebFilter {
|
||||
return this.userDetailsService.findByUsername(userName)
|
||||
.switchIfEmpty(Mono.error(this::noTargetAuthenticationException))
|
||||
.doOnNext(this.userDetailsChecker::check)
|
||||
.map(userDetails -> createSwitchUserToken(userDetails, currentAuthentication));
|
||||
.map((userDetails) -> createSwitchUserToken(userDetails, currentAuthentication));
|
||||
}
|
||||
|
||||
@NonNull
|
||||
@@ -255,7 +255,7 @@ public class SwitchUserWebFilter implements WebFilter {
|
||||
return Mono.justOrEmpty(this.failureHandler).switchIfEmpty(Mono.defer(() -> {
|
||||
this.logger.error("Switch User failed", exception);
|
||||
return Mono.error(exception);
|
||||
})).flatMap(failureHandler -> failureHandler.onAuthenticationFailure(webFilterExchange, exception));
|
||||
})).flatMap((failureHandler) -> failureHandler.onAuthenticationFailure(webFilterExchange, exception));
|
||||
}
|
||||
|
||||
private Authentication createSwitchUserToken(UserDetails targetUser, Authentication currentAuthentication) {
|
||||
|
||||
@@ -50,7 +50,7 @@ public class DelegatingServerLogoutHandler implements ServerLogoutHandler {
|
||||
|
||||
@Override
|
||||
public Mono<Void> logout(WebFilterExchange exchange, Authentication authentication) {
|
||||
return Flux.fromIterable(this.delegates).concatMap(delegate -> delegate.logout(exchange, authentication))
|
||||
return Flux.fromIterable(this.delegates).concatMap((delegate) -> delegate.logout(exchange, authentication))
|
||||
.then();
|
||||
}
|
||||
|
||||
|
||||
@@ -57,9 +57,9 @@ public class LogoutWebFilter implements WebFilter {
|
||||
|
||||
@Override
|
||||
public Mono<Void> filter(ServerWebExchange exchange, WebFilterChain chain) {
|
||||
return this.requiresLogout.matches(exchange).filter(result -> result.isMatch())
|
||||
.switchIfEmpty(chain.filter(exchange).then(Mono.empty())).map(result -> exchange)
|
||||
.flatMap(this::flatMapAuthentication).flatMap(authentication -> {
|
||||
return this.requiresLogout.matches(exchange).filter((result) -> result.isMatch())
|
||||
.switchIfEmpty(chain.filter(exchange).then(Mono.empty())).map((result) -> exchange)
|
||||
.flatMap(this::flatMapAuthentication).flatMap((authentication) -> {
|
||||
WebFilterExchange webFilterExchange = new WebFilterExchange(exchange, chain);
|
||||
return logout(webFilterExchange, authentication);
|
||||
});
|
||||
|
||||
@@ -45,13 +45,14 @@ public class AuthorizationWebFilter implements WebFilter {
|
||||
|
||||
@Override
|
||||
public Mono<Void> filter(ServerWebExchange exchange, WebFilterChain chain) {
|
||||
return ReactiveSecurityContextHolder.getContext().filter(c -> c.getAuthentication() != null)
|
||||
return ReactiveSecurityContextHolder.getContext().filter((c) -> c.getAuthentication() != null)
|
||||
.map(SecurityContext::getAuthentication)
|
||||
.as(authentication -> this.authorizationManager.verify(authentication, exchange)).doOnSuccess(it -> {
|
||||
.as((authentication) -> this.authorizationManager.verify(authentication, exchange))
|
||||
.doOnSuccess((it) -> {
|
||||
if (logger.isDebugEnabled()) {
|
||||
logger.debug("Authorization successful");
|
||||
}
|
||||
}).doOnError(AccessDeniedException.class, e -> {
|
||||
}).doOnError(AccessDeniedException.class, (e) -> {
|
||||
if (logger.isDebugEnabled()) {
|
||||
logger.debug("Authorization failed: " + e.getMessage());
|
||||
}
|
||||
|
||||
@@ -49,8 +49,8 @@ public final class DelegatingReactiveAuthorizationManager implements ReactiveAut
|
||||
|
||||
@Override
|
||||
public Mono<AuthorizationDecision> check(Mono<Authentication> authentication, ServerWebExchange exchange) {
|
||||
return Flux.fromIterable(this.mappings).concatMap(mapping -> mapping.getMatcher().matches(exchange)
|
||||
.filter(MatchResult::isMatch).map(MatchResult::getVariables).flatMap(variables -> {
|
||||
return Flux.fromIterable(this.mappings).concatMap((mapping) -> mapping.getMatcher().matches(exchange)
|
||||
.filter(MatchResult::isMatch).map(MatchResult::getVariables).flatMap((variables) -> {
|
||||
if (logger.isDebugEnabled()) {
|
||||
logger.debug(
|
||||
"Checking authorization on '" + exchange.getRequest().getPath().pathWithinApplication()
|
||||
|
||||
@@ -42,8 +42,8 @@ public class ExceptionTranslationWebFilter implements WebFilter {
|
||||
@Override
|
||||
public Mono<Void> filter(ServerWebExchange exchange, WebFilterChain chain) {
|
||||
return chain.filter(exchange).onErrorResume(AccessDeniedException.class,
|
||||
denied -> exchange.getPrincipal().switchIfEmpty(commenceAuthentication(exchange, denied))
|
||||
.flatMap(principal -> this.accessDeniedHandler.handle(exchange, denied)));
|
||||
(denied) -> exchange.getPrincipal().switchIfEmpty(commenceAuthentication(exchange, denied))
|
||||
.flatMap((principal) -> this.accessDeniedHandler.handle(exchange, denied)));
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -50,12 +50,12 @@ public class HttpStatusServerAccessDeniedHandler implements ServerAccessDeniedHa
|
||||
|
||||
@Override
|
||||
public Mono<Void> handle(ServerWebExchange exchange, AccessDeniedException ex) {
|
||||
return Mono.defer(() -> Mono.just(exchange.getResponse())).flatMap(response -> {
|
||||
return Mono.defer(() -> Mono.just(exchange.getResponse())).flatMap((response) -> {
|
||||
response.setStatusCode(this.httpStatus);
|
||||
response.getHeaders().setContentType(MediaType.TEXT_PLAIN);
|
||||
DataBufferFactory dataBufferFactory = response.bufferFactory();
|
||||
DataBuffer buffer = dataBufferFactory.wrap(ex.getMessage().getBytes(Charset.defaultCharset()));
|
||||
return response.writeWith(Mono.just(buffer)).doOnError(error -> DataBufferUtils.release(buffer));
|
||||
return response.writeWith(Mono.just(buffer)).doOnError((error) -> DataBufferUtils.release(buffer));
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
@@ -69,9 +69,9 @@ public class ServerWebExchangeDelegatingServerAccessDeniedHandler implements Ser
|
||||
|
||||
@Override
|
||||
public Mono<Void> handle(ServerWebExchange exchange, AccessDeniedException denied) {
|
||||
return Flux.fromIterable(this.handlers).filterWhen(entry -> isMatch(exchange, entry)).next()
|
||||
return Flux.fromIterable(this.handlers).filterWhen((entry) -> isMatch(exchange, entry)).next()
|
||||
.map(DelegateEntry::getAccessDeniedHandler).defaultIfEmpty(this.defaultHandler)
|
||||
.flatMap(handler -> handler.handle(exchange, denied));
|
||||
.flatMap((handler) -> handler.handle(exchange, denied));
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -45,7 +45,7 @@ public class ReactorContextWebFilter implements WebFilter {
|
||||
@Override
|
||||
public Mono<Void> filter(ServerWebExchange exchange, WebFilterChain chain) {
|
||||
return chain.filter(exchange)
|
||||
.subscriberContext(c -> c.hasKey(SecurityContext.class) ? c : withSecurityContext(c, exchange));
|
||||
.subscriberContext((c) -> c.hasKey(SecurityContext.class) ? c : withSecurityContext(c, exchange));
|
||||
}
|
||||
|
||||
private Context withSecurityContext(Context mainContext, ServerWebExchange exchange) {
|
||||
|
||||
@@ -44,7 +44,7 @@ public class SecurityContextServerWebExchange extends ServerWebExchangeDecorator
|
||||
@Override
|
||||
@SuppressWarnings("unchecked")
|
||||
public <T extends Principal> Mono<T> getPrincipal() {
|
||||
return this.context.map(c -> (T) c.getAuthentication());
|
||||
return this.context.map((c) -> (T) c.getAuthentication());
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -56,7 +56,7 @@ public class WebSessionServerSecurityContextRepository implements ServerSecurity
|
||||
|
||||
@Override
|
||||
public Mono<Void> save(ServerWebExchange exchange, SecurityContext context) {
|
||||
return exchange.getSession().doOnNext(session -> {
|
||||
return exchange.getSession().doOnNext((session) -> {
|
||||
if (context == null) {
|
||||
session.getAttributes().remove(this.springSecurityContextAttrName);
|
||||
if (logger.isDebugEnabled()) {
|
||||
@@ -69,12 +69,12 @@ public class WebSessionServerSecurityContextRepository implements ServerSecurity
|
||||
logger.debug("Saved SecurityContext '" + context + "' in WebSession: '" + session + "'");
|
||||
}
|
||||
}
|
||||
}).flatMap(session -> session.changeSessionId());
|
||||
}).flatMap((session) -> session.changeSessionId());
|
||||
}
|
||||
|
||||
@Override
|
||||
public Mono<SecurityContext> load(ServerWebExchange exchange) {
|
||||
return exchange.getSession().flatMap(session -> {
|
||||
return exchange.getSession().flatMap((session) -> {
|
||||
SecurityContext context = (SecurityContext) session.getAttribute(this.springSecurityContextAttrName);
|
||||
if (logger.isDebugEnabled()) {
|
||||
if (context == null) {
|
||||
|
||||
@@ -116,11 +116,11 @@ public class CsrfWebFilter implements WebFilter {
|
||||
return chain.filter(exchange).then(Mono.empty());
|
||||
}
|
||||
|
||||
return this.requireCsrfProtectionMatcher.matches(exchange).filter(matchResult -> matchResult.isMatch())
|
||||
.filter(matchResult -> !exchange.getAttributes().containsKey(CsrfToken.class.getName()))
|
||||
.flatMap(m -> validateToken(exchange)).flatMap(m -> continueFilterChain(exchange, chain))
|
||||
return this.requireCsrfProtectionMatcher.matches(exchange).filter((matchResult) -> matchResult.isMatch())
|
||||
.filter((matchResult) -> !exchange.getAttributes().containsKey(CsrfToken.class.getName()))
|
||||
.flatMap((m) -> validateToken(exchange)).flatMap((m) -> continueFilterChain(exchange, chain))
|
||||
.switchIfEmpty(continueFilterChain(exchange, chain).then(Mono.empty()))
|
||||
.onErrorResume(CsrfException.class, e -> this.accessDeniedHandler.handle(exchange, e));
|
||||
.onErrorResume(CsrfException.class, (e) -> this.accessDeniedHandler.handle(exchange, e));
|
||||
}
|
||||
|
||||
public static void skipExchange(ServerWebExchange exchange) {
|
||||
@@ -131,15 +131,15 @@ public class CsrfWebFilter implements WebFilter {
|
||||
return this.csrfTokenRepository.loadToken(exchange)
|
||||
.switchIfEmpty(Mono
|
||||
.defer(() -> Mono.error(new CsrfException("CSRF Token has been associated to this client"))))
|
||||
.filterWhen(expected -> containsValidCsrfToken(exchange, expected))
|
||||
.filterWhen((expected) -> containsValidCsrfToken(exchange, expected))
|
||||
.switchIfEmpty(Mono.defer(() -> Mono.error(new CsrfException("Invalid CSRF Token")))).then();
|
||||
}
|
||||
|
||||
private Mono<Boolean> containsValidCsrfToken(ServerWebExchange exchange, CsrfToken expected) {
|
||||
return exchange.getFormData().flatMap(data -> Mono.justOrEmpty(data.getFirst(expected.getParameterName())))
|
||||
return exchange.getFormData().flatMap((data) -> Mono.justOrEmpty(data.getFirst(expected.getParameterName())))
|
||||
.switchIfEmpty(Mono.justOrEmpty(exchange.getRequest().getHeaders().getFirst(expected.getHeaderName())))
|
||||
.switchIfEmpty(tokenFromMultipartData(exchange, expected))
|
||||
.map(actual -> actual.equals(expected.getToken()));
|
||||
.map((actual) -> actual.equals(expected.getToken()));
|
||||
}
|
||||
|
||||
private Mono<String> tokenFromMultipartData(ServerWebExchange exchange, CsrfToken expected) {
|
||||
@@ -152,7 +152,7 @@ public class CsrfWebFilter implements WebFilter {
|
||||
if (!contentType.includes(MediaType.MULTIPART_FORM_DATA)) {
|
||||
return Mono.empty();
|
||||
}
|
||||
return exchange.getMultipartData().map(d -> d.getFirst(expected.getParameterName())).cast(FormFieldPart.class)
|
||||
return exchange.getMultipartData().map((d) -> d.getFirst(expected.getParameterName())).cast(FormFieldPart.class)
|
||||
.map(FormFieldPart::value);
|
||||
}
|
||||
|
||||
@@ -170,7 +170,7 @@ public class CsrfWebFilter implements WebFilter {
|
||||
|
||||
private Mono<CsrfToken> generateToken(ServerWebExchange exchange) {
|
||||
return this.csrfTokenRepository.generateToken(exchange)
|
||||
.delayUntil(token -> this.csrfTokenRepository.saveToken(exchange, token));
|
||||
.delayUntil((token) -> this.csrfTokenRepository.saveToken(exchange, token));
|
||||
}
|
||||
|
||||
private static class DefaultRequireCsrfProtectionMatcher implements ServerWebExchangeMatcher {
|
||||
@@ -180,8 +180,8 @@ public class CsrfWebFilter implements WebFilter {
|
||||
|
||||
@Override
|
||||
public Mono<MatchResult> matches(ServerWebExchange exchange) {
|
||||
return Mono.just(exchange.getRequest()).flatMap(r -> Mono.justOrEmpty(r.getMethod()))
|
||||
.filter(m -> ALLOWED_METHODS.contains(m)).flatMap(m -> MatchResult.notMatch())
|
||||
return Mono.just(exchange.getRequest()).flatMap((r) -> Mono.justOrEmpty(r.getMethod()))
|
||||
.filter((m) -> ALLOWED_METHODS.contains(m)).flatMap((m) -> MatchResult.notMatch())
|
||||
.switchIfEmpty(MatchResult.match());
|
||||
}
|
||||
|
||||
|
||||
@@ -58,8 +58,8 @@ public class WebSessionServerCsrfTokenRepository implements ServerCsrfTokenRepos
|
||||
|
||||
@Override
|
||||
public Mono<Void> saveToken(ServerWebExchange exchange, CsrfToken token) {
|
||||
return exchange.getSession().doOnNext(session -> putToken(session.getAttributes(), token))
|
||||
.flatMap(session -> session.changeSessionId());
|
||||
return exchange.getSession().doOnNext((session) -> putToken(session.getAttributes(), token))
|
||||
.flatMap((session) -> session.changeSessionId());
|
||||
}
|
||||
|
||||
private void putToken(Map<String, Object> attributes, CsrfToken token) {
|
||||
@@ -73,8 +73,8 @@ public class WebSessionServerCsrfTokenRepository implements ServerCsrfTokenRepos
|
||||
|
||||
@Override
|
||||
public Mono<CsrfToken> loadToken(ServerWebExchange exchange) {
|
||||
return exchange.getSession().filter(s -> s.getAttributes().containsKey(this.sessionAttributeName))
|
||||
.map(s -> s.getAttribute(this.sessionAttributeName));
|
||||
return exchange.getSession().filter((s) -> s.getAttributes().containsKey(this.sessionAttributeName))
|
||||
.map((s) -> s.getAttribute(this.sessionAttributeName));
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -44,7 +44,7 @@ public class CompositeServerHttpHeadersWriter implements ServerHttpHeadersWriter
|
||||
|
||||
@Override
|
||||
public Mono<Void> writeHttpHeaders(ServerWebExchange exchange) {
|
||||
return Flux.fromIterable(this.writers).concatMap(w -> w.writeHttpHeaders(exchange)).then();
|
||||
return Flux.fromIterable(this.writers).concatMap((w) -> w.writeHttpHeaders(exchange)).then();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -71,8 +71,8 @@ public class CookieServerRequestCache implements ServerRequestCache {
|
||||
|
||||
@Override
|
||||
public Mono<Void> saveRequest(ServerWebExchange exchange) {
|
||||
return this.saveRequestMatcher.matches(exchange).filter(m -> m.isMatch()).map(m -> exchange.getResponse())
|
||||
.map(ServerHttpResponse::getCookies).doOnNext(cookies -> {
|
||||
return this.saveRequestMatcher.matches(exchange).filter((m) -> m.isMatch()).map((m) -> exchange.getResponse())
|
||||
.map(ServerHttpResponse::getCookies).doOnNext((cookies) -> {
|
||||
ResponseCookie redirectUriCookie = createRedirectUriCookie(exchange.getRequest());
|
||||
cookies.add(REDIRECT_URI_COOKIE_NAME, redirectUriCookie);
|
||||
if (logger.isDebugEnabled()) {
|
||||
@@ -86,13 +86,13 @@ public class CookieServerRequestCache implements ServerRequestCache {
|
||||
MultiValueMap<String, HttpCookie> cookieMap = exchange.getRequest().getCookies();
|
||||
return Mono.justOrEmpty(cookieMap.getFirst(REDIRECT_URI_COOKIE_NAME)).map(HttpCookie::getValue)
|
||||
.map(CookieServerRequestCache::decodeCookie)
|
||||
.onErrorResume(IllegalArgumentException.class, e -> Mono.empty()).map(URI::create);
|
||||
.onErrorResume(IllegalArgumentException.class, (e) -> Mono.empty()).map(URI::create);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Mono<ServerHttpRequest> removeMatchingRequest(ServerWebExchange exchange) {
|
||||
return Mono.just(exchange.getResponse()).map(ServerHttpResponse::getCookies).doOnNext(
|
||||
cookies -> cookies.add(REDIRECT_URI_COOKIE_NAME, invalidateRedirectUriCookie(exchange.getRequest())))
|
||||
(cookies) -> cookies.add(REDIRECT_URI_COOKIE_NAME, invalidateRedirectUriCookie(exchange.getRequest())))
|
||||
.thenReturn(exchange.getRequest());
|
||||
}
|
||||
|
||||
|
||||
@@ -35,8 +35,8 @@ public class ServerRequestCacheWebFilter implements WebFilter {
|
||||
|
||||
@Override
|
||||
public Mono<Void> filter(ServerWebExchange exchange, WebFilterChain chain) {
|
||||
return this.requestCache.removeMatchingRequest(exchange).map(r -> exchange.mutate().request(r).build())
|
||||
.defaultIfEmpty(exchange).flatMap(e -> chain.filter(e));
|
||||
return this.requestCache.removeMatchingRequest(exchange).map((r) -> exchange.mutate().request(r).build())
|
||||
.defaultIfEmpty(exchange).flatMap((e) -> chain.filter(e));
|
||||
}
|
||||
|
||||
public void setRequestCache(ServerRequestCache requestCache) {
|
||||
|
||||
@@ -69,7 +69,7 @@ public class WebSessionServerRequestCache implements ServerRequestCache {
|
||||
@Override
|
||||
public Mono<Void> saveRequest(ServerWebExchange exchange) {
|
||||
return this.saveRequestMatcher.matches(exchange).filter(MatchResult::isMatch)
|
||||
.flatMap(m -> exchange.getSession()).map(WebSession::getAttributes).doOnNext(attrs -> {
|
||||
.flatMap((m) -> exchange.getSession()).map(WebSession::getAttributes).doOnNext((attrs) -> {
|
||||
String requestPath = pathInApplication(exchange.getRequest());
|
||||
attrs.put(this.sessionAttrName, requestPath);
|
||||
if (logger.isDebugEnabled()) {
|
||||
@@ -81,13 +81,13 @@ public class WebSessionServerRequestCache implements ServerRequestCache {
|
||||
@Override
|
||||
public Mono<URI> getRedirectUri(ServerWebExchange exchange) {
|
||||
return exchange.getSession()
|
||||
.flatMap(session -> Mono.justOrEmpty(session.<String>getAttribute(this.sessionAttrName)))
|
||||
.flatMap((session) -> Mono.justOrEmpty(session.<String>getAttribute(this.sessionAttrName)))
|
||||
.map(URI::create);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Mono<ServerHttpRequest> removeMatchingRequest(ServerWebExchange exchange) {
|
||||
return exchange.getSession().map(WebSession::getAttributes).filter(attributes -> {
|
||||
return exchange.getSession().map(WebSession::getAttributes).filter((attributes) -> {
|
||||
String requestPath = pathInApplication(exchange.getRequest());
|
||||
boolean removed = attributes.remove(this.sessionAttrName, requestPath);
|
||||
if (removed) {
|
||||
@@ -96,7 +96,7 @@ public class WebSessionServerRequestCache implements ServerRequestCache {
|
||||
}
|
||||
}
|
||||
return removed;
|
||||
}).map(attributes -> exchange.getRequest());
|
||||
}).map((attributes) -> exchange.getRequest());
|
||||
}
|
||||
|
||||
private static String pathInApplication(ServerHttpRequest request) {
|
||||
|
||||
@@ -57,9 +57,9 @@ public final class HttpsRedirectWebFilter implements WebFilter {
|
||||
@Override
|
||||
public Mono<Void> filter(ServerWebExchange exchange, WebFilterChain chain) {
|
||||
return Mono.just(exchange).filter(this::isInsecure).flatMap(this.requiresHttpsRedirectMatcher::matches)
|
||||
.filter(matchResult -> matchResult.isMatch()).switchIfEmpty(chain.filter(exchange).then(Mono.empty()))
|
||||
.map(matchResult -> createRedirectUri(exchange))
|
||||
.flatMap(uri -> this.redirectStrategy.sendRedirect(exchange, uri));
|
||||
.filter((matchResult) -> matchResult.isMatch()).switchIfEmpty(chain.filter(exchange).then(Mono.empty()))
|
||||
.map((matchResult) -> createRedirectUri(exchange))
|
||||
.flatMap((uri) -> this.redirectStrategy.sendRedirect(exchange, uri));
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -64,7 +64,7 @@ public class LoginPageGeneratingWebFilter implements WebFilter {
|
||||
@Override
|
||||
public Mono<Void> filter(ServerWebExchange exchange, WebFilterChain chain) {
|
||||
return this.matcher.matches(exchange).filter(ServerWebExchangeMatcher.MatchResult::isMatch)
|
||||
.switchIfEmpty(chain.filter(exchange).then(Mono.empty())).flatMap(matchResult -> render(exchange));
|
||||
.switchIfEmpty(chain.filter(exchange).then(Mono.empty())).flatMap((matchResult) -> render(exchange));
|
||||
}
|
||||
|
||||
private Mono<Void> render(ServerWebExchange exchange) {
|
||||
@@ -77,7 +77,7 @@ public class LoginPageGeneratingWebFilter implements WebFilter {
|
||||
private Mono<DataBuffer> createBuffer(ServerWebExchange exchange) {
|
||||
|
||||
Mono<CsrfToken> token = exchange.getAttributeOrDefault(CsrfToken.class.getName(), Mono.empty());
|
||||
return token.map(LoginPageGeneratingWebFilter::csrfToken).defaultIfEmpty("").map(csrfTokenHtmlInput -> {
|
||||
return token.map(LoginPageGeneratingWebFilter::csrfToken).defaultIfEmpty("").map((csrfTokenHtmlInput) -> {
|
||||
byte[] bytes = createPage(exchange, csrfTokenHtmlInput);
|
||||
DataBufferFactory bufferFactory = exchange.getResponse().bufferFactory();
|
||||
return bufferFactory.wrap(bytes);
|
||||
|
||||
@@ -46,7 +46,7 @@ public class LogoutPageGeneratingWebFilter implements WebFilter {
|
||||
@Override
|
||||
public Mono<Void> filter(ServerWebExchange exchange, WebFilterChain chain) {
|
||||
return this.matcher.matches(exchange).filter(ServerWebExchangeMatcher.MatchResult::isMatch)
|
||||
.switchIfEmpty(chain.filter(exchange).then(Mono.empty())).flatMap(matchResult -> render(exchange));
|
||||
.switchIfEmpty(chain.filter(exchange).then(Mono.empty())).flatMap((matchResult) -> render(exchange));
|
||||
}
|
||||
|
||||
private Mono<Void> render(ServerWebExchange exchange) {
|
||||
@@ -54,12 +54,12 @@ public class LogoutPageGeneratingWebFilter implements WebFilter {
|
||||
result.setStatusCode(HttpStatus.OK);
|
||||
result.getHeaders().setContentType(MediaType.TEXT_HTML);
|
||||
return result.writeWith(createBuffer(exchange));
|
||||
// .doOnError( error -> DataBufferUtils.release(buffer));
|
||||
// .doOnError( (error) -> DataBufferUtils.release(buffer));
|
||||
}
|
||||
|
||||
private Mono<DataBuffer> createBuffer(ServerWebExchange exchange) {
|
||||
Mono<CsrfToken> token = exchange.getAttributeOrDefault(CsrfToken.class.getName(), Mono.empty());
|
||||
return token.map(LogoutPageGeneratingWebFilter::csrfToken).defaultIfEmpty("").map(csrfTokenHtmlInput -> {
|
||||
return token.map(LogoutPageGeneratingWebFilter::csrfToken).defaultIfEmpty("").map((csrfTokenHtmlInput) -> {
|
||||
byte[] bytes = createPage(csrfTokenHtmlInput);
|
||||
DataBufferFactory bufferFactory = exchange.getResponse().bufferFactory();
|
||||
return bufferFactory.wrap(bytes);
|
||||
|
||||
@@ -56,14 +56,14 @@ public class AndServerWebExchangeMatcher implements ServerWebExchangeMatcher {
|
||||
public Mono<MatchResult> matches(ServerWebExchange exchange) {
|
||||
return Mono.defer(() -> {
|
||||
Map<String, Object> variables = new HashMap<>();
|
||||
return Flux.fromIterable(this.matchers).doOnNext(it -> {
|
||||
return Flux.fromIterable(this.matchers).doOnNext((it) -> {
|
||||
if (logger.isDebugEnabled()) {
|
||||
logger.debug("Trying to match using " + it);
|
||||
}
|
||||
}).flatMap(matcher -> matcher.matches(exchange))
|
||||
.doOnNext(matchResult -> variables.putAll(matchResult.getVariables())).all(MatchResult::isMatch)
|
||||
.flatMap(allMatch -> allMatch ? MatchResult.match(variables) : MatchResult.notMatch())
|
||||
.doOnNext(it -> {
|
||||
}).flatMap((matcher) -> matcher.matches(exchange))
|
||||
.doOnNext((matchResult) -> variables.putAll(matchResult.getVariables())).all(MatchResult::isMatch)
|
||||
.flatMap((allMatch) -> allMatch ? MatchResult.match(variables) : MatchResult.notMatch())
|
||||
.doOnNext((it) -> {
|
||||
if (logger.isDebugEnabled()) {
|
||||
logger.debug(it.isMatch() ? "All requestMatchers returned true" : "Did not match");
|
||||
}
|
||||
|
||||
@@ -44,8 +44,8 @@ public class NegatedServerWebExchangeMatcher implements ServerWebExchangeMatcher
|
||||
|
||||
@Override
|
||||
public Mono<MatchResult> matches(ServerWebExchange exchange) {
|
||||
return this.matcher.matches(exchange).flatMap(m -> m.isMatch() ? MatchResult.notMatch() : MatchResult.match())
|
||||
.doOnNext(it -> {
|
||||
return this.matcher.matches(exchange).flatMap((m) -> m.isMatch() ? MatchResult.notMatch() : MatchResult.match())
|
||||
.doOnNext((it) -> {
|
||||
if (logger.isDebugEnabled()) {
|
||||
logger.debug("matches = " + it.isMatch());
|
||||
}
|
||||
|
||||
@@ -52,12 +52,12 @@ public class OrServerWebExchangeMatcher implements ServerWebExchangeMatcher {
|
||||
|
||||
@Override
|
||||
public Mono<MatchResult> matches(ServerWebExchange exchange) {
|
||||
return Flux.fromIterable(this.matchers).doOnNext(it -> {
|
||||
return Flux.fromIterable(this.matchers).doOnNext((it) -> {
|
||||
if (logger.isDebugEnabled()) {
|
||||
logger.debug("Trying to match using " + it);
|
||||
}
|
||||
}).flatMap(m -> m.matches(exchange)).filter(MatchResult::isMatch).next().switchIfEmpty(MatchResult.notMatch())
|
||||
.doOnNext(it -> {
|
||||
}).flatMap((m) -> m.matches(exchange)).filter(MatchResult::isMatch).next().switchIfEmpty(MatchResult.notMatch())
|
||||
.doOnNext((it) -> {
|
||||
if (logger.isDebugEnabled()) {
|
||||
logger.debug(it.isMatch() ? "matched" : "No matches found");
|
||||
}
|
||||
|
||||
@@ -73,7 +73,7 @@ public final class PathPatternParserServerWebExchangeMatcher implements ServerWe
|
||||
ServerHttpRequest request = exchange.getRequest();
|
||||
PathContainer path = request.getPath().pathWithinApplication();
|
||||
if (this.method != null && !this.method.equals(request.getMethod())) {
|
||||
return MatchResult.notMatch().doOnNext(result -> {
|
||||
return MatchResult.notMatch().doOnNext((result) -> {
|
||||
if (logger.isDebugEnabled()) {
|
||||
logger.debug("Request '" + request.getMethod() + " " + path + "' doesn't match '" + this.method
|
||||
+ " " + this.pattern.getPatternString() + "'");
|
||||
@@ -82,7 +82,7 @@ public final class PathPatternParserServerWebExchangeMatcher implements ServerWe
|
||||
}
|
||||
boolean match = this.pattern.matches(path);
|
||||
if (!match) {
|
||||
return MatchResult.notMatch().doOnNext(result -> {
|
||||
return MatchResult.notMatch().doOnNext((result) -> {
|
||||
if (logger.isDebugEnabled()) {
|
||||
logger.debug("Request '" + request.getMethod() + " " + path + "' doesn't match '" + this.method
|
||||
+ " " + this.pattern.getPatternString() + "'");
|
||||
|
||||
@@ -97,7 +97,7 @@ public class ConcurrentSessionFilter extends GenericFilterBean {
|
||||
() -> expiredUrl + " isn't a valid redirect URL");
|
||||
this.expiredUrl = expiredUrl;
|
||||
this.sessionRegistry = sessionRegistry;
|
||||
this.sessionInformationExpiredStrategy = event -> {
|
||||
this.sessionInformationExpiredStrategy = (event) -> {
|
||||
HttpServletRequest request = event.getRequest();
|
||||
HttpServletResponse response = event.getResponse();
|
||||
SessionInformation info = event.getSessionInformation();
|
||||
|
||||
@@ -41,14 +41,14 @@ public class ThrowableAnalyzer {
|
||||
*
|
||||
* @see Throwable#getCause()
|
||||
*/
|
||||
public static final ThrowableCauseExtractor DEFAULT_EXTRACTOR = throwable -> throwable.getCause();
|
||||
public static final ThrowableCauseExtractor DEFAULT_EXTRACTOR = (throwable) -> throwable.getCause();
|
||||
|
||||
/**
|
||||
* Default extractor for {@link InvocationTargetException} instances.
|
||||
*
|
||||
* @see InvocationTargetException#getTargetException()
|
||||
*/
|
||||
public static final ThrowableCauseExtractor INVOCATIONTARGET_EXTRACTOR = throwable -> {
|
||||
public static final ThrowableCauseExtractor INVOCATIONTARGET_EXTRACTOR = (throwable) -> {
|
||||
verifyThrowableHierarchy(throwable, InvocationTargetException.class);
|
||||
return ((InvocationTargetException) throwable).getTargetException();
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user