use of org.springframework.security.web.authentication.rememberme.TokenBasedRememberMeServices in project spring-security by spring-projects.
the class TokenBasedRememberMeServicesTests method loginSuccessIgnoredIfParameterNotSetOrFalse.
@Test
public void loginSuccessIgnoredIfParameterNotSetOrFalse() {
TokenBasedRememberMeServices services = new TokenBasedRememberMeServices("key", new AbstractRememberMeServicesTests.MockUserDetailsService(null, false));
MockHttpServletRequest request = new MockHttpServletRequest();
request.addParameter(DEFAULT_PARAMETER, "false");
MockHttpServletResponse response = new MockHttpServletResponse();
services.loginSuccess(request, response, new TestingAuthenticationToken("someone", "password", "ROLE_ABC"));
Cookie cookie = response.getCookie(SPRING_SECURITY_REMEMBER_ME_COOKIE_KEY);
assertThat(cookie).isNull();
}
use of org.springframework.security.web.authentication.rememberme.TokenBasedRememberMeServices in project spring-security by spring-projects.
the class AbstractAuthenticationProcessingFilterTests method testGettersSetters.
@Test
public void testGettersSetters() throws Exception {
AbstractAuthenticationProcessingFilter filter = new MockAuthenticationFilter();
filter.setAuthenticationManager(mock(AuthenticationManager.class));
filter.setFilterProcessesUrl("/p");
filter.afterPropertiesSet();
assertThat(filter.getRememberMeServices()).isNotNull();
filter.setRememberMeServices(new TokenBasedRememberMeServices("key", new AbstractRememberMeServicesTests.MockUserDetailsService()));
assertThat(filter.getRememberMeServices().getClass()).isEqualTo(TokenBasedRememberMeServices.class);
assertThat(filter.getAuthenticationManager() != null).isTrue();
}
use of org.springframework.security.web.authentication.rememberme.TokenBasedRememberMeServices in project spring-security by spring-projects.
the class TokenBasedRememberMeServicesTests method createTokenBasedRememberMeServices.
// ~ Methods
// ========================================================================================================
@Before
public void createTokenBasedRememberMeServices() {
uds = mock(UserDetailsService.class);
services = new TokenBasedRememberMeServices("key", uds);
}
use of org.springframework.security.web.authentication.rememberme.TokenBasedRememberMeServices in project ocvn by devgateway.
the class FormsSecurityConfig method rememberMeServices.
/**
* This bean configures the {@link TokenBasedRememberMeServices} with
* {@link CustomJPAUserDetailsService}
*
* @return
*/
@Bean
public AbstractRememberMeServices rememberMeServices() {
TokenBasedRememberMeServices rememberMeServices = new TokenBasedRememberMeServices(UNIQUE_SECRET_REMEMBER_ME_KEY, customJPAUserDetailsService);
rememberMeServices.setAlwaysRemember(true);
return rememberMeServices;
}
Aggregations