【问题标题】:Spring Session and Spring Security (3.2.X RELEASE)Spring Session 和 Spring Security (3.2.X RELEASE)
【发布时间】:2016-11-07 04:08:31
【问题描述】:

我们有一个基于 Spring Framework 3.2.x(目前为 3.2.12-RELEASE)和 Spring Security 3.2.x(即 3.2.5-RELEASE)构建的 Web 应用程序

安全性是用 classical Spring 方法实现的。在 web.xml 我们加载 ApplicationContextspringSecurityFilterChain

<?xml version="1.0" encoding="UTF-8"?>
<web-app xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://java.sun.com/xml/ns/javaee"  xsi:schemaLocation="http://java.sun.com/xml/ns/javaee  http://java.sun.com/xml/ns/javaee/web-app_3_0.xsd" version="3.0">
<context-param>
     <param-name>contextConfigLocation</param-name>
     <param-value>
        classpath*:META-INF/spring/applicationContext*.xml
    </param-value>
</context-param>
...
  <filter>
    <filter-name>springSecurityFilterChain</filter-name>
    <filter-class>org.springframework.web.filter.DelegatingFilterProxy</filter-class>
  </filter>
  <filter-mapping>
    <filter-name>springSecurityFilterChain</filter-name>
    <url-pattern>/*</url-pattern>
  </filter-mapping>

随着要求的变化,我们正在尝试研究如何在同一浏览器中允许每个选项卡(或窗口)使用不同的 HttpSession:在这种情况下同一物理用户可以使用两个单独的应用用户登录应用程序。

我可以理解,使用 JSESSIONID cookie 方法是不可能的。我正在尝试使用 Spring Session (Spring Session and Spring SecuritySpring Session Multiple Session),但我无法做到这一点,在将我的 XML 配置与之前链接中显示的 JavaConfig 方法混合时遇到困难,Tomcat 甚至不会以很多错误开始。

我是混合 XML 和 JavaConfig approch 的新手,所以..谁能给我一个提示,告诉我如何继续使用 Spring Session?

还有其他方法可以满足我的要求吗?

【问题讨论】:

    标签: spring spring-security spring-java-config spring-session xml-configuration


    【解决方案1】:

    Spring Session 项目实际上包含一些 sample projects,它们演示了 Spring XML 配置的用法。查找示例名称中带有-xml 后缀的示例。

    一般来说,您需要手动将适当的@Configuration 类注册为@Bean。例如,如果你想使用 Redis 支持的 Spring Session,注册RedisHttpSessionConfiguration。通过查看适当的@Enable*HttpSession 注释(在本例中为@EnableRedisHttpSession)并确定通过@Import 注释导入的类,您将找到要使用的正确@Configuration 类。

    【讨论】:

      猜你喜欢
      • 2015-06-11
      • 2016-07-08
      • 2019-10-15
      • 2018-04-12
      • 1970-01-01
      • 2018-02-23
      • 2014-05-05
      • 1970-01-01
      • 2014-02-25
      相关资源
      最近更新 更多