我在我的项目中使用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());
}
此外,不推荐使用方法setAuthentication(authentication).
这两种方法有其他选择吗?
最佳答案
没有替代品,因为这种方法存在安全风险.
3.x版本的latest Javadoc说:
@deprecated to avoid potential leaking of sensitive information (e.g. through serialization/remoting).
任何依赖于此的代码都需要重新思考.
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。