我想从会话范围的 spring bean 访问登录用户,这可能吗?
我没有使用 spring security,而是 openam 来为我的 web 应用程序提供安全性,所以我不能使用它(正如我在互联网上的许多示例中看到的那样):
(User)SecurityContextHolder.getContext().getAuthentication().getPrincipal();
是否可以将与您获得的名称相同的名称注入到我的会话范围 bean 中:
HttpServletRequest.getUserPrincipal().getName()