我在我的项目中使用Spring 3,现在升级到Spring 4.0.3.RELEASE.
现在使用AuthenticationException.getAuthentication()时,它表示已弃用,但无法找到替代方案.这是代码:
public ModelAndView init(HttpServletRequest request,HttpServletResponse response) {
AuthenticationException exception = (AuthenticationException) request.getSession().getAttribute(WebAttributes.AUTHENTICATION_EXCEPTION);
Authentication loginAuthentication = exception.getAuthentication();
// Set the user name for the change password screen
return new ModelAndView("common/changePassword","userName",loginAuthentication.getPrincipal());
}
最佳答案
没有替代品,因为这种方法存在安全风险.
原文链接:https://www.f2er.com/spring/432253.html3.x版本的latest Javadoc说:
@deprecated to avoid potential leaking of sensitive information (e.g. through serialization/remoting).
任何依赖于此的代码都需要重新思考.