2727import eu .webeid .example .security .ajax .AjaxAuthenticationFailureHandler ;
2828import eu .webeid .example .security .ajax .AjaxAuthenticationSuccessHandler ;
2929import eu .webeid .security .authtoken .WebEidAuthToken ;
30- import jakarta .servlet .FilterChain ;
31- import jakarta .servlet .ServletException ;
3230import jakarta .servlet .http .HttpServletRequest ;
3331import jakarta .servlet .http .HttpServletResponse ;
3432import org .slf4j .Logger ;
4139import org .springframework .security .authentication .BadCredentialsException ;
4240import org .springframework .security .core .Authentication ;
4341import org .springframework .security .core .AuthenticationException ;
44- import org .springframework .security .core .context .SecurityContextHolder ;
4542import org .springframework .security .web .authentication .AbstractAuthenticationProcessingFilter ;
4643import org .springframework .security .web .authentication .preauth .PreAuthenticatedAuthenticationToken ;
4744import org .springframework .security .web .authentication .session .SessionFixationProtectionStrategy ;
4845import org .springframework .security .web .context .HttpSessionSecurityContextRepository ;
49- import org .springframework .security .web .context .SecurityContextRepository ;
5046import org .springframework .security .web .servlet .util .matcher .PathPatternRequestMatcher ;
5147
5248import java .io .IOException ;
5349
5450public class WebEidAjaxLoginProcessingFilter extends AbstractAuthenticationProcessingFilter {
5551 private static final Logger LOG = LoggerFactory .getLogger (WebEidAjaxLoginProcessingFilter .class );
5652 private final ObjectReader OBJECT_READER = new ObjectMapper ().readerFor (WebEidAuthToken .class );
57- private final SecurityContextRepository securityContextRepository ;
5853
5954 public WebEidAjaxLoginProcessingFilter (
6055 String defaultFilterProcessesUrl ,
@@ -64,8 +59,8 @@ public WebEidAjaxLoginProcessingFilter(
6459 this .setAuthenticationManager (authenticationManager );
6560 this .setAuthenticationSuccessHandler (new AjaxAuthenticationSuccessHandler ());
6661 this .setAuthenticationFailureHandler (new AjaxAuthenticationFailureHandler ());
67- setSessionAuthenticationStrategy (new SessionFixationProtectionStrategy ());
68- this .securityContextRepository = new HttpSessionSecurityContextRepository ();
62+ this . setSessionAuthenticationStrategy (new SessionFixationProtectionStrategy ());
63+ this .setSecurityContextRepository ( new HttpSessionSecurityContextRepository () );
6964 }
7065
7166 @ Override
@@ -92,10 +87,4 @@ private WebEidAuthToken parseWebEidAuthToken(HttpServletRequest request) {
9287 throw new BadCredentialsException ("Unable to authenticate the Web eID authentication token" , e );
9388 }
9489 }
95-
96- @ Override
97- protected void successfulAuthentication (HttpServletRequest request , HttpServletResponse response , FilterChain chain , Authentication authResult ) throws IOException , ServletException {
98- super .successfulAuthentication (request , response , chain , authResult );
99- securityContextRepository .saveContext (SecurityContextHolder .getContext (), request , response );
100- }
10190}
0 commit comments