27
27
import eu .webeid .example .security .ajax .AjaxAuthenticationFailureHandler ;
28
28
import eu .webeid .example .security .ajax .AjaxAuthenticationSuccessHandler ;
29
29
import eu .webeid .security .authtoken .WebEidAuthToken ;
30
- import jakarta .servlet .FilterChain ;
31
- import jakarta .servlet .ServletException ;
32
30
import jakarta .servlet .http .HttpServletRequest ;
33
31
import jakarta .servlet .http .HttpServletResponse ;
34
32
import org .slf4j .Logger ;
41
39
import org .springframework .security .authentication .BadCredentialsException ;
42
40
import org .springframework .security .core .Authentication ;
43
41
import org .springframework .security .core .AuthenticationException ;
44
- import org .springframework .security .core .context .SecurityContextHolder ;
45
42
import org .springframework .security .web .authentication .AbstractAuthenticationProcessingFilter ;
46
43
import org .springframework .security .web .authentication .preauth .PreAuthenticatedAuthenticationToken ;
47
44
import org .springframework .security .web .authentication .session .SessionFixationProtectionStrategy ;
48
45
import org .springframework .security .web .context .HttpSessionSecurityContextRepository ;
49
- import org .springframework .security .web .context .SecurityContextRepository ;
50
46
import org .springframework .security .web .servlet .util .matcher .PathPatternRequestMatcher ;
51
47
52
48
import java .io .IOException ;
53
49
54
50
public class WebEidAjaxLoginProcessingFilter extends AbstractAuthenticationProcessingFilter {
55
51
private static final Logger LOG = LoggerFactory .getLogger (WebEidAjaxLoginProcessingFilter .class );
56
52
private final ObjectReader OBJECT_READER = new ObjectMapper ().readerFor (WebEidAuthToken .class );
57
- private final SecurityContextRepository securityContextRepository ;
58
53
59
54
public WebEidAjaxLoginProcessingFilter (
60
55
String defaultFilterProcessesUrl ,
@@ -64,8 +59,8 @@ public WebEidAjaxLoginProcessingFilter(
64
59
this .setAuthenticationManager (authenticationManager );
65
60
this .setAuthenticationSuccessHandler (new AjaxAuthenticationSuccessHandler ());
66
61
this .setAuthenticationFailureHandler (new AjaxAuthenticationFailureHandler ());
67
- setSessionAuthenticationStrategy (new SessionFixationProtectionStrategy ());
68
- this .securityContextRepository = new HttpSessionSecurityContextRepository ();
62
+ this . setSessionAuthenticationStrategy (new SessionFixationProtectionStrategy ());
63
+ this .setSecurityContextRepository ( new HttpSessionSecurityContextRepository () );
69
64
}
70
65
71
66
@ Override
@@ -92,10 +87,4 @@ private WebEidAuthToken parseWebEidAuthToken(HttpServletRequest request) {
92
87
throw new BadCredentialsException ("Unable to authenticate the Web eID authentication token" , e );
93
88
}
94
89
}
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
- }
101
90
}
0 commit comments