Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p>Thanks, help me a lot ! With <code>SessionRegistry</code>, I can use <a href="http://static.springsource.org/spring-security/site/docs/3.1.x/apidocs/org/springframework/security/core/session/SessionRegistry.html#getAllPrincipals%28%29" rel="noreferrer">getAllPrincipals()</a> to compare the user to modify with the current active users in sessions. If a session exist, I can invalidate his session using : <a href="http://static.springsource.org/spring-security/site/docs/3.1.x/apidocs/org/springframework/security/core/session/SessionInformation.html#expireNow%28%29" rel="noreferrer">expireNow()</a> (from <code>SessionInformation</code>) to force re-authentication.</p> <p>But I don't understand the usefulness of <code>securityContextPersistenceFilter</code> ?</p> <p>EDIT :</p> <pre><code>// user object = User currently updated // invalidate user session List&lt;Object&gt; loggedUsers = sessionRegistry.getAllPrincipals(); for (Object principal : loggedUsers) { if(principal instanceof User) { final User loggedUser = (User) principal; if(user.getUsername().equals(loggedUser.getUsername())) { List&lt;SessionInformation&gt; sessionsInfo = sessionRegistry.getAllSessions(principal, false); if(null != sessionsInfo &amp;&amp; sessionsInfo.size() &gt; 0) { for (SessionInformation sessionInformation : sessionsInfo) { LOGGER.info("Exprire now :" + sessionInformation.getSessionId()); sessionInformation.expireNow(); sessionRegistry.removeSessionInformation(sessionInformation.getSessionId()); // User is not forced to re-logging } } } } } </code></pre>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload