Search in sources :

Example 1 with TokenBasedRememberMeServices

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();
}
Also used : Cookie(javax.servlet.http.Cookie) MockHttpServletRequest(org.springframework.mock.web.MockHttpServletRequest) TokenBasedRememberMeServices(org.springframework.security.web.authentication.rememberme.TokenBasedRememberMeServices) TestingAuthenticationToken(org.springframework.security.authentication.TestingAuthenticationToken) MockHttpServletResponse(org.springframework.mock.web.MockHttpServletResponse) Test(org.junit.Test)

Example 2 with TokenBasedRememberMeServices

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();
}
Also used : AuthenticationManager(org.springframework.security.authentication.AuthenticationManager) TokenBasedRememberMeServices(org.springframework.security.web.authentication.rememberme.TokenBasedRememberMeServices) Test(org.junit.Test)

Example 3 with TokenBasedRememberMeServices

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);
}
Also used : UserDetailsService(org.springframework.security.core.userdetails.UserDetailsService) TokenBasedRememberMeServices(org.springframework.security.web.authentication.rememberme.TokenBasedRememberMeServices) Before(org.junit.Before)

Example 4 with TokenBasedRememberMeServices

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;
}
Also used : TokenBasedRememberMeServices(org.springframework.security.web.authentication.rememberme.TokenBasedRememberMeServices) Bean(org.springframework.context.annotation.Bean)

Aggregations

TokenBasedRememberMeServices (org.springframework.security.web.authentication.rememberme.TokenBasedRememberMeServices)4 Test (org.junit.Test)2 Cookie (javax.servlet.http.Cookie)1 Before (org.junit.Before)1 Bean (org.springframework.context.annotation.Bean)1 MockHttpServletRequest (org.springframework.mock.web.MockHttpServletRequest)1 MockHttpServletResponse (org.springframework.mock.web.MockHttpServletResponse)1 AuthenticationManager (org.springframework.security.authentication.AuthenticationManager)1 TestingAuthenticationToken (org.springframework.security.authentication.TestingAuthenticationToken)1 UserDetailsService (org.springframework.security.core.userdetails.UserDetailsService)1