Class AbstractFlowUserServlet
java.lang.Object
javax.servlet.GenericServlet
javax.servlet.http.HttpServlet
com.google.api.client.extensions.servlet.auth.AbstractFlowUserServlet
- All Implemented Interfaces:
Serializable
,javax.servlet.Servlet
,javax.servlet.ServletConfig
@Beta
public abstract class AbstractFlowUserServlet
extends javax.servlet.http.HttpServlet
Beta
Servlet that can be used to invoke and manage a
ThreeLeggedFlow
object in the App Engine
container. Developers should subclass this to provide the necessary information for their
specific use case.
Warning: starting with version 1.7, usage of this for OAuth 2.0 is deprecated. Instead use AbstractAuthorizationCodeServlet
.
- Since:
- 1.4
- See Also:
-
Field Summary
FieldsModifier and TypeFieldDescriptionprivate static final String
Reserved request context identifier used to store the credential instance in an authorized servlet.private final com.google.api.client.http.HttpTransport
private final com.google.api.client.json.JsonFactory
private static final long
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprotected Credential
getCredential
(javax.servlet.http.HttpServletRequest req) Fetch a credential associated with this request.protected final com.google.api.client.http.HttpTransport
Return theHttpTransport
instance for this servlet.protected final com.google.api.client.json.JsonFactory
Return theJsonFactory
instance for this servlet.protected abstract javax.jdo.PersistenceManagerFactory
Obtain a PersistenceManagerFactory for working with the datastore.protected abstract String
protected abstract ThreeLeggedFlow
Create a flow object which will be used to obtain credentials.protected abstract com.google.api.client.http.HttpTransport
Create a newHttpTransport
instance.protected abstract com.google.api.client.json.JsonFactory
Create a newJsonFactory
instance.protected void
service
(javax.servlet.http.HttpServletRequest req, javax.servlet.http.HttpServletResponse resp) private void
startAuthFlow
(javax.servlet.http.HttpServletResponse resp, javax.jdo.PersistenceManager pm, ThreeLeggedFlow oauthFlow) Start the auth flow.Methods inherited from class javax.servlet.http.HttpServlet
doDelete, doGet, doHead, doOptions, doPost, doPut, doTrace, getLastModified, service
Methods inherited from class javax.servlet.GenericServlet
destroy, getInitParameter, getInitParameterNames, getServletConfig, getServletContext, getServletInfo, getServletName, init, init, log, log
-
Field Details
-
serialVersionUID
private static final long serialVersionUID- See Also:
-
httpTransport
private final com.google.api.client.http.HttpTransport httpTransport -
jsonFactory
private final com.google.api.client.json.JsonFactory jsonFactory -
AUTH_CREDENTIAL
Reserved request context identifier used to store the credential instance in an authorized servlet.- See Also:
-
-
Constructor Details
-
AbstractFlowUserServlet
public AbstractFlowUserServlet()
-
-
Method Details
-
service
protected void service(javax.servlet.http.HttpServletRequest req, javax.servlet.http.HttpServletResponse resp) throws IOException, javax.servlet.ServletException - Overrides:
service
in classjavax.servlet.http.HttpServlet
- Throws:
IOException
javax.servlet.ServletException
-
startAuthFlow
private void startAuthFlow(javax.servlet.http.HttpServletResponse resp, javax.jdo.PersistenceManager pm, ThreeLeggedFlow oauthFlow) throws IOException Start the auth flow. Don't run any code after this method that will change the response object.- Throws:
IOException
-
getCredential
Fetch a credential associated with this request.- Parameters:
req
- Request object to use as context for fetching the credential.- Returns:
- Credential object for this request and user.
- Since:
- 1.5
-
getJsonFactory
protected final com.google.api.client.json.JsonFactory getJsonFactory()Return theJsonFactory
instance for this servlet. -
getHttpTransport
protected final com.google.api.client.http.HttpTransport getHttpTransport()Return theHttpTransport
instance for this servlet. -
getPersistenceManagerFactory
protected abstract javax.jdo.PersistenceManagerFactory getPersistenceManagerFactory()Obtain a PersistenceManagerFactory for working with the datastore.- Returns:
- PersistenceManagerFactory instance.
-
newFlow
Create a flow object which will be used to obtain credentials.- Parameters:
userId
- User id to be passed to the constructor of the flow object- Returns:
- Flow object used to obtain credentials
- Throws:
IOException
-
newHttpTransportInstance
protected abstract com.google.api.client.http.HttpTransport newHttpTransportInstance()Create a newHttpTransport
instance. Implementations can create any type of applicable transport and should be as simple as:new NetHttpTransport();
- Returns:
HttpTransport
instance for your particular environment
-
newJsonFactoryInstance
protected abstract com.google.api.client.json.JsonFactory newJsonFactoryInstance()Create a newJsonFactory
instance. Implementations can create any type of applicable json factory and should be as simple as:new JacksonFactory();
- Returns:
JsonFactory
instance for your particular environment
-
getUserId
- Returns:
- Get a string representation of a userId that can be used to associate credentials and flows with a specific user.
-