Class SecurityMockMvcRequestPostProcessors.UserRequestPostProcessor
- java.lang.Object
-
- org.springframework.security.test.web.servlet.request.SecurityMockMvcRequestPostProcessors.UserRequestPostProcessor
-
- All Implemented Interfaces:
org.springframework.test.web.servlet.request.RequestPostProcessor
- Enclosing class:
- SecurityMockMvcRequestPostProcessors
public static final class SecurityMockMvcRequestPostProcessors.UserRequestPostProcessor extends java.lang.Object implements org.springframework.test.web.servlet.request.RequestPostProcessorCreates aUsernamePasswordAuthenticationTokenand sets the principal to be aUserand associates it to theMockHttpServletRequest.- Since:
- 4.0
-
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description SecurityMockMvcRequestPostProcessors.UserRequestPostProcessorauthorities(java.util.Collection<? extends org.springframework.security.core.GrantedAuthority> authorities)Populates the user'sGrantedAuthority's.SecurityMockMvcRequestPostProcessors.UserRequestPostProcessorauthorities(org.springframework.security.core.GrantedAuthority... authorities)Populates the user'sGrantedAuthority's.SecurityMockMvcRequestPostProcessors.UserRequestPostProcessorpassword(java.lang.String password)Populates the user's password.org.springframework.mock.web.MockHttpServletRequestpostProcessRequest(org.springframework.mock.web.MockHttpServletRequest request)SecurityMockMvcRequestPostProcessors.UserRequestPostProcessorroles(java.lang.String... roles)Specify the roles of the user to authenticate as.
-
-
-
Method Detail
-
roles
public SecurityMockMvcRequestPostProcessors.UserRequestPostProcessor roles(java.lang.String... roles)
Specify the roles of the user to authenticate as. This method is similar toauthorities(GrantedAuthority...), but just not as flexible.- Parameters:
roles- The roles to populate. Note that if the role does not start withROLE_PREFIXit will automatically be prepended. This means by defaultroles("ROLE_USER")androles("USER")are equivalent.- Returns:
- the UserRequestPostProcessor for further customizations
- See Also:
authorities(GrantedAuthority...),ROLE_PREFIX
-
authorities
public SecurityMockMvcRequestPostProcessors.UserRequestPostProcessor authorities(org.springframework.security.core.GrantedAuthority... authorities)
Populates the user'sGrantedAuthority's. The default is ROLE_USER.- Parameters:
authorities-- Returns:
- the UserRequestPostProcessor for further customizations
- See Also:
roles(String...)
-
authorities
public SecurityMockMvcRequestPostProcessors.UserRequestPostProcessor authorities(java.util.Collection<? extends org.springframework.security.core.GrantedAuthority> authorities)
Populates the user'sGrantedAuthority's. The default is ROLE_USER.- Parameters:
authorities-- Returns:
- the UserRequestPostProcessor for further customizations
- See Also:
roles(String...)
-
password
public SecurityMockMvcRequestPostProcessors.UserRequestPostProcessor password(java.lang.String password)
Populates the user's password. The default is "password"- Parameters:
password- the user's password- Returns:
- the UserRequestPostProcessor for further customizations
-
postProcessRequest
public org.springframework.mock.web.MockHttpServletRequest postProcessRequest(org.springframework.mock.web.MockHttpServletRequest request)
- Specified by:
postProcessRequestin interfaceorg.springframework.test.web.servlet.request.RequestPostProcessor
-
-