I want to manage user sessions and forbid one user to login twice using the same credentials.
According to documentation I've added the listener entry in my web.xml
and tried to edit context.xml
My context.xml
file looks like this:
<?xml version="1.0" encoding="UTF-8"?>
<beans:beans xmlns="http://www.springframework.org/schema/mvc"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:beans="http://www.springframework.org/schema/beans"
xmlns:context="http://www.springframework.org/schema/context"
xsi:schemaLocation="http://www.springframework.org/schema/mvc http://www.springframework.org/schema/mvc/spring-mvc.xsd
http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd
http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context.xsd">
<annotation-driven />
<beans:bean class="org.springframework.web.servlet.view.InternalResourceViewResolver">
<beans:property name="prefix" value="/WEB-INF/views/" />
<beans:property name="suffix" value=".jsp" />
</beans:bean>
<context:component-scan base-package="com.xyz.abc" />
</beans:beans>
and when I add lines from documentation:
<http>
<session-management>
<concurrency-control max-sessions="1" error-if-maximum-exceeded="true" />
</session-management>
</http>
below/under I got an error:
The markup in the document following the root element must be well-formed.
Which means I can only have one root element. So I've added that code inside <beans:beans>
and then another problem occured:
cvc-complex-type.2.4.c: The matching wildcard is strict, but no declaration can be found for element 'http'.
and Cannot locate BeanDefinitionParser for element [http]
For first error I tried the answer from here and added:
<dependency>
<groupId>org.springframework.security</groupId>
<artifactId>spring-security-config</artifactId>
<version>4.0.3.RELEASE</version>
</dependency>
to my pom.xml
to download the mentioned spring-security-config.jar
and also added:
http://www.springframework.org/schema/security
http://www.springframework.org/schema/security/spring-security-4.0.3.xsd
to xsi:schemaLocation
but nothing has changed.
From what I've found, the second error is connected with the first one.
Edit:
I followed @rmlan's lead and added: xmlns:sec="http://www.springframework.org/schema/security"
and changed <http>
to <sec:http>
And also added missing dependency to pom.xml
:
<dependency>
<groupId>org.springframework.security</groupId>
<artifactId>spring-security-web</artifactId>
<version>4.0.3.RELEASE</version>
</dependency>
and another error popped up:
No AuthenticationEntryPoint could be established. Please make sure you have a login mechanism configured through the namespace (such as form-login) or specify a custom AuthenticationEntryPoint with the 'entry-point-ref' attribute
But it'll be handled in the future.