Java 类org.springframework.security.web.authentication.rememberme.TokenBasedRememberMeServices 实例源码

项目:dxa-modules    文件:AudienceManagerSecurityProviderTest.java   
@Before
public void init() {
    audienceManagerService = mock(AudienceManagerService.class);
    authenticationManager = mock(AuthenticationManager.class);
    UserDetailsService userDetailsService = mock(UserDetailsService.class);
    TokenBasedRememberMeServices rememberMeServices = spy(new TokenBasedRememberMeServices("key", userDetailsService));
    provider = new AudienceManagerSecurityProvider(audienceManagerService, authenticationManager, rememberMeServices);

    token.setDetails("id");

    doThrow(new BadCredentialsException("Test")).when(authenticationManager).authenticate(any(Authentication.class));
    doReturn(token).when(authenticationManager).authenticate(argThat(new BaseMatcher<Authentication>() {
        @Override
        public boolean matches(Object item) {
            return ((Authentication) item).getPrincipal().equals("user");
        }

        @Override
        public void describeTo(Description description) {
            description.appendText("Username is user");
        }
    }));
}
项目:wonderjameeee    文件:SecurityConfiguration.java   
@Bean
    TokenBasedRememberMeServices rememberMeServices() {
        BackendTokenBasedRememberMeServices tokenBasedRememberMeServices = new BackendTokenBasedRememberMeServices(REMEMBER_ME_KEY, userDetailsService);
        tokenBasedRememberMeServices.setCookieName(REMEMBER_ME_TOKEN);
        tokenBasedRememberMeServices.setParameter(REMEMBER_ME_TOKEN);
        tokenBasedRememberMeServices.setTokenValiditySeconds(3600);
        tokenBasedRememberMeServices.setAlwaysRemember(true);
//        tokenBasedRememberMeServices.set;
        return tokenBasedRememberMeServices;
    }
项目:artifactory    文件:AuthUtils.java   
/**
 * try to restore remember me authentication and create valid session of it
 */
private static void restoreRememberMeAuth(HttpServletRequest request,HttpServletResponse response) {
    TokenBasedRememberMeServices tokenBasedRememberMeServices = ContextHelper.get().beanForType(
            TokenBasedRememberMeServices.class);
    Authentication authentication = tokenBasedRememberMeServices.autoLogin(request, response);
    if (authentication != null) {
        boolean sessionCreated = SessionUtils.setAuthentication(request, authentication, true);
        if (sessionCreated) {
            bindAuthentication(authentication);
        }
    }
}
项目:trader    文件:TraderApplication.java   
@Bean
public RememberMeServices rememberMeServices() {
    // TODO Is there some way of exposing the RememberMeServices instance that the remember me configurer creates by default?
    TokenBasedRememberMeServices services = new TokenBasedRememberMeServices("myAppKey", userDetailsService());
    services.setAlwaysRemember(true);
    return services;
}
项目:musicrecital    文件:Logout.java   
Object onActivate() {

        // Clear session
        Session session = request.getSession(false);
        if (session != null) {
            session.invalidate();
        }

        // Remove RememberMe cookie
        cookies.removeCookieValue(TokenBasedRememberMeServices.SPRING_SECURITY_REMEMBER_ME_COOKIE_KEY);

        return Home.class;
    }
项目:vaadin4spring-bits    文件:ServiceWrappedSpringVaadinServlet.java   
@Override
protected void service(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {

    // Get the entity manager factory if we don't have it
    if (this.entityManagerFactory == null) {
        this.entityManagerFactory = RuntimeBeanLoader.getBean(EntityManagerFactory.class);
    }

    // Create a new entity manager and set it in thread local
    if (this.entityManagerFactory != null) {
        LazyHibernateEntityManagerProvider.setCurrentEntityManager(this.entityManagerFactory.createEntityManager());
    }

    // Process the request normally now
    super.service(request, response);


    // Remove the used entity manager since it's finished with
    LazyHibernateEntityManagerProvider.setCurrentEntityManager(null);

    // We've just authorised the user in the service method so set the Remember Me cookie.
    // Ordinarily this would be done by Spring's UsernamePasswordAuthenticationFilter.
    Authentication auth = SecurityContextHolder.getContext().getAuthentication();
    if (auth != null && auth.isAuthenticated()) {
        if (rememberMeServices == null) {
            rememberMeServices = RuntimeBeanLoader.getBean(TokenBasedRememberMeServices.class);
        }
        rememberMeServices.onLoginSuccess(request, response, auth);
    }
}
项目:bbplay    文件:SecurityConfiguration.java   
/**
 * The {@link RememberMeServices} must be available as a Spring bean for
 * Vaadin4Spring.
 */
@Bean
public RememberMeServices rememberMeServices() {
    return new TokenBasedRememberMeServices(REMEMBERME_KEY, userDetailsService());
}
项目:todolist    文件:WebSecurityConfiguration.java   
@Bean
public RememberMeServices rememberMeServices() throws Exception {
    TokenBasedRememberMeServices result = new TokenBasedRememberMeServices("hell0w0r1d", service);
    result.setTokenValiditySeconds(2419200);
    return result;
}
项目:pbkdf2springsecurity    文件:SecurityConfig.java   
@Bean
public TokenBasedRememberMeServices rememberMeServices() {
    return new TokenBasedRememberMeServices("remember-me-key", userService());
}
项目:The-Punisher    文件:SecurityConfig.java   
@Bean
public TokenBasedRememberMeServices rememberMeServices() {
    return new TokenBasedRememberMeServices("remember-me-key", userService());
}
项目:spring-mvc-kickstart-archetype    文件:SecurityConfig.java   
@Bean
public TokenBasedRememberMeServices rememberMeServices() {
    return new TokenBasedRememberMeServices(REMEBER_ME_KEY, userService());
}
项目:vaadin4spring    文件:Application.java   
/**
 * The {@link RememberMeServices} must be available as a Spring bean for Vaadin4Spring.
 */
@Bean
public RememberMeServices rememberMeServices() {
    return new TokenBasedRememberMeServices("myAppKey", userDetailsService());
}
项目:wicket-spring-jpa-bootstrap-boilerplate    文件:Logout.java   
private void removeRememberMeCookie() {
    ((WebResponse)getResponse()).clearCookie(
            new Cookie(TokenBasedRememberMeServices.SPRING_SECURITY_REMEMBER_ME_COOKIE_KEY, null));
}
项目:adjule    文件:SecurityConfig.java   
@Bean
public RememberMeServices rememberMeServices() {
    return new TokenBasedRememberMeServices(env.getProperty("appKey"), userDetailsService);
}
项目:thymeleafexamples-layouts    文件:SecurityConfig.java   
@Bean
public TokenBasedRememberMeServices rememberMeServices() {
    return new TokenBasedRememberMeServices("remember-me-key", accountService);
}
项目:carmaint    文件:SecurityConfig.java   
@Bean
public TokenBasedRememberMeServices rememberMeServices() {
    return new TokenBasedRememberMeServices("remember-me-key", userService());
}
项目:eCommerce    文件:SecurityConfig.java   
@Bean
public TokenBasedRememberMeServices rememberMeServices() {
    return new TokenBasedRememberMeServices("remember-me-key", userService());
}
项目:members_cuacfm    文件:SecurityConfig.java   
/**
 * Remember me services.
 *
 * @return the token based remember me services
 */
@Bean
public TokenBasedRememberMeServices rememberMeServices() {
   return new TokenBasedRememberMeServices("remember-me-key", userService());
}