加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 大数据 > 正文

在Spring4.0.3中,什么是AuthenticationException.getAuthenticat

发布时间:2020-12-15 01:30:04 所属栏目:大数据 来源:网络整理
导读:我在我的项目中使用Spring 3,现在升级到Spring 4.0.3.RELEASE. 现在使用AuthenticationException.getAuthentication()时,它表示已弃用,但无法找到替代方案.这是代码: public ModelAndView init(HttpServletRequest request,HttpServletResponse response) {

我在我的项目中使用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).

任何依赖于此的代码都需要重新思考.

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读