本文整理汇总了Java中org.springframework.security.web.authentication.rememberme.TokenBasedRememberMeServices类的典型用法代码示例。如果您正苦于以下问题:Java TokenBasedRememberMeServices类的具体用法?Java TokenBasedRememberMeServices怎么用?Java TokenBasedRememberMeServices使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
TokenBasedRememberMeServices类属于org.springframework.security.web.authentication.rememberme包,在下文中一共展示了TokenBasedRememberMeServices类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: init
import org.springframework.security.web.authentication.rememberme.TokenBasedRememberMeServices; //导入依赖的package包/类
@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");
}
}));
}
示例2: rememberMeServices
import org.springframework.security.web.authentication.rememberme.TokenBasedRememberMeServices; //导入依赖的package包/类
@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;
}
示例3: restoreRememberMeAuth
import org.springframework.security.web.authentication.rememberme.TokenBasedRememberMeServices; //导入依赖的package包/类
/**
* 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);
}
}
}
示例4: rememberMeServices
import org.springframework.security.web.authentication.rememberme.TokenBasedRememberMeServices; //导入依赖的package包/类
@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;
}
示例5: onActivate
import org.springframework.security.web.authentication.rememberme.TokenBasedRememberMeServices; //导入依赖的package包/类
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;
}
示例6: service
import org.springframework.security.web.authentication.rememberme.TokenBasedRememberMeServices; //导入依赖的package包/类
@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);
}
}
示例7: rememberMeServices
import org.springframework.security.web.authentication.rememberme.TokenBasedRememberMeServices; //导入依赖的package包/类
/**
* The {@link RememberMeServices} must be available as a Spring bean for
* Vaadin4Spring.
*/
@Bean
public RememberMeServices rememberMeServices() {
return new TokenBasedRememberMeServices(REMEMBERME_KEY, userDetailsService());
}
示例8: rememberMeServices
import org.springframework.security.web.authentication.rememberme.TokenBasedRememberMeServices; //导入依赖的package包/类
@Bean
public RememberMeServices rememberMeServices() throws Exception {
TokenBasedRememberMeServices result = new TokenBasedRememberMeServices("hell0w0r1d", service);
result.setTokenValiditySeconds(2419200);
return result;
}
示例9: rememberMeServices
import org.springframework.security.web.authentication.rememberme.TokenBasedRememberMeServices; //导入依赖的package包/类
@Bean
public TokenBasedRememberMeServices rememberMeServices() {
return new TokenBasedRememberMeServices("remember-me-key", userService());
}
示例10: rememberMeServices
import org.springframework.security.web.authentication.rememberme.TokenBasedRememberMeServices; //导入依赖的package包/类
@Bean
public TokenBasedRememberMeServices rememberMeServices() {
return new TokenBasedRememberMeServices("remember-me-key", userService());
}
示例11: rememberMeServices
import org.springframework.security.web.authentication.rememberme.TokenBasedRememberMeServices; //导入依赖的package包/类
@Bean
public TokenBasedRememberMeServices rememberMeServices() {
return new TokenBasedRememberMeServices(REMEBER_ME_KEY, userService());
}
示例12: rememberMeServices
import org.springframework.security.web.authentication.rememberme.TokenBasedRememberMeServices; //导入依赖的package包/类
/**
* The {@link RememberMeServices} must be available as a Spring bean for Vaadin4Spring.
*/
@Bean
public RememberMeServices rememberMeServices() {
return new TokenBasedRememberMeServices("myAppKey", userDetailsService());
}
示例13: removeRememberMeCookie
import org.springframework.security.web.authentication.rememberme.TokenBasedRememberMeServices; //导入依赖的package包/类
private void removeRememberMeCookie() {
((WebResponse)getResponse()).clearCookie(
new Cookie(TokenBasedRememberMeServices.SPRING_SECURITY_REMEMBER_ME_COOKIE_KEY, null));
}
示例14: rememberMeServices
import org.springframework.security.web.authentication.rememberme.TokenBasedRememberMeServices; //导入依赖的package包/类
@Bean
public RememberMeServices rememberMeServices() {
return new TokenBasedRememberMeServices(env.getProperty("appKey"), userDetailsService);
}
示例15: rememberMeServices
import org.springframework.security.web.authentication.rememberme.TokenBasedRememberMeServices; //导入依赖的package包/类
@Bean
public TokenBasedRememberMeServices rememberMeServices() {
return new TokenBasedRememberMeServices("remember-me-key", accountService);
}