
Originally Posted by
rohan123
if you want to get the values form database then obvious solution is override the concurrency control class.
Code:
<beans:bean id="sas" class="org.springframework.security.web.authentication.session.ConcurrentSessionControlStrategy">
<beans:constructor-arg name="sessionRegistry" ref="sessionRegistry" />
<beans:property name="maximumSessions" value="1" />
</beans:bean>this is default entry with beans namespace.
You can override the given "ConcurrentSessionControlStrategy" and add DataAccess logic there. and specify your custom class here.
First off...thank you for taking the time to reply. Much appreciated. Also...I am sorry that I was not clearer in my initial posting. I am aware of your suggestion and it was the reason I posted in the first place. In my post I was hoping to determine if there was a far more direct and simple strategy for specifying this property other than customizing the ConcurrentSessionControlStrategy itself.
This was a road I'd already started down, but upon doing so and surveying the results the amount of custom bean configuration (outside the scope of the default http namespace configuration) seemed really unreasonable. All of it necessary only to specify this single property dynamically upon startup (and because a property configurer can not be applied within the max-sessions attribute of the <concurrency-control /> element).
The "rough" psuedo-configuration may be as follows. I am aware this may not be complete and the wiring needs tweaking...but the reason I post it is that it illustrates the extent of the customizations needed purely to apply the property configurer:
Code:
<bean id="concurrencyFilter"
class="org.springframework.security.web.session.ConcurrentSessionFilter">
<property name="sessionRegistry" ref="sessionRegistry" />
<property name="expiredUrl"
value="/index.html?spring.security.error=expired.session" />
</bean>
<bean id="customAuthFilter"
class="org.springframework.security.web.authentication.UsernamePasswordAuthenticationFilter">
<property name="sessionAuthenticationStrategy" ref="sas" />
<property name="authenticationManager" ref="authenticationManager" />
</bean>
<bean id="sas"
class="org.springframework.security.web.authentication.session.ConcurrentSessionControlStrategy">
<constructor-arg name="sessionRegistry" ref="sessionRegistry" />
<property name="maximumSessions"
value="$+MAX_SESSIONS+" />
<property name="exceptionIfMaximumExceeded" value="true" />
</bean>
<bean id="sessionRegistry"
class="org.springframework.security.core.session.SessionRegistryImpl" />
<bean id="authenticationEntryPoint"
class="org.springframework.security.web.authentication.LoginUrlAuthenticationEntryPoint">
<property name="loginFormUrl" value="/index.html" />
</bean>
...
...
And then modification to the http namespace configuration that would be something similar to:
Code:
<!-- auto-config now set to false in order to allow for customizations -->
<security:http auto-config="false" use-expressions="true">
<security:session-management session-authentication-strategy-ref="sas">
<!-- COMMENTED OUT as now replaced by session-authentication-strategy-ref above...
<security:concurrency-control
max-sessions="30" error-if-maximum-exceeded="true"
expired-url="/index.html?spring.security.error=expired.session" />
-->
</security:session-management>
<security:custom-filter position="CONCURRENT_SESSION_FILTER" ref="concurrencyFilter" />
<security:custom-filter position="FORM_LOGIN_FILTER" ref="customAuthFilter" />
...
...
Thus, my posting was to determine if there was a direct way to handle this, but for which I'm not aware of.
Thanks again for the feedback,
Kind Regards,
Todd