Class OAuthEnabledSlingServlet
java.lang.Object
javax.servlet.GenericServlet
org.apache.sling.api.servlets.SlingSafeMethodsServlet
org.apache.sling.api.servlets.SlingAllMethodsServlet
org.apache.sling.auth.oauth_client.support.OAuthEnabledSlingServlet
- All Implemented Interfaces:
Serializable
,javax.servlet.Servlet
,javax.servlet.ServletConfig
public abstract class OAuthEnabledSlingServlet
extends org.apache.sling.api.servlets.SlingAllMethodsServlet
Support class for implementing OAuth-enabled servlets
Features:
- Handles OAuth token retrieval and refresh
- Starts the authentication flow if no token is available
- Handles invalid access tokens (
isInvalidAccessTokenException(Exception)
)
- See Also:
-
Constructor Summary
ConstructorsModifierConstructorDescriptionprotected
OAuthEnabledSlingServlet
(ClientConnection connection, OAuthTokenAccess tokenAccess) -
Method Summary
Modifier and TypeMethodDescriptionprotected void
doDelete
(@NotNull org.apache.sling.api.SlingHttpServletRequest request, @NotNull org.apache.sling.api.SlingHttpServletResponse response) protected void
doDeleteWithToken
(@NotNull org.apache.sling.api.SlingHttpServletRequest request, @NotNull org.apache.sling.api.SlingHttpServletResponse response, String accessToken) protected void
doGeneric
(@NotNull org.apache.sling.api.SlingHttpServletRequest request, @NotNull org.apache.sling.api.SlingHttpServletResponse response) protected void
doGenericWithToken
(@NotNull org.apache.sling.api.SlingHttpServletRequest request, @NotNull org.apache.sling.api.SlingHttpServletResponse response, String accessToken) protected void
doGet
(@NotNull org.apache.sling.api.SlingHttpServletRequest request, @NotNull org.apache.sling.api.SlingHttpServletResponse response) protected void
doGetWithToken
(@NotNull org.apache.sling.api.SlingHttpServletRequest request, @NotNull org.apache.sling.api.SlingHttpServletResponse response, String accessToken) protected void
doPost
(@NotNull org.apache.sling.api.SlingHttpServletRequest request, @NotNull org.apache.sling.api.SlingHttpServletResponse response) protected void
doPostWithToken
(@NotNull org.apache.sling.api.SlingHttpServletRequest request, @NotNull org.apache.sling.api.SlingHttpServletResponse response, String accessToken) protected void
doPut
(@NotNull org.apache.sling.api.SlingHttpServletRequest request, @NotNull org.apache.sling.api.SlingHttpServletResponse response) protected void
doPutWithToken
(@NotNull org.apache.sling.api.SlingHttpServletRequest request, @NotNull org.apache.sling.api.SlingHttpServletResponse response, String accessToken) protected @NotNull String
getRedirectPath
(@NotNull org.apache.sling.api.SlingHttpServletRequest request) protected boolean
Methods inherited from class org.apache.sling.api.servlets.SlingAllMethodsServlet
getAllowedRequestMethods, isMethodValid, mayService
Methods inherited from class org.apache.sling.api.servlets.SlingSafeMethodsServlet
doHead, doOptions, doTrace, getServletInfo, handleMethodNotImplemented, service, service
Methods inherited from class javax.servlet.GenericServlet
destroy, getInitParameter, getInitParameterNames, getServletConfig, getServletContext, getServletName, init, init, log, log
-
Constructor Details
-
OAuthEnabledSlingServlet
-
-
Method Details
-
doGet
protected void doGet(@NotNull @NotNull org.apache.sling.api.SlingHttpServletRequest request, @NotNull @NotNull org.apache.sling.api.SlingHttpServletResponse response) throws javax.servlet.ServletException, IOException - Overrides:
doGet
in classorg.apache.sling.api.servlets.SlingSafeMethodsServlet
- Throws:
javax.servlet.ServletException
IOException
-
doPost
protected void doPost(@NotNull @NotNull org.apache.sling.api.SlingHttpServletRequest request, @NotNull @NotNull org.apache.sling.api.SlingHttpServletResponse response) throws javax.servlet.ServletException, IOException - Overrides:
doPost
in classorg.apache.sling.api.servlets.SlingAllMethodsServlet
- Throws:
javax.servlet.ServletException
IOException
-
doDelete
protected void doDelete(@NotNull @NotNull org.apache.sling.api.SlingHttpServletRequest request, @NotNull @NotNull org.apache.sling.api.SlingHttpServletResponse response) throws javax.servlet.ServletException, IOException - Overrides:
doDelete
in classorg.apache.sling.api.servlets.SlingAllMethodsServlet
- Throws:
javax.servlet.ServletException
IOException
-
doPut
protected void doPut(@NotNull @NotNull org.apache.sling.api.SlingHttpServletRequest request, @NotNull @NotNull org.apache.sling.api.SlingHttpServletResponse response) throws javax.servlet.ServletException, IOException - Overrides:
doPut
in classorg.apache.sling.api.servlets.SlingAllMethodsServlet
- Throws:
javax.servlet.ServletException
IOException
-
doGeneric
protected void doGeneric(@NotNull @NotNull org.apache.sling.api.SlingHttpServletRequest request, @NotNull @NotNull org.apache.sling.api.SlingHttpServletResponse response) throws javax.servlet.ServletException, IOException - Overrides:
doGeneric
in classorg.apache.sling.api.servlets.SlingSafeMethodsServlet
- Throws:
javax.servlet.ServletException
IOException
-
getRedirectPath
@NotNull protected @NotNull String getRedirectPath(@NotNull @NotNull org.apache.sling.api.SlingHttpServletRequest request) -
doGetWithToken
protected void doGetWithToken(@NotNull @NotNull org.apache.sling.api.SlingHttpServletRequest request, @NotNull @NotNull org.apache.sling.api.SlingHttpServletResponse response, String accessToken) throws IOException, javax.servlet.ServletException - Throws:
IOException
javax.servlet.ServletException
-
doPostWithToken
protected void doPostWithToken(@NotNull @NotNull org.apache.sling.api.SlingHttpServletRequest request, @NotNull @NotNull org.apache.sling.api.SlingHttpServletResponse response, String accessToken) throws IOException, javax.servlet.ServletException - Throws:
IOException
javax.servlet.ServletException
-
doPutWithToken
protected void doPutWithToken(@NotNull @NotNull org.apache.sling.api.SlingHttpServletRequest request, @NotNull @NotNull org.apache.sling.api.SlingHttpServletResponse response, String accessToken) throws IOException, javax.servlet.ServletException - Throws:
IOException
javax.servlet.ServletException
-
doDeleteWithToken
protected void doDeleteWithToken(@NotNull @NotNull org.apache.sling.api.SlingHttpServletRequest request, @NotNull @NotNull org.apache.sling.api.SlingHttpServletResponse response, String accessToken) throws IOException, javax.servlet.ServletException - Throws:
IOException
javax.servlet.ServletException
-
doGenericWithToken
protected void doGenericWithToken(@NotNull @NotNull org.apache.sling.api.SlingHttpServletRequest request, @NotNull @NotNull org.apache.sling.api.SlingHttpServletResponse response, String accessToken) throws IOException, javax.servlet.ServletException - Throws:
IOException
javax.servlet.ServletException
-
isInvalidAccessTokenException
-