Class SecurityMockServerConfigurers.JwtMutator
java.lang.Object
org.springframework.security.test.web.reactive.server.SecurityMockServerConfigurers.JwtMutator
- All Implemented Interfaces:
org.springframework.test.web.reactive.server.MockServerConfigurer
,org.springframework.test.web.reactive.server.WebTestClientConfigurer
- Enclosing class:
- SecurityMockServerConfigurers
public static final class SecurityMockServerConfigurers.JwtMutator
extends Object
implements org.springframework.test.web.reactive.server.WebTestClientConfigurer, org.springframework.test.web.reactive.server.MockServerConfigurer
Updates the WebServerExchange using
{@link
SecurityMockServerConfigurers#mockAuthentication(Authentication)}
.- Since:
- 5.2
-
Method Summary
Modifier and TypeMethodDescriptionvoid
afterConfigureAdded
(org.springframework.test.web.reactive.server.WebTestClient.MockServerSpec<?> serverSpec) void
afterConfigurerAdded
(org.springframework.test.web.reactive.server.WebTestClient.Builder builder, org.springframework.web.server.adapter.WebHttpHandlerBuilder httpHandlerBuilder, org.springframework.http.client.reactive.ClientHttpConnector connector) authorities
(Collection<GrantedAuthority> authorities) Use the provided authorities in the tokenauthorities
(org.springframework.core.convert.converter.Converter<Jwt, Collection<GrantedAuthority>> authoritiesConverter) Provides the configuredJwt
so that custom authorities can be derived from itauthorities
(GrantedAuthority... authorities) Use the provided authorities in the tokenvoid
beforeServerCreated
(org.springframework.web.server.adapter.WebHttpHandlerBuilder builder) jwt
(Consumer<Jwt.Builder> jwtBuilderConsumer) Use the givenJwt.Builder
Consumer
to configure the underlyingJwt
This method first creates a defaultJwt.Builder
instance with default values for thealg
,sub
, andscope
claims.Use the givenJwt
-
Method Details
-
jwt
Use the givenJwt.Builder
Consumer
to configure the underlyingJwt
This method first creates a defaultJwt.Builder
instance with default values for thealg
,sub
, andscope
claims. TheConsumer
can then modify these or provide additional configuration. CallingSecurityMockServerConfigurers.mockJwt()
is the equivalent of callingSecurityMockMvcRequestPostProcessors.mockJwt().jwt(() -> {})
.- Parameters:
jwtBuilderConsumer
- For configuring the underlyingJwt
- Returns:
- the
SecurityMockServerConfigurers.JwtMutator
for further configuration
-
jwt
Use the givenJwt
- Parameters:
jwt
- TheJwt
to use- Returns:
- the
SecurityMockServerConfigurers.JwtMutator
for further configuration
-
authorities
public SecurityMockServerConfigurers.JwtMutator authorities(Collection<GrantedAuthority> authorities) Use the provided authorities in the token- Parameters:
authorities
- the authorities to use- Returns:
- the
SecurityMockServerConfigurers.JwtMutator
for further configuration
-
authorities
Use the provided authorities in the token- Parameters:
authorities
- the authorities to use- Returns:
- the
SecurityMockServerConfigurers.JwtMutator
for further configuration
-
authorities
public SecurityMockServerConfigurers.JwtMutator authorities(org.springframework.core.convert.converter.Converter<Jwt, Collection<GrantedAuthority>> authoritiesConverter) Provides the configuredJwt
so that custom authorities can be derived from it- Parameters:
authoritiesConverter
- the conversion strategy fromJwt
to aCollection
ofGrantedAuthority
s- Returns:
- the
SecurityMockServerConfigurers.JwtMutator
for further configuration
-
beforeServerCreated
public void beforeServerCreated(org.springframework.web.server.adapter.WebHttpHandlerBuilder builder) - Specified by:
beforeServerCreated
in interfaceorg.springframework.test.web.reactive.server.MockServerConfigurer
-
afterConfigureAdded
public void afterConfigureAdded(org.springframework.test.web.reactive.server.WebTestClient.MockServerSpec<?> serverSpec) - Specified by:
afterConfigureAdded
in interfaceorg.springframework.test.web.reactive.server.MockServerConfigurer
-
afterConfigurerAdded
public void afterConfigurerAdded(org.springframework.test.web.reactive.server.WebTestClient.Builder builder, @Nullable org.springframework.web.server.adapter.WebHttpHandlerBuilder httpHandlerBuilder, @Nullable org.springframework.http.client.reactive.ClientHttpConnector connector) - Specified by:
afterConfigurerAdded
in interfaceorg.springframework.test.web.reactive.server.WebTestClientConfigurer
-