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 java.lang.Object implements org.springframework.test.web.reactive.server.WebTestClientConfigurer, org.springframework.test.web.reactive.server.MockServerConfigurerUpdates the WebServerExchange using{@link SecurityMockServerConfigurers#mockAuthentication(Authentication)}.- Since:
- 5.2
-
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidafterConfigureAdded(org.springframework.test.web.reactive.server.WebTestClient.MockServerSpec<?> serverSpec)voidafterConfigurerAdded(org.springframework.test.web.reactive.server.WebTestClient.Builder builder, org.springframework.web.server.adapter.WebHttpHandlerBuilder httpHandlerBuilder, org.springframework.http.client.reactive.ClientHttpConnector connector)SecurityMockServerConfigurers.JwtMutatorauthorities(java.util.Collection<org.springframework.security.core.GrantedAuthority> authorities)Use the provided authorities in the tokenSecurityMockServerConfigurers.JwtMutatorauthorities(org.springframework.core.convert.converter.Converter<org.springframework.security.oauth2.jwt.Jwt,java.util.Collection<org.springframework.security.core.GrantedAuthority>> authoritiesConverter)Provides the configuredJwtso that custom authorities can be derived from itSecurityMockServerConfigurers.JwtMutatorauthorities(org.springframework.security.core.GrantedAuthority... authorities)Use the provided authorities in the tokenvoidbeforeServerCreated(org.springframework.web.server.adapter.WebHttpHandlerBuilder builder)SecurityMockServerConfigurers.JwtMutatorjwt(java.util.function.Consumer<org.springframework.security.oauth2.jwt.Jwt.Builder> jwtBuilderConsumer)Use the givenJwt.BuilderConsumerto configure the underlyingJwtThis method first creates a defaultJwt.Builderinstance with default values for thealg,sub, andscopeclaims.SecurityMockServerConfigurers.JwtMutatorjwt(org.springframework.security.oauth2.jwt.Jwt jwt)Use the givenJwt
-
-
-
Method Detail
-
jwt
public SecurityMockServerConfigurers.JwtMutator jwt(java.util.function.Consumer<org.springframework.security.oauth2.jwt.Jwt.Builder> jwtBuilderConsumer)
Use the givenJwt.BuilderConsumerto configure the underlyingJwtThis method first creates a defaultJwt.Builderinstance with default values for thealg,sub, andscopeclaims. TheConsumercan 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.JwtMutatorfor further configuration
-
jwt
public SecurityMockServerConfigurers.JwtMutator jwt(org.springframework.security.oauth2.jwt.Jwt jwt)
Use the givenJwt- Parameters:
jwt- TheJwtto use- Returns:
- the
SecurityMockServerConfigurers.JwtMutatorfor further configuration
-
authorities
public SecurityMockServerConfigurers.JwtMutator authorities(java.util.Collection<org.springframework.security.core.GrantedAuthority> authorities)
Use the provided authorities in the token- Parameters:
authorities- the authorities to use- Returns:
- the
SecurityMockServerConfigurers.JwtMutatorfor further configuration
-
authorities
public SecurityMockServerConfigurers.JwtMutator authorities(org.springframework.security.core.GrantedAuthority... authorities)
Use the provided authorities in the token- Parameters:
authorities- the authorities to use- Returns:
- the
SecurityMockServerConfigurers.JwtMutatorfor further configuration
-
authorities
public SecurityMockServerConfigurers.JwtMutator authorities(org.springframework.core.convert.converter.Converter<org.springframework.security.oauth2.jwt.Jwt,java.util.Collection<org.springframework.security.core.GrantedAuthority>> authoritiesConverter)
Provides the configuredJwtso that custom authorities can be derived from it- Parameters:
authoritiesConverter- the conversion strategy fromJwtto aCollectionofGrantedAuthoritys- Returns:
- the
SecurityMockServerConfigurers.JwtMutatorfor further configuration
-
beforeServerCreated
public void beforeServerCreated(org.springframework.web.server.adapter.WebHttpHandlerBuilder builder)
- Specified by:
beforeServerCreatedin interfaceorg.springframework.test.web.reactive.server.MockServerConfigurer
-
afterConfigureAdded
public void afterConfigureAdded(org.springframework.test.web.reactive.server.WebTestClient.MockServerSpec<?> serverSpec)
- Specified by:
afterConfigureAddedin 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:
afterConfigurerAddedin interfaceorg.springframework.test.web.reactive.server.WebTestClientConfigurer
-
-