// switch between both authroization methods simply replace retrieving a AuthManager
// instance with the getOauthManager method for the getAuthSubManager method. This can be
// done by uncommenting the code below. There is a similar change that must occur in the
// MainServlet class.
AuthManager authManager = AuthManagerFactory.getAuthSubManager();
//AuthManager authManager = AuthManagerFactory.getOauthManager();
String nextUrl = "";
if (request.getParameter(authManager.getTokenParam()) != null) {
// The user is being redirected back from google.com to exchange the AuthSub one time
// use token for a session token.
authManager.storeAuthorizedToken(request.getQueryString());
nextUrl = MainServlet.MAIN_URL;
} else if (request.getParameter("action") != null) {
if (request.getParameter("action").equals("revoke")) {
// The user is revoking their token.
authManager.revokeToken();
nextUrl = MainServlet.MAIN_URL;
} else if (request.getParameter("action").equals("authorize")) {
// The user is starting the AuthSub authorization process.
nextUrl = authManager.getAuthorizationRedirectUrl(request.getRequestURL());
}
}
GoogleData googleData = authManager.getGoogleData();
if (googleData.getAuthorizationErrorMessage() != null) {
// Forward users to the authorization page.
request.setAttribute("googleData", googleData);
ServletContext sc = getServletContext();