Class AbstractFlowUserServlet
- java.lang.Object
-
- javax.servlet.GenericServlet
-
- javax.servlet.http.HttpServlet
-
- com.google.api.client.extensions.servlet.auth.AbstractFlowUserServlet
-
- All Implemented Interfaces:
java.io.Serializable,javax.servlet.Servlet,javax.servlet.ServletConfig
@Beta public abstract class AbstractFlowUserServlet extends javax.servlet.http.HttpServletBeta
Servlet that can be used to invoke and manage aThreeLeggedFlowobject 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:
- Serialized Form
-
-
Field Summary
Fields Modifier and Type Field Description private static java.lang.StringAUTH_CREDENTIALReserved request context identifier used to store the credential instance in an authorized servlet.private com.google.api.client.http.HttpTransporthttpTransportprivate com.google.api.client.json.JsonFactoryjsonFactoryprivate static longserialVersionUID
-
Constructor Summary
Constructors Constructor Description AbstractFlowUserServlet()
-
Method Summary
All Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description protected CredentialgetCredential(javax.servlet.http.HttpServletRequest req)Fetch a credential associated with this request.protected com.google.api.client.http.HttpTransportgetHttpTransport()Return theHttpTransportinstance for this servlet.protected com.google.api.client.json.JsonFactorygetJsonFactory()Return theJsonFactoryinstance for this servlet.protected abstract javax.jdo.PersistenceManagerFactorygetPersistenceManagerFactory()Obtain a PersistenceManagerFactory for working with the datastore.protected abstract java.lang.StringgetUserId()protected abstract ThreeLeggedFlownewFlow(java.lang.String userId)Create a flow object which will be used to obtain credentials.protected abstract com.google.api.client.http.HttpTransportnewHttpTransportInstance()Create a newHttpTransportinstance.protected abstract com.google.api.client.json.JsonFactorynewJsonFactoryInstance()Create a newJsonFactoryinstance.protected voidservice(javax.servlet.http.HttpServletRequest req, javax.servlet.http.HttpServletResponse resp)private voidstartAuthFlow(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
-
-
-
-
Field Detail
-
serialVersionUID
private static final long serialVersionUID
- See Also:
- Constant Field Values
-
httpTransport
private final com.google.api.client.http.HttpTransport httpTransport
-
jsonFactory
private final com.google.api.client.json.JsonFactory jsonFactory
-
AUTH_CREDENTIAL
private static final java.lang.String AUTH_CREDENTIAL
Reserved request context identifier used to store the credential instance in an authorized servlet.- See Also:
- Constant Field Values
-
-
Method Detail
-
service
protected void service(javax.servlet.http.HttpServletRequest req, javax.servlet.http.HttpServletResponse resp) throws java.io.IOException, javax.servlet.ServletException- Overrides:
servicein classjavax.servlet.http.HttpServlet- Throws:
java.io.IOExceptionjavax.servlet.ServletException
-
startAuthFlow
private void startAuthFlow(javax.servlet.http.HttpServletResponse resp, javax.jdo.PersistenceManager pm, ThreeLeggedFlow oauthFlow) throws java.io.IOExceptionStart the auth flow. Don't run any code after this method that will change the response object.- Throws:
java.io.IOException
-
getCredential
protected Credential getCredential(javax.servlet.http.HttpServletRequest req)
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 theJsonFactoryinstance for this servlet.
-
getHttpTransport
protected final com.google.api.client.http.HttpTransport getHttpTransport()
Return theHttpTransportinstance for this servlet.
-
getPersistenceManagerFactory
protected abstract javax.jdo.PersistenceManagerFactory getPersistenceManagerFactory()
Obtain a PersistenceManagerFactory for working with the datastore.- Returns:
- PersistenceManagerFactory instance.
-
newFlow
protected abstract ThreeLeggedFlow newFlow(java.lang.String userId) throws java.io.IOException
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:
java.io.IOException
-
newHttpTransportInstance
protected abstract com.google.api.client.http.HttpTransport newHttpTransportInstance()
Create a newHttpTransportinstance. Implementations can create any type of applicable transport and should be as simple as:new NetHttpTransport();
- Returns:
HttpTransportinstance for your particular environment
-
newJsonFactoryInstance
protected abstract com.google.api.client.json.JsonFactory newJsonFactoryInstance()
Create a newJsonFactoryinstance. Implementations can create any type of applicable json factory and should be as simple as:new JacksonFactory();
- Returns:
JsonFactoryinstance for your particular environment
-
getUserId
protected abstract java.lang.String getUserId()
- Returns:
- Get a string representation of a userId that can be used to associate credentials and flows with a specific user.
-
-