gpt4 book ai didi

java - Spring4.0.3中AuthenticationException.getAuthentication()的替换是什么

转载 作者:塔克拉玛干 更新时间:2023-11-03 03:55:28 25 4
gpt4 key购买 nike

我在我的项目中使用 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) 方法也已弃用。这两种方法有什么替代方法吗?

最佳答案

没有替代方法,因为此方法存在安全风险。

latest Javadoc对于 3.x 版本说:

@deprecated to avoid potential leaking of sensitive information (e.g. through serialization/remoting).

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

关于java - Spring4.0.3中AuthenticationException.getAuthentication()的替换是什么,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/39524178/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com