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<org.springframework.security.core.GrantedAuthority> authorities) Use the provided authorities in the tokenauthorities(org.springframework.core.convert.converter.Converter<org.springframework.security.oauth2.jwt.Jwt, Collection<org.springframework.security.core.GrantedAuthority>> authoritiesConverter) Provides the configuredJwtso that custom authorities can be derived from itauthorities(org.springframework.security.core.GrantedAuthority... authorities) Use the provided authorities in the tokenUse the givenJwt.BuilderConsumerto configure the underlyingJwtThis method first creates a defaultJwt.Builderinstance with default values for thealg,sub, andscopeclaims.jwt(org.springframework.security.oauth2.jwt.Jwt jwt) Use the givenJwtorg.springframework.mock.web.MockHttpServletRequestpostProcessRequest(org.springframework.mock.web.MockHttpServletRequest request)
-
Method Details
-
jwt
public SecurityMockMvcRequestPostProcessors.JwtRequestPostProcessor jwt(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. CallingSecurityMockMvcRequestPostProcessors.jwt()is the equivalent of callingSecurityMockMvcRequestPostProcessors.jwt().jwt(() -> {}).- Parameters:
jwtBuilderConsumer- For configuring the underlyingJwt- Returns:
- the
SecurityMockMvcRequestPostProcessors.JwtRequestPostProcessorfor additional customization
-
jwt
public SecurityMockMvcRequestPostProcessors.JwtRequestPostProcessor jwt(org.springframework.security.oauth2.jwt.Jwt jwt) Use the givenJwt- Parameters:
jwt- TheJwtto use- Returns:
- the
SecurityMockMvcRequestPostProcessors.JwtRequestPostProcessorfor additional customization
-
authorities
public SecurityMockMvcRequestPostProcessors.JwtRequestPostProcessor authorities(Collection<org.springframework.security.core.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.security.core.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<org.springframework.security.oauth2.jwt.Jwt, 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
SecurityMockMvcRequestPostProcessors.JwtRequestPostProcessorfor further configuration
-
postProcessRequest
public org.springframework.mock.web.MockHttpServletRequest postProcessRequest(org.springframework.mock.web.MockHttpServletRequest request) - Specified by:
postProcessRequestin interfaceorg.springframework.test.web.servlet.request.RequestPostProcessor
-