1
0
mirror of synced 2026-08-04 17:27:13 +00:00

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:
Phillip Webb
2020-07-29 18:18:05 -07:00
committed by Rob Winch
parent 01d90c9881
commit 52f20b5281
426 changed files with 1668 additions and 1617 deletions
@@ -53,7 +53,7 @@ public class HelloRSocketApplicationITests {
public void messageWhenAuthenticatedThenSuccess() {
UsernamePasswordMetadata credentials = new UsernamePasswordMetadata("user", "password");
RSocketRequester requester = this.requester
.rsocketStrategies(builder -> builder.encoder(new BasicAuthenticationEncoder()))
.rsocketStrategies((builder) -> builder.encoder(new BasicAuthenticationEncoder()))
.setupMetadata(credentials, BASIC_AUTHENTICATION_MIME_TYPE)
.connectTcp("localhost", this.port)
.block();
@@ -70,11 +70,11 @@ public class HelloWebfluxMethodApplicationITests {
}
private Consumer<HttpHeaders> robsCredentials() {
return httpHeaders -> httpHeaders.setBasicAuth("rob", "rob");
return (httpHeaders) -> httpHeaders.setBasicAuth("rob", "rob");
}
private Consumer<HttpHeaders> adminCredentials() {
return httpHeaders -> httpHeaders.setBasicAuth("admin", "admin");
return (httpHeaders) -> httpHeaders.setBasicAuth("admin", "admin");
}
}
@@ -40,7 +40,7 @@ public class SecurityConfig {
return http
// Demonstrate that method security works
// Best practice to use both for defense in depth
.authorizeExchange(exchanges -> exchanges
.authorizeExchange((exchanges) -> exchanges
.anyExchange().permitAll()
)
.httpBasic(withDefaults())
@@ -123,10 +123,10 @@ public class HelloWebfluxMethodApplicationTests {
}
private Consumer<HttpHeaders> robsCredentials() {
return httpHeaders -> httpHeaders.setBasicAuth("rob", "rob");
return (httpHeaders) -> httpHeaders.setBasicAuth("rob", "rob");
}
private Consumer<HttpHeaders> adminCredentials() {
return httpHeaders -> httpHeaders.setBasicAuth("admin", "admin");
return (httpHeaders) -> httpHeaders.setBasicAuth("admin", "admin");
}
}
@@ -69,10 +69,10 @@ public class HelloWebfluxApplicationITests {
}
private Consumer<HttpHeaders> userCredentials() {
return httpHeaders -> httpHeaders.setBasicAuth("user", "user");
return (httpHeaders) -> httpHeaders.setBasicAuth("user", "user");
}
private Consumer<HttpHeaders> invalidCredentials() {
return httpHeaders -> httpHeaders.setBasicAuth("user", "INVALID");
return (httpHeaders) -> httpHeaders.setBasicAuth("user", "INVALID");
}
}
@@ -105,10 +105,10 @@ public class HelloWebfluxApplicationTests {
}
private Consumer<HttpHeaders> userCredentials() {
return httpHeaders -> httpHeaders.setBasicAuth("user", "user");
return (httpHeaders) -> httpHeaders.setBasicAuth("user", "user");
}
private Consumer<HttpHeaders> invalidCredentials() {
return httpHeaders -> httpHeaders.setBasicAuth("user", "INVALID");
return (httpHeaders) -> httpHeaders.setBasicAuth("user", "INVALID");
}
}
@@ -75,10 +75,10 @@ public class HelloWebfluxFnApplicationITests {
}
private Consumer<HttpHeaders> userCredentials() {
return httpHeaders -> httpHeaders.setBasicAuth("user", "user");
return (httpHeaders) -> httpHeaders.setBasicAuth("user", "user");
}
private Consumer<HttpHeaders> invalidCredentials() {
return httpHeaders -> httpHeaders.setBasicAuth("user", "INVALID");
return (httpHeaders) -> httpHeaders.setBasicAuth("user", "INVALID");
}
}
@@ -36,7 +36,7 @@ public class HelloUserController {
public Mono<ServerResponse> hello(ServerRequest serverRequest) {
return serverRequest.principal()
.map(Principal::getName)
.flatMap(username ->
.flatMap((username) ->
ServerResponse.ok()
.contentType(MediaType.APPLICATION_JSON)
.syncBody(Collections.singletonMap("message", "Hello " + username + "!"))
@@ -106,10 +106,10 @@ public class HelloWebfluxFnApplicationTests {
}
private Consumer<HttpHeaders> userCredentials() {
return httpHeaders -> httpHeaders.setBasicAuth("user", "user");
return (httpHeaders) -> httpHeaders.setBasicAuth("user", "user");
}
private Consumer<HttpHeaders> invalidCredentials() {
return httpHeaders -> httpHeaders.setBasicAuth("user", "INVALID");
return (httpHeaders) -> httpHeaders.setBasicAuth("user", "INVALID");
}
}
@@ -35,11 +35,11 @@ public class SecurityConfig extends WebSecurityConfigurerAdapter {
@Override
protected void configure(HttpSecurity http) throws Exception {
http
.authorizeRequests(authorize -> authorize
.authorizeRequests((authorize) -> authorize
.antMatchers("/css/**", "/index").permitAll()
.antMatchers("/user/**").hasRole("USER")
)
.formLogin(formLogin -> formLogin
.formLogin((formLogin) -> formLogin
.loginPage("/login")
.failureUrl("/login-error")
);
@@ -167,7 +167,7 @@ class UserConfig extends WebSecurityConfigurerAdapter {
.and()
.httpBasic()
.and()
.csrf().ignoringRequestMatchers(request -> "/introspect".equals(request.getRequestURI()));
.csrf().ignoringRequestMatchers((request) -> "/introspect".equals(request.getRequestURI()));
}
@Bean
@@ -46,7 +46,7 @@ public class OAuth2LoginApplicationTests {
@Test
public void requestWhenMockOidcLoginThenIndex() {
this.clientRegistrationRepository.findByRegistrationId("github")
.map(clientRegistration ->
.map((clientRegistration) ->
this.test.mutateWith(mockOAuth2Login().clientRegistration(clientRegistration))
.get().uri("/")
.exchange()
@@ -65,12 +65,12 @@ public class OAuth2LoginControllerTests {
.bindToController(this.controller)
.apply(springSecurity())
.webFilter(new SecurityContextServerWebExchangeWebFilter())
.argumentResolvers(c -> {
.argumentResolvers((c) -> {
c.addCustomResolver(new AuthenticationPrincipalArgumentResolver(new ReactiveAdapterRegistry()));
c.addCustomResolver(new OAuth2AuthorizedClientArgumentResolver
(this.clientRegistrationRepository, this.authorizedClientRepository));
})
.viewResolvers(c -> c.viewResolver(this.viewResolver))
.viewResolvers((c) -> c.viewResolver(this.viewResolver))
.build();
}
@@ -308,7 +308,7 @@ public class OAuth2LoginApplicationTests {
private HtmlAnchor getClientAnchorElement(HtmlPage page, ClientRegistration clientRegistration) {
Optional<HtmlAnchor> clientAnchorElement = page.getAnchors().stream()
.filter(e -> e.asText().equals(clientRegistration.getClientName())).findFirst();
.filter((e) -> e.asText().equals(clientRegistration.getClientName())).findFirst();
return (clientAnchorElement.orElse(null));
}
@@ -335,17 +335,17 @@ public class OAuth2LoginApplicationTests {
@Override
protected void configure(HttpSecurity http) throws Exception {
http
.authorizeRequests(authorizeRequests ->
.authorizeRequests((authorizeRequests) ->
authorizeRequests
.anyRequest().authenticated()
)
.oauth2Login(oauth2Login ->
.oauth2Login((oauth2Login) ->
oauth2Login
.tokenEndpoint(tokenEndpoint ->
.tokenEndpoint((tokenEndpoint) ->
tokenEndpoint
.accessTokenResponseClient(this.mockAccessTokenResponseClient())
)
.userInfoEndpoint(userInfoEndpoint ->
.userInfoEndpoint((userInfoEndpoint) ->
userInfoEndpoint
.userService(this.mockUserService())
)
@@ -63,7 +63,7 @@ public class OAuth2LoginControllerTests {
this.mvc.perform(get("/").with(oauth2Login()
.clientRegistration(clientRegistration)
.attributes(a -> a.put("sub", "spring-security"))))
.attributes((a) -> a.put("sub", "spring-security"))))
.andExpect(model().attribute("userName", "spring-security"))
.andExpect(model().attribute("clientName", "my-client-name"))
.andExpect(model().attribute("userAttributes", Collections.singletonMap("sub", "spring-security")));
@@ -69,12 +69,12 @@ public class OAuth2ResourceServerSecurityConfiguration extends WebSecurityConfig
protected void configure(HttpSecurity http) throws Exception {
// @formatter:off
http
.authorizeRequests(authorizeRequests ->
.authorizeRequests((authorizeRequests) ->
authorizeRequests
.antMatchers("/message/**").hasAuthority("SCOPE_message:read")
.anyRequest().authenticated()
)
.oauth2ResourceServer(oauth2ResourceServer ->
.oauth2ResourceServer((oauth2ResourceServer) ->
oauth2ResourceServer
.jwt(withDefaults())
);
@@ -156,10 +156,10 @@ public class MockWebServerPropertySource extends PropertySource<MockWebServer> i
if ("/introspect".equals(request.getPath())) {
return Optional.ofNullable(request.getHeader(HttpHeaders.AUTHORIZATION))
.filter(authorization -> isAuthorized(authorization, "client", "secret"))
.map(authorization -> parseBody(request.getBody()))
.map(parameters -> parameters.get("token"))
.map(token -> {
.filter((authorization) -> isAuthorized(authorization, "client", "secret"))
.map((authorization) -> parseBody(request.getBody()))
.map((parameters) -> parameters.get("token"))
.map((token) -> {
if ("00ed5855-1869-47a0-b0c9-0f3ce520aee7".equals(token)) {
return NO_SCOPES_RESPONSE;
} else if ("b43d1500-c405-4dc9-b9c9-6cfd966c34c9".equals(token)) {
@@ -181,8 +181,8 @@ public class MockWebServerPropertySource extends PropertySource<MockWebServer> i
private Map<String, Object> parseBody(Buffer body) {
return Stream.of(body.readUtf8().split("&"))
.map(parameter -> parameter.split("="))
.collect(Collectors.toMap(parts -> parts[0], parts -> parts[1]));
.map((parameter) -> parameter.split("="))
.collect(Collectors.toMap((parts) -> parts[0], (parts) -> parts[1]));
}
private static MockResponse response(String body, int status) {
@@ -37,11 +37,11 @@ public class OAuth2ResourceServerSecurityConfiguration extends WebSecurityConfig
protected void configure(HttpSecurity http) throws Exception {
// @formatter:off
http
.authorizeRequests(authz -> authz
.authorizeRequests((authz) -> authz
.antMatchers("/message/**").hasAuthority("SCOPE_message:read")
.anyRequest().authenticated()
)
.oauth2ResourceServer(oauth2 -> oauth2
.oauth2ResourceServer((oauth2) -> oauth2
.authenticationManagerResolver(this.authenticationManagerResolver)
);
// @formatter:on
@@ -142,10 +142,10 @@ public class MockWebServerPropertySource extends PropertySource<MockWebServer> i
private MockResponse doDispatch(RecordedRequest request) {
if ("/introspect".equals(request.getPath())) {
return Optional.ofNullable(request.getHeader(HttpHeaders.AUTHORIZATION))
.filter(authorization -> isAuthorized(authorization, "client", "secret"))
.map(authorization -> parseBody(request.getBody()))
.map(parameters -> parameters.get("token"))
.map(token -> {
.filter((authorization) -> isAuthorized(authorization, "client", "secret"))
.map((authorization) -> parseBody(request.getBody()))
.map((parameters) -> parameters.get("token"))
.map((token) -> {
if ("00ed5855-1869-47a0-b0c9-0f3ce520aee7".equals(token)) {
return NO_SCOPES_RESPONSE;
} else if ("b43d1500-c405-4dc9-b9c9-6cfd966c34c9".equals(token)) {
@@ -167,8 +167,8 @@ public class MockWebServerPropertySource extends PropertySource<MockWebServer> i
private Map<String, Object> parseBody(Buffer body) {
return Stream.of(body.readUtf8().split("&"))
.map(parameter -> parameter.split("="))
.collect(Collectors.toMap(parts -> parts[0], parts -> parts[1]));
.map((parameter) -> parameter.split("="))
.collect(Collectors.toMap((parts) -> parts[0], (parts) -> parts[1]));
}
private static MockResponse response(String body, int status) {
@@ -36,15 +36,15 @@ public class OAuth2ResourceServerSecurityConfiguration extends WebSecurityConfig
protected void configure(HttpSecurity http) throws Exception {
// @formatter:off
http
.authorizeRequests(authorizeRequests ->
.authorizeRequests((authorizeRequests) ->
authorizeRequests
.antMatchers(HttpMethod.GET, "/message/**").hasAuthority("SCOPE_message:read")
.antMatchers(HttpMethod.POST, "/message/**").hasAuthority("SCOPE_message:write")
.anyRequest().authenticated()
)
.oauth2ResourceServer(oauth2ResourceServer ->
.oauth2ResourceServer((oauth2ResourceServer) ->
oauth2ResourceServer
.opaqueToken(opaqueToken ->
.opaqueToken((opaqueToken) ->
opaqueToken
.introspectionUri(this.introspectionUri)
.introspectionClientCredentials(this.clientId, this.clientSecret)
@@ -46,13 +46,13 @@ public class OAuth2ResourceServerControllerTests {
@Test
public void indexGreetsAuthenticatedUser() throws Exception {
this.mvc.perform(get("/").with(opaqueToken().attributes(a -> a.put("sub", "ch4mpy"))))
this.mvc.perform(get("/").with(opaqueToken().attributes((a) -> a.put("sub", "ch4mpy"))))
.andExpect(content().string(is("Hello, ch4mpy!")));
}
@Test
public void messageCanBeReadWithScopeMessageReadAuthority() throws Exception {
this.mvc.perform(get("/message").with(opaqueToken().attributes(a -> a.put("scope", "message:read"))))
this.mvc.perform(get("/message").with(opaqueToken().attributes((a) -> a.put("scope", "message:read"))))
.andExpect(content().string(is("secret message")));
this.mvc.perform(get("/message")
@@ -39,14 +39,14 @@ public class OAuth2ResourceServerSecurityConfiguration extends WebSecurityConfig
protected void configure(HttpSecurity http) throws Exception {
// @formatter:off
http
.authorizeRequests(authorizeRequests ->
.authorizeRequests((authorizeRequests) ->
authorizeRequests
.antMatchers("/message/**").hasAuthority("SCOPE_message:read")
.anyRequest().authenticated()
)
.oauth2ResourceServer(oauth2ResourceServer ->
.oauth2ResourceServer((oauth2ResourceServer) ->
oauth2ResourceServer
.jwt(jwt ->
.jwt((jwt) ->
jwt.decoder(jwtDecoder())
)
);
@@ -38,8 +38,8 @@ import static org.hamcrest.Matchers.containsString;
@RunWith(SpringJUnit4ClassRunner.class)
public class ServerOAuth2ResourceServerApplicationITests {
Consumer<HttpHeaders> noScopesToken = http -> http.setBearerAuth("eyJhbGciOiJSUzI1NiJ9.eyJzdWIiOiJzdWJqZWN0IiwiZXhwIjo0NjgzODA1MTI4fQ.ULEPdHG-MK5GlrTQMhgqcyug2brTIZaJIrahUeq9zaiwUSdW83fJ7W1IDd2Z3n4a25JY2uhEcoV95lMfccHR6y_2DLrNvfta22SumY9PEDF2pido54LXG6edIGgarnUbJdR4rpRe_5oRGVa8gDx8FnuZsNv6StSZHAzw5OsuevSTJ1UbJm4UfX3wiahFOQ2OI6G-r5TB2rQNdiPHuNyzG5yznUqRIZ7-GCoMqHMaC-1epKxiX8gYXRROuUYTtcMNa86wh7OVDmvwVmFioRcR58UWBRoO1XQexTtOQq_t8KYsrPZhb9gkyW8x2bAQF-d0J0EJY8JslaH6n4RBaZISww");
Consumer<HttpHeaders> messageReadToken = http -> http.setBearerAuth("eyJhbGciOiJSUzI1NiJ9.eyJzdWIiOiJzdWJqZWN0Iiwic2NvcGUiOiJtZXNzYWdlOnJlYWQiLCJleHAiOjQ2ODM4MDUxNDF9.h-j6FKRFdnTdmAueTZCdep45e6DPwqM68ZQ8doIJ1exi9YxAlbWzOwId6Bd0L5YmCmp63gGQgsBUBLzwnZQ8kLUgUOBEC3UzSWGRqMskCY9_k9pX0iomX6IfF3N0PaYs0WPC4hO1s8wfZQ-6hKQ4KigFi13G9LMLdH58PRMK0pKEvs3gCbHJuEPw-K5ORlpdnleUTQIwINafU57cmK3KocTeknPAM_L716sCuSYGvDl6xUTXO7oPdrXhS_EhxLP6KxrpI1uD4Ea_5OWTh7S0Wx5LLDfU6wBG1DowN20d374zepOIEkR-Jnmr_QlR44vmRqS5ncrF-1R0EGcPX49U6A");
Consumer<HttpHeaders> noScopesToken = (http) -> http.setBearerAuth("eyJhbGciOiJSUzI1NiJ9.eyJzdWIiOiJzdWJqZWN0IiwiZXhwIjo0NjgzODA1MTI4fQ.ULEPdHG-MK5GlrTQMhgqcyug2brTIZaJIrahUeq9zaiwUSdW83fJ7W1IDd2Z3n4a25JY2uhEcoV95lMfccHR6y_2DLrNvfta22SumY9PEDF2pido54LXG6edIGgarnUbJdR4rpRe_5oRGVa8gDx8FnuZsNv6StSZHAzw5OsuevSTJ1UbJm4UfX3wiahFOQ2OI6G-r5TB2rQNdiPHuNyzG5yznUqRIZ7-GCoMqHMaC-1epKxiX8gYXRROuUYTtcMNa86wh7OVDmvwVmFioRcR58UWBRoO1XQexTtOQq_t8KYsrPZhb9gkyW8x2bAQF-d0J0EJY8JslaH6n4RBaZISww");
Consumer<HttpHeaders> messageReadToken = (http) -> http.setBearerAuth("eyJhbGciOiJSUzI1NiJ9.eyJzdWIiOiJzdWJqZWN0Iiwic2NvcGUiOiJtZXNzYWdlOnJlYWQiLCJleHAiOjQ2ODM4MDUxNDF9.h-j6FKRFdnTdmAueTZCdep45e6DPwqM68ZQ8doIJ1exi9YxAlbWzOwId6Bd0L5YmCmp63gGQgsBUBLzwnZQ8kLUgUOBEC3UzSWGRqMskCY9_k9pX0iomX6IfF3N0PaYs0WPC4hO1s8wfZQ-6hKQ4KigFi13G9LMLdH58PRMK0pKEvs3gCbHJuEPw-K5ORlpdnleUTQIwINafU57cmK3KocTeknPAM_L716sCuSYGvDl6xUTXO7oPdrXhS_EhxLP6KxrpI1uD4Ea_5OWTh7S0Wx5LLDfU6wBG1DowN20d374zepOIEkR-Jnmr_QlR44vmRqS5ncrF-1R0EGcPX49U6A");
@Autowired
private WebTestClient rest;
@@ -34,13 +34,13 @@ public class SecurityConfig {
@Bean
SecurityWebFilterChain springSecurityFilterChain(ServerHttpSecurity http) {
http
.authorizeExchange(exchanges ->
.authorizeExchange((exchanges) ->
exchanges
.pathMatchers(HttpMethod.GET, "/message/**").hasAuthority("SCOPE_message:read")
.pathMatchers(HttpMethod.POST, "/message/**").hasAuthority("SCOPE_message:write")
.anyExchange().authenticated()
)
.oauth2ResourceServer(oauth2ResourceServer ->
.oauth2ResourceServer((oauth2ResourceServer) ->
oauth2ResourceServer
.jwt(withDefaults())
);
@@ -50,14 +50,14 @@ public class OAuth2ResourceServerControllerTests {
@Test
public void indexGreetsAuthenticatedUser() {
this.rest.mutateWith(mockJwt().jwt(jwt -> jwt.subject("test-subject")))
this.rest.mutateWith(mockJwt().jwt((jwt) -> jwt.subject("test-subject")))
.get().uri("/").exchange()
.expectBody(String.class).isEqualTo("Hello, test-subject!");
}
@Test
public void messageCanBeReadWithScopeMessageReadAuthority() {
this.rest.mutateWith(mockJwt().jwt(jwt -> jwt.claim("scope", "message:read")))
this.rest.mutateWith(mockJwt().jwt((jwt) -> jwt.claim("scope", "message:read")))
.get().uri("/message").exchange()
.expectBody(String.class).isEqualTo("secret message");
@@ -78,7 +78,7 @@ public class OAuth2ResourceServerControllerTests {
Jwt jwt = jwt().claim("scope", "").build();
when(this.jwtDecoder.decode(anyString())).thenReturn(Mono.just(jwt));
this.rest.post().uri("/message")
.headers(headers -> headers.setBearerAuth(jwt.getTokenValue()))
.headers((headers) -> headers.setBearerAuth(jwt.getTokenValue()))
.syncBody("Hello message").exchange()
.expectStatus().isForbidden();
}
@@ -88,7 +88,7 @@ public class OAuth2ResourceServerControllerTests {
Jwt jwt = jwt().claim("scope", "message:read").build();
when(this.jwtDecoder.decode(anyString())).thenReturn(Mono.just(jwt));
this.rest.post().uri("/message")
.headers(headers -> headers.setBearerAuth(jwt.getTokenValue()))
.headers((headers) -> headers.setBearerAuth(jwt.getTokenValue()))
.syncBody("Hello message").exchange()
.expectStatus().isForbidden();
}
@@ -98,7 +98,7 @@ public class OAuth2ResourceServerControllerTests {
Jwt jwt = jwt().claim("scope", "message:write").build();
when(this.jwtDecoder.decode(anyString())).thenReturn(Mono.just(jwt));
this.rest.post().uri("/message")
.headers(headers -> headers.setBearerAuth(jwt.getTokenValue()))
.headers((headers) -> headers.setBearerAuth(jwt.getTokenValue()))
.syncBody("Hello message").exchange()
.expectStatus().isOk()
.expectBody(String.class).isEqualTo("Message was created. Content: Hello message");
@@ -38,7 +38,7 @@ public class OAuth2ResourceServerSecurityConfiguration extends WebSecurityConfig
protected void configure(HttpSecurity http) throws Exception {
// @formatter:off
http
.authorizeRequests(authorizeRequests ->
.authorizeRequests((authorizeRequests) ->
authorizeRequests
.antMatchers(HttpMethod.GET, "/message/**").hasAuthority("SCOPE_message:read")
.antMatchers(HttpMethod.POST, "/message/**").hasAuthority("SCOPE_message:write")
@@ -48,13 +48,13 @@ public class OAuth2ResourceServerControllerTests {
@Test
public void indexGreetsAuthenticatedUser() throws Exception {
mockMvc.perform(get("/").with(jwt().jwt(jwt -> jwt.subject("ch4mpy"))))
mockMvc.perform(get("/").with(jwt().jwt((jwt) -> jwt.subject("ch4mpy"))))
.andExpect(content().string(is("Hello, ch4mpy!")));
}
@Test
public void messageCanBeReadWithScopeMessageReadAuthority() throws Exception {
mockMvc.perform(get("/message").with(jwt().jwt(jwt -> jwt.claim("scope", "message:read"))))
mockMvc.perform(get("/message").with(jwt().jwt((jwt) -> jwt.claim("scope", "message:read"))))
.andExpect(content().string(is("secret message")));
mockMvc.perform(get("/message")
@@ -80,7 +80,7 @@ public class OAuth2ResourceServerControllerTests {
public void messageCanNotBeCreatedWithScopeMessageReadAuthority() throws Exception {
mockMvc.perform(post("/message")
.content("Hello message")
.with(jwt().jwt(jwt -> jwt.claim("scope", "message:read"))))
.with(jwt().jwt((jwt) -> jwt.claim("scope", "message:read"))))
.andExpect(status().isForbidden());
}
@@ -89,7 +89,7 @@ public class OAuth2ResourceServerControllerTests {
throws Exception {
mockMvc.perform(post("/message")
.content("Hello message")
.with(jwt().jwt(jwt -> jwt.claim("scope", "message:write"))))
.with(jwt().jwt((jwt) -> jwt.claim("scope", "message:write"))))
.andExpect(status().isOk())
.andExpect(content().string(is("Message was created. Content: Hello message")));
}
@@ -35,7 +35,7 @@ public class SecurityConfig {
@Bean
SecurityWebFilterChain configure(ServerHttpSecurity http) {
http
.authorizeExchange(exchanges ->
.authorizeExchange((exchanges) ->
exchanges
.pathMatchers("/", "/public/**").permitAll()
.anyExchange().authenticated()
@@ -36,7 +36,7 @@ public class SecurityConfig extends WebSecurityConfigurerAdapter {
@Override
protected void configure(HttpSecurity http) throws Exception {
http
.authorizeRequests(authorizeRequests ->
.authorizeRequests((authorizeRequests) ->
authorizeRequests
.mvcMatchers("/", "/public/**").permitAll()
.anyRequest().authenticated()
@@ -483,7 +483,7 @@ public class Saml2LoginIntegrationTests {
String code,
Matcher<String> message
) {
return result -> {
return (result) -> {
final HttpSession session = result.getRequest().getSession(false);
AssertionErrors.assertNotNull("HttpSession", session);
Object exception = session.getAttribute(AUTHENTICATION_EXCEPTION);
@@ -46,13 +46,13 @@ public class WebfluxFormSecurityConfig {
@Bean
SecurityWebFilterChain springSecurityFilterChain(ServerHttpSecurity http) {
http
.authorizeExchange(exchanges ->
.authorizeExchange((exchanges) ->
exchanges
.pathMatchers("/login").permitAll()
.anyExchange().authenticated()
)
.httpBasic(withDefaults())
.formLogin(formLogin ->
.formLogin((formLogin) ->
formLogin
.loginPage("/login")
);
@@ -35,6 +35,6 @@ public class MeController {
public Mono<String> me() {
return ReactiveSecurityContextHolder.getContext()
.map(SecurityContext::getAuthentication)
.map(authentication -> "Hello, " + authentication.getName());
.map((authentication) -> "Hello, " + authentication.getName());
}
}
@@ -46,7 +46,7 @@ public class WebfluxX509Application {
// @formatter:off
http
.x509(withDefaults())
.authorizeExchange(exchanges ->
.authorizeExchange((exchanges) ->
exchanges
.anyExchange().authenticated()
);
@@ -55,7 +55,7 @@ public class WebfluxX509ApplicationTest {
.exchange()
.expectStatus().isOk()
.expectBody()
.consumeWith(result -> {
.consumeWith((result) -> {
String responseBody = new String(result.getResponseBody());
assertThat(responseBody).contains("Hello, client");
});
@@ -79,7 +79,7 @@ public class WebfluxX509ApplicationTest {
.trustManager(devCA)
.keyManager(clientKey, clientCrt);
HttpClient httpClient = HttpClient.create().secure(sslContextSpec -> sslContextSpec.sslContext(sslContextBuilder));
HttpClient httpClient = HttpClient.create().secure((sslContextSpec) -> sslContextSpec.sslContext(sslContextBuilder));
ClientHttpConnector httpConnector = new ReactorClientHttpConnector(httpClient);
return WebTestClient