<http>
<remember-me/>
....</http>
我想在自动登录中执行一些逻辑 所以我试图覆盖AbstractRememberMeServices,如下所示:
package com.foo;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.core.Authentication;
import org.springframework.security.web.authentication.RememberMeServices;
public abstract class AbstractRememberMeServices implements RememberMeServices{
@Override
public Authentication autoLogin(HttpServletRequest arg0,
HttpServletResponse arg1) {
System.out.println("Auto Login");
return null;
}
@Override
public void loginSuccess(HttpServletRequest arg0, HttpServletResponse arg1,
Authentication arg2) {
System.out.println("Login Success");
}
}
但是自动登录没有动作,用户自动登录但打印声明没有打印? 怎么了?
答案 0 :(得分:2)
您为自己的班级AbstractRememberMeServices
命名的事实并不意味着之前扩展的所有其他班级现在都扩展了您的com.foo.AbstractRememberMeServices
。我并不是说不礼貌,但你需要回顾一下你对Java基础知识的了解。
关于你的问题,你需要编写一个自定义org.springframework.security.web.authentication.RememberMeService
实现,在Spring中配置它并使用services-ref
属性注册它:
<security:remember-me services-ref="myRememberMeServices"/>