public static final class SecurityMockMvcRequestPostProcessors.UserRequestPostProcessor extends Object implements RequestPostProcessor
UsernamePasswordAuthenticationToken
and sets the principal to be
a User
and associates it to the MockHttpServletRequest
.Modifier and Type | Method and Description |
---|---|
SecurityMockMvcRequestPostProcessors.UserRequestPostProcessor |
authorities(Collection<? extends GrantedAuthority> authorities)
Populates the user's
GrantedAuthority 's. |
SecurityMockMvcRequestPostProcessors.UserRequestPostProcessor |
authorities(GrantedAuthority... authorities)
Populates the user's
GrantedAuthority 's. |
SecurityMockMvcRequestPostProcessors.UserRequestPostProcessor |
password(String password)
Populates the user's password.
|
MockHttpServletRequest |
postProcessRequest(MockHttpServletRequest request) |
SecurityMockMvcRequestPostProcessors.UserRequestPostProcessor |
roles(String... roles)
Specify the roles of the user to authenticate as.
|
public SecurityMockMvcRequestPostProcessors.UserRequestPostProcessor roles(String... roles)
authorities(GrantedAuthority...)
, but just not as flexible.roles
- The roles to populate. Note that if the role does not start with
#rolePrefix(String)
it will automatically be prepended. This means by
default roles("ROLE_USER")
and roles("USER")
are equivalent.authorities(GrantedAuthority...)
,
#rolePrefix(String)
public SecurityMockMvcRequestPostProcessors.UserRequestPostProcessor authorities(GrantedAuthority... authorities)
GrantedAuthority
's. The default is ROLE_USER.authorities
- roles(String...)
public SecurityMockMvcRequestPostProcessors.UserRequestPostProcessor authorities(Collection<? extends GrantedAuthority> authorities)
GrantedAuthority
's. The default is ROLE_USER.authorities
- roles(String...)
public SecurityMockMvcRequestPostProcessors.UserRequestPostProcessor password(String password)
password
- the user's passwordpublic MockHttpServletRequest postProcessRequest(MockHttpServletRequest request)
postProcessRequest
in interface RequestPostProcessor