Class AuthenticationRedirector

java.lang.Object
net.ltgt.oidc.servlet.AuthenticationRedirector

public class AuthenticationRedirector extends Object
Responsible for redirecting to the OpenID Provider.

An instance of this class needs to be added as a ServletContext attribute under the name CONTEXT_ATTRIBUTE_NAME, to be used by the authorization filters or the LoginServlet.

See Also:
  • Field Details

    • CONTEXT_ATTRIBUTE_NAME

      public static final String CONTEXT_ATTRIBUTE_NAME
  • Constructor Details

    • AuthenticationRedirector

      public AuthenticationRedirector(Configuration configuration, String callbackPath)
  • Method Details

    • redirectToAuthenticationEndpoint

      public void redirectToAuthenticationEndpoint(HttpServletRequest req, HttpServletResponse res, String returnTo)
      Redirects to the OpenID Provider, returning to the given page when coming back.

      This is equivalent to redirectToAuthenticationEndpoint(req, res, returnTo, null).

    • redirectToAuthenticationEndpoint

      public void redirectToAuthenticationEndpoint(HttpServletRequest req, HttpServletResponse res, String returnTo, @Nullable Consumer<AuthenticationRequest.Builder> configureAuthenticationRequest)
      Redirects to the OpenID Provider, returning to the given page when coming back, and possibly configuring the authentication request further.

      The target page should be given as an absolute path (possibly with a query string), though a full URL would be accepted as long as it's the same origin. It will be saved in the session to be redirected to from the CallbackServlet.

    • configureAuthenticationRequest

      @ForOverride protected void configureAuthenticationRequest(AuthenticationRequest.Builder authenticationRequestBuilder)
      Called by redirectToAuthenticationEndpoint to configure the authentication request further.

      The configurator passed to redirectToAuthenticationEndpoint, if any, will be called before this method. Then redirectToAuthenticationEndpoint will finalize configuration after this method (possibly overwriting some properties) before redirecting.