代码之家  ›  专栏  ›  技术社区  ›  PowerStat

如何将基于ConcurrentSessionControllerImpl的旧代码从Spring Security 2.0迁移到3.0?

  •  0
  • PowerStat  · 技术社区  · 7 年前

    我现在的问题是有一个类 ConcurrentSessionControllerImpl 已在SpringSecurity3.0中通过重构删除。关键是我找不到任何关于此重构的文档,也找不到任何关于 ConcurrentSessionControllerImpl 在SpringSecurity2.0文档中初始化。

    类重写以下方法:

    public void checkAuthenticationAllowed(final Authentication auth) throws AuthenticationException;
    
    public void registerSuccessfulAuthentication(final Authentication authentication);
    

    有没有迁移的方法,或者我必须重写整个应用程序安全层?

    0 回复  |  直到 7 年前
        1
  •  0
  •   PowerStat    6 年前

    由于SpringSecurity的重构 ConcurrentSessionControllerImpl 在很大程度上被重构为 org.springframework.security.web.authentication.session.ConcurrentSessionControlStrategy

    在哪里? registerSuccessfulAuthentication 最佳映射到

    onAuthentication(Authentication authentication, HttpServletRequest request, HttpServletResponse response)
    

    checkAuthenticationAllowed 现在是 ConcurrentSessionControlStrategy 部分可通过以下方式定制:

    protected void allowableSessionsExceeded(List<SessionInformation> sessions, int allowableSessions, SessionRegistry registry);
    
    protected int getMaximumSessionsForThisUser(Authentication authentication);
    

    还有一些setter要配置:

    public void setExceptionIfMaximumExceeded(boolean exceptionIfMaximumExceeded);
    public void setMaximumSessions(int maximumSessions);
    

    并发会话控制策略 看看 JavaDocs .