16
16
17
17
package org .springframework .security .web .authentication .ott ;
18
18
19
- import java .io .IOException ;
20
-
21
- import jakarta .servlet .ServletException ;
22
- import jakarta .servlet .http .HttpServletRequest ;
23
- import jakarta .servlet .http .HttpServletResponse ;
24
-
25
- import org .springframework .security .authentication .BadCredentialsException ;
26
- import org .springframework .security .core .Authentication ;
27
- import org .springframework .security .core .AuthenticationException ;
28
19
import org .springframework .security .web .authentication .AbstractAuthenticationProcessingFilter ;
29
- import org .springframework .security .web .authentication .AuthenticationConverter ;
30
20
import org .springframework .security .web .util .matcher .AntPathRequestMatcher ;
31
- import org .springframework .util .Assert ;
32
21
33
22
/**
34
23
* Filter that processes a one-time token for log in.
@@ -43,31 +32,9 @@ public final class OneTimeTokenAuthenticationFilter extends AbstractAuthenticati
43
32
44
33
public static final String DEFAULT_LOGIN_PROCESSING_URL = "/login/ott" ;
45
34
46
- private AuthenticationConverter authenticationConverter = new OneTimeTokenAuthenticationConverter ();
47
-
48
35
public OneTimeTokenAuthenticationFilter () {
49
36
super (new AntPathRequestMatcher (DEFAULT_LOGIN_PROCESSING_URL , "POST" ));
50
- }
51
-
52
- @ Override
53
- public Authentication attemptAuthentication (HttpServletRequest request , HttpServletResponse response )
54
- throws AuthenticationException , IOException , ServletException {
55
- Authentication authentication = this .authenticationConverter .convert (request );
56
- if (authentication == null ) {
57
- throw new BadCredentialsException ("Unable to authenticate with the one-time token" );
58
- }
59
- return getAuthenticationManager ().authenticate (authentication );
60
- }
61
-
62
- /**
63
- * Use this {@link AuthenticationConverter} when converting incoming requests to an
64
- * {@link Authentication}. By default, the {@link OneTimeTokenAuthenticationConverter}
65
- * is used.
66
- * @param authenticationConverter the {@link AuthenticationConverter} to use
67
- */
68
- public void setAuthenticationConverter (AuthenticationConverter authenticationConverter ) {
69
- Assert .notNull (authenticationConverter , "authenticationConverter cannot be null" );
70
- this .authenticationConverter = authenticationConverter ;
37
+ setAuthenticationConverter (new OneTimeTokenAuthenticationConverter ());
71
38
}
72
39
73
40
}
0 commit comments