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 java.lang.Object implements org.springframework.test.web.servlet.request.RequestPostProcessor- Since:
- 5.2
-
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description SecurityMockMvcRequestPostProcessors.JwtRequestPostProcessorauthorities(java.util.Collection<org.springframework.security.core.GrantedAuthority> authorities)Use the provided authorities in the tokenSecurityMockMvcRequestPostProcessors.JwtRequestPostProcessorauthorities(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 itSecurityMockMvcRequestPostProcessors.JwtRequestPostProcessorauthorities(org.springframework.security.core.GrantedAuthority... authorities)Use the provided authorities in the tokenSecurityMockMvcRequestPostProcessors.JwtRequestPostProcessorjwt(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.SecurityMockMvcRequestPostProcessors.JwtRequestPostProcessorjwt(org.springframework.security.oauth2.jwt.Jwt jwt)Use the givenJwtorg.springframework.mock.web.MockHttpServletRequestpostProcessRequest(org.springframework.mock.web.MockHttpServletRequest request)
-
-
-
Method Detail
-
jwt
public SecurityMockMvcRequestPostProcessors.JwtRequestPostProcessor 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. 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(java.util.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,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
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
-
-