Class CallbackServlet
- All Implemented Interfaces:
Servlet,ServletConfig,Serializable
A Configuration instance must have been added as a ServletContext attribute under the name Configuration.CONTEXT_ATTRIBUTE_NAME.
If a HTTPRequestSender instance has been added as ServletContext attribute under the name Utils.HTTP_REQUEST_SENDER_CONTEXT_ATTRIBUTE_NAME, it'll be used to send requests to the OpenID
Provider.
Authentication state must have been put in the session by an AuthenticationRedirector (generally through the LoginServlet or an
authorization filter).
After validating the request, and if authentication was successful, the user will be redirected to the page stored in the authentication state.
If a UserPrincipalFactory is available in the ServletContext, it'll be called to possibly load additional data to the session, that can later
be made available through the UserPrincipal.
- See Also:
-
Field Summary
Fields inherited from class jakarta.servlet.http.HttpServlet
LEGACY_DO_HEAD -
Constructor Summary
ConstructorsConstructorDescriptionCallbackServlet(Configuration configuration, UserPrincipalFactory userPrincipalFactory) Constructs a servlet with the given configuration andUserPrincipalfactory, and no HTTP request sender.CallbackServlet(Configuration configuration, UserPrincipalFactory userPrincipalFactory, @Nullable HTTPRequestSender httpRequestSender) Constructs a servlet with the given configuration andUserPrincipalfactory. -
Method Summary
Modifier and TypeMethodDescriptionprotected voiddoGet(HttpServletRequest req, HttpServletResponse resp) protected voiddoPost(HttpServletRequest req, HttpServletResponse resp) voidinit()protected voidsendError(HttpServletResponse resp, int statusCode, String message, @Nullable Throwable cause) Methods inherited from class jakarta.servlet.http.HttpServlet
doDelete, doHead, doOptions, doPut, doTrace, getLastModified, init, service, serviceMethods inherited from class jakarta.servlet.GenericServlet
destroy, getInitParameter, getInitParameterNames, getServletConfig, getServletContext, getServletInfo, getServletName, log, log
-
Constructor Details
-
CallbackServlet
public CallbackServlet() -
CallbackServlet
Constructs a servlet with the given configuration andUserPrincipalfactory, and no HTTP request sender.When this constructor is used, the servlet context attributes won't be read.
This is equivalent to
new CallbackServlet(configuration, userPrincipalFactory, null). -
CallbackServlet
public CallbackServlet(Configuration configuration, UserPrincipalFactory userPrincipalFactory, @Nullable HTTPRequestSender httpRequestSender) Constructs a servlet with the given configuration andUserPrincipalfactory.When this constructor is used, the servlet context attributes won't be read.
-
-
Method Details
-
init
- Overrides:
initin classGenericServlet- Throws:
ServletException
-
doGet
protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException - Overrides:
doGetin classHttpServlet- Throws:
ServletExceptionIOException
-
doPost
protected void doPost(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException - Overrides:
doPostin classHttpServlet- Throws:
ServletExceptionIOException
-
sendError
@ForOverride protected void sendError(HttpServletResponse resp, int statusCode, String message, @Nullable Throwable cause) throws IOException, ServletException - Throws:
IOExceptionServletException
-