use of org.springframework.security.authentication.RememberMeAuthenticationProvider in project spring-security by spring-projects.
the class RememberMeAuthenticationProviderTests method testIgnoresClassesItDoesNotSupport.
@Test
public void testIgnoresClassesItDoesNotSupport() throws Exception {
RememberMeAuthenticationProvider aap = new RememberMeAuthenticationProvider("qwerty");
TestingAuthenticationToken token = new TestingAuthenticationToken("user", "password", "ROLE_A");
assertThat(aap.supports(TestingAuthenticationToken.class)).isFalse();
// Try it anyway
assertThat(aap.authenticate(token)).isNull();
}
use of org.springframework.security.authentication.RememberMeAuthenticationProvider in project spring-security by spring-projects.
the class RememberMeAuthenticationProviderTests method testNormalOperation.
@Test
public void testNormalOperation() throws Exception {
RememberMeAuthenticationProvider aap = new RememberMeAuthenticationProvider("qwerty");
RememberMeAuthenticationToken token = new RememberMeAuthenticationToken("qwerty", "Test", AuthorityUtils.createAuthorityList("ROLE_ONE", "ROLE_TWO"));
Authentication result = aap.authenticate(token);
assertThat(token).isEqualTo(result);
}
use of org.springframework.security.authentication.RememberMeAuthenticationProvider in project spring-security by spring-projects.
the class RememberMeConfigurer method init.
@SuppressWarnings("unchecked")
@Override
public void init(H http) throws Exception {
validateInput();
String key = getKey();
RememberMeServices rememberMeServices = getRememberMeServices(http, key);
http.setSharedObject(RememberMeServices.class, rememberMeServices);
LogoutConfigurer<H> logoutConfigurer = http.getConfigurer(LogoutConfigurer.class);
if (logoutConfigurer != null && this.logoutHandler != null) {
logoutConfigurer.addLogoutHandler(this.logoutHandler);
}
RememberMeAuthenticationProvider authenticationProvider = new RememberMeAuthenticationProvider(key);
authenticationProvider = postProcess(authenticationProvider);
http.authenticationProvider(authenticationProvider);
initDefaultLoginFilter(http);
}
use of org.springframework.security.authentication.RememberMeAuthenticationProvider in project spring-security by spring-projects.
the class RememberMeAuthenticationProviderTests method testGettersSetters.
@Test
public void testGettersSetters() throws Exception {
RememberMeAuthenticationProvider aap = new RememberMeAuthenticationProvider("qwerty");
aap.afterPropertiesSet();
assertThat(aap.getKey()).isEqualTo("qwerty");
}
use of org.springframework.security.authentication.RememberMeAuthenticationProvider in project spring-security by spring-projects.
the class RememberMeAuthenticationProviderTests method testDetectsAnInvalidKey.
// ~ Methods
// ========================================================================================================
@Test
public void testDetectsAnInvalidKey() throws Exception {
RememberMeAuthenticationProvider aap = new RememberMeAuthenticationProvider("qwerty");
RememberMeAuthenticationToken token = new RememberMeAuthenticationToken("WRONG_KEY", "Test", AuthorityUtils.createAuthorityList("ROLE_ONE", "ROLE_TWO"));
try {
aap.authenticate(token);
fail("Should have thrown BadCredentialsException");
} catch (BadCredentialsException expected) {
}
}
Aggregations