HttpSessionListener を実装しましたが、ログインしているユーザーが同時に 2 回目にログインする場合を除いて、正常に動作します。Spring は最初のセッションを正しく終了しますが、destroySession イベントは発生しません。少なくとも私のリスナーはそれを取得しません。
私の春のセキュリティは次のとおりです。
<session-management
session-fixation-protection="migrateSession" >
<concurrency-control
max-sessions="1"
expired-url="/login_sessionexpired" />
</session-management>
上記は、2 回目に同時にログインした場合、最初のセッションからユーザーをログアウトしますが、HttpSessionListener.sessionDestroyed は呼び出されません。
HttpSessionListener.sessionDestroyed は、通常、手動ログアウトとセッション タイムアウトのために呼び出されます。
web.xml にリスナー用の「委任プロキシ」があります: com.test.security.DelegatingHttpSessionEventListenerProxy
このリスナーは、my-servlet.xml で次のように定義された spring-bean に委譲します。
<bean id="httpSessionEventListener"
class="com.test.security.SimpleHttpSessionEventListenerImpl" />
委任リスナーは次のようにコーディングされます。
public class DelegatingHttpSessionEventListenerProxy implements
HttpSessionListener {
/**
* Delegates sessionCreated Event to the Spring-bean
*/
@Override
public void sessionCreated(HttpSessionEvent se) {
ApplicationContext context = WebApplicationContextUtils
.getWebApplicationContext(se.getSession().getServletContext());
HttpSessionListener target = context.getBean(
"httpSessionEventListener", HttpSessionListener.class);
target.sessionCreated(se);
}
/**
* Delegates sessionDestroyed Event to the Spring-bean
*/
@Override
public void sessionDestroyed(HttpSessionEvent se) {
ApplicationContext context = WebApplicationContextUtils
.getWebApplicationContext(se.getSession().getServletContext());
HttpSessionListener target = context.getBean(
"httpSessionEventListener", HttpSessionListener.class);
target.sessionDestroyed(se);
}
}
私は spring-security-3.0.5 を使用しています。何が欠けているのか誰か教えてください。ありがとうございました。