2017-09-14 178 views
1

我有一个要求,允许在我的web应用程序中进行并发会话控制并使可配置字段“max-sessions”。我的配置是这样的:Spring Security并发会话:未能使“max-sessions”字段可配置

<security:session-management> 
    <security:concurrency-control max-sessions="${maxConcurrentSessionsCount}" session-registry-ref="sessionRegistry" expired-url="/handleInvalidatedSession.gs4tr"/> 
</security:session-management>` 

正如您可以猜到,在“services.properties”文件应该有“maxConcurrentSessionsCount”字段,用户将通过自己的意志设定。 但我在Intelij获得下一个警告:

"attribute 'max-sessions' on element 'security:concurrency-control' is not valid with respect to its type, 'positiveInteger'". 

我成功地“记住我”配置许多其他的东西,如“令牌有效性秒”和“记住,我cookie的”,等等。 任何想法如何解决问题?搜索几天的互联网寻求帮助,但失败。

编辑: 在 “services.properties” 配置: “maxConcurrentSessionsCount = 2”

在启动应用程序时,它引发下一个错误:

No, it doesn't. It throws next ERROR on starting app: 

017-09-14 15点46分:47,724 ERROR [org.gs4tr.projectdirector.service.context.ContextLoaderListener] [localhost-startStop-1] [user:] - org.springframework.beans.factory.xml.XmlBeanDefinitionStoreException:来自类路径资源的XML文档中的第75行[组织/ gs4tr /基础/模块/ webmvc /弹簧/的applicationContext安全默认.xml]无效;嵌套异常是org.xml.sax.SAXParseException; lineNumber:75; columnNumber:72; cvc-datatype-valid.1.2.1:'$ {maxConcurrentSessionsCount}'不是'integer'的有效值。 在org.springframework.beans.factory.xml.XmlBeanDefinitionReader.doLoadBeanDefinitions(XmlBeanDefinitionReader.java:399) 在org.springframework.beans.factory.xml.XmlBeanDefinitionReader.loadBeanDefinitions(XmlBeanDefinitionReader.java:336) 在org.springframework。 beans.factory.xml.XmlBeanDefinitionReader.loadBeanDefinitions(XmlBeanDefinitionReader.java:304) 在org.springframework.beans.factory.support.AbstractBeanDefinitionReader.loadBeanDefinitions(AbstractBeanDefinitionReader.java:181) 在org.springframework.beans.factory.support。 AbstractBeanDefinitionReader.loadBeanDefinitions(AbstractBeanDefinitionReader.java:217) at org.springframework.beans.factory.support.AbstractBeanDefinitionReader.loadBeanDefinitions(AbstractBeanDefinitionReader.java:188) at org.spri ngframework.web.context.support.XmlWebApplicationContext.loadBeanDefinitions(XmlWebApplicationContext.java:125) at org.springframework.web.context.support.XmlWebApplicationContext.loadBeanDefinitions(XmlWebApplicationContext.java:94) at org.springframework.context.support。 AbstractRefreshableApplicationContext.refreshBeanFactory(AbstractRefreshableApplicationContext.java:129) 在org.springframework.context.support.AbstractApplicationContext.obtainFreshBeanFactory(AbstractApplicationContext.java:537) 在org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:452) at org.springframework.web.context.ContextLoader.configureAndRefreshWebApplicationContext(ContextLoader.java:403) at org.springframework.web.context.ContextLoader.initWebApplicationContex吨(ContextLoader.java:306) 在org.springframework.web.context.ContextLoaderListener.contextInitialized(ContextLoaderListener.java:106) 在org.gs4tr.projectdirector.service.context.ContextLoaderListener.contextInitialized(ContextLoaderListener.java:73) 在org.apache.catalina.core.StandardContext.listenerStart(StandardContext.java:4811) 在org.apache.catalina.core.StandardContext.startInternal(StandardContext.java:5251) 的组织。apache.catalina.util.LifecycleBase.start(LifecycleBase.java:147)

+1

所以你得到一个警告,但它的工作原理?您是否在某处定义了'maxConcurrentSesionsCount'参数? IntelliJ IDEA是否意识到它? – Kayaman

+0

@Kayaman请参阅编辑问题。 – Alex

回答

0

这是最大会话属性的定义:

<xs:attribute name="max-sessions" type="xs:positiveInteger"> 
<xs:annotation> 
<xs:documentation> 
The maximum number of sessions a single authenticated user can have open at the same time. Defaults to "1". 
</xs:documentation> 
</xs:annotation> 
</xs:attribute> 

正如你所看到的,属性的类型为positiveInteger和你不能使用SpEL。

规划环境地政司(如获取属性值)的字符串,并在某些情况下,你被允许use SpEL

A property or constructor-arg value can be set using expressions as shown below

相关问题