3131import javax .servlet .*;
3232import javax .servlet .http .HttpServletRequest ;
3333import javax .servlet .http .HttpServletResponse ;
34- import java .io .IOException ;
3534
3635public class OidcAuthFilter implements Filter {
3736
@@ -41,14 +40,20 @@ public class OidcAuthFilter implements Filter {
4140 private final OidcClient <?> client ;
4241
4342 @ Inject
44- public OidcAuthFilter (@ Named ("oidc" ) Config config , OidcClient <?> client ) {
43+ public OidcAuthFilter (PluginConfiguration pluginConfig ,
44+ @ Named ("oidc" ) Config config ,
45+ OidcClient <?> client ) {
4546 this .config = config ;
4647 this .client = client ;
48+
49+ if (pluginConfig .isEnabled () && !client .isInitialized ()) {
50+ client .init ();
51+ }
4752 }
4853
4954 @ Override
5055 @ SuppressWarnings ("unchecked" )
51- public void doFilter (ServletRequest request , ServletResponse response , FilterChain chain ) throws IOException , ServletException {
56+ public void doFilter (ServletRequest request , ServletResponse response , FilterChain chain ) {
5257 HttpServletRequest req = (HttpServletRequest ) request ;
5358 HttpServletResponse resp = (HttpServletResponse ) response ;
5459
@@ -57,7 +62,8 @@ public void doFilter(ServletRequest request, ServletResponse response, FilterCha
5762 String redirectUrl = req .getParameter ("from" );
5863 context .getSessionStore ().set (context , Pac4jConstants .REQUESTED_URL , redirectUrl );
5964
60- RedirectionAction action = client .getRedirectionAction (context )
65+ RedirectionAction action = client .getRedirectionActionBuilder ()
66+ .getRedirectionAction (context )
6167 .orElseThrow (() -> new IllegalStateException ("Can't get a redirection action for the request" ));
6268
6369 config .getHttpActionAdapter ().adapt (action , context );
0 commit comments