Class SecurityMockMvcRequestPostProcessors.JwtRequestPostProcessor
java.lang.Object
org.springframework.security.test.web.servlet.request.SecurityMockMvcRequestPostProcessors.JwtRequestPostProcessor
- All Implemented Interfaces:
org.springframework.test.web.servlet.request.RequestPostProcessor
- Enclosing class:
- SecurityMockMvcRequestPostProcessors
public static final class SecurityMockMvcRequestPostProcessors.JwtRequestPostProcessor
extends Object
implements org.springframework.test.web.servlet.request.RequestPostProcessor
- Since:
- 5.2
-
Method Summary
Modifier and TypeMethodDescriptionauthorities(Collection<GrantedAuthority> authorities) Use the provided authorities in the tokenauthorities(org.springframework.core.convert.converter.Converter<Jwt, Collection<GrantedAuthority>> authoritiesConverter) Provides the configuredJwtso that custom authorities can be derived from itauthorities(GrantedAuthority... authorities) Use the provided authorities in the tokenjwt(Consumer<Jwt.Builder> jwtBuilderConsumer) Use the givenJwt.BuilderConsumerto configure the underlyingJwtThis method first creates a defaultJwt.Builderinstance with default values for thealg,sub, andscopeclaims.Use the givenJwtorg.springframework.mock.web.MockHttpServletRequestpostProcessRequest(org.springframework.mock.web.MockHttpServletRequest request)
-
Method Details
-
jwt
public SecurityMockMvcRequestPostProcessors.JwtRequestPostProcessor jwt(Consumer<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. CallingSecurityMockMvcRequestPostProcessors.jwt()is the equivalent of callingSecurityMockMvcRequestPostProcessors.jwt().jwt(() -> {}).- Parameters:
jwtBuilderConsumer- For configuring the underlyingJwt- Returns:
- the
SecurityMockMvcRequestPostProcessors.JwtRequestPostProcessorfor additional customization
-
jwt
Use the givenJwt- Parameters:
jwt- TheJwtto use- Returns:
- the
SecurityMockMvcRequestPostProcessors.JwtRequestPostProcessorfor additional customization
-
authorities
public SecurityMockMvcRequestPostProcessors.JwtRequestPostProcessor authorities(Collection<GrantedAuthority> authorities) Use the provided authorities in the token- Parameters:
authorities- the authorities to use- Returns:
- the
SecurityMockMvcRequestPostProcessors.JwtRequestPostProcessorfor further configuration
-
authorities
public SecurityMockMvcRequestPostProcessors.JwtRequestPostProcessor authorities(GrantedAuthority... authorities) Use the provided authorities in the token- Parameters:
authorities- the authorities to use- Returns:
- the
SecurityMockMvcRequestPostProcessors.JwtRequestPostProcessorfor further configuration
-
authorities
public SecurityMockMvcRequestPostProcessors.JwtRequestPostProcessor authorities(org.springframework.core.convert.converter.Converter<Jwt, Collection<GrantedAuthority>> authoritiesConverter) Provides the configuredJwtso that custom authorities can be derived from it- Parameters:
authoritiesConverter- the conversion strategy fromJwtto aCollectionofGrantedAuthoritys- Returns:
- the
SecurityMockMvcRequestPostProcessors.JwtRequestPostProcessorfor further configuration
-
postProcessRequest
@NullUnmarked public org.springframework.mock.web.MockHttpServletRequest postProcessRequest(org.springframework.mock.web.MockHttpServletRequest request) - Specified by:
postProcessRequestin interfaceorg.springframework.test.web.servlet.request.RequestPostProcessor
-