简体   繁体   English

Spring MVC +安全-会话范围的Bean

[英]Spring mvc + security - session scoped beans

I have a web application that uses spring-security. 我有一个使用spring-security的Web应用程序。

The spring security creates sessions for our users. Spring Security为我们的用户创建会话。 Is it possible to tell spring security to store some reference in the session object for future lookup? 是否可以告诉Spring Security将一些引用存储在会话对象中以供将来查找? If so is it possible to do using xml and/or annotations or do I need to extend some class or use one of the spring security "extension points"? 如果是这样,是否可以使用xml和/或注释,或者是否需要扩展某些类或使用spring安全性“扩展点”之一?

If it is not possible by using spring-security what is the proper way to add some attribute to session? 如果使用spring-security无法实现,那么向会话添加一些属性的正确方法是什么?

I am not expertise in spring-secutiry module but as per my knowledge if the spring security in creating session for you then on the controller(assumption) you can use request.getSession() to work with HttpSession object. 我不是spring-seccutiry模块的专家,但是据我所知,如果spring安全性为您创建会话,然后在控制器上(假设),您可以使用request.getSession()处理HttpSession对象。

Regarding adding the attributes in the session, you can use some create some context inside HttpSession. 关于在会话中添加属性,您可以使用一些在HttpSession中创建一些上下文。 The context will be an object(bean) that would have all the setters/getters to get required values. 上下文将是一个对象(bean),它将具有所有设置程序/获取程序以获取所需的值。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM