Package spanishgringo.logic

Source Code of spanishgringo.logic.AuthManagerFactory

// Copyright 2009 Google Inc. All Rights Reserved.

package spanishgringo.logic;

import spanishgringo.data.AuthorizationServiceAuthSubImpl;
import spanishgringo.data.AuthorizationServiceOauthImpl;
import spanishgringo.data.PMF;
import spanishgringo.data.TokenDaoJdoImpl;

import com.google.appengine.api.users.UserServiceFactory;
import com.google.gdata.client.authn.oauth.GoogleOAuthParameters;


/**
* Factory to create an AuthManager.
* @author api.nickm@google.com (Nick Mihailovski)
*/
public class AuthManagerFactory {

  /**
   * Constructor.
   */
  private AuthManagerFactory() {}

  /**
   * Returns an AuthManager object that implements AuthSub to get authentication tokens.
   * @return an AuthManager object to get authenticated tokens.
   */
  public static AuthManager getAuthSubManager() {
    return new AuthManager(
        UserServiceFactory.getUserService(),
        new AuthorizationServiceAuthSubImpl(
            GoogleDataManager.GOOGLE_DATA_SCOPE),
        new TokenDaoJdoImpl(PMF.getInstance()));
  }

  /**
   * Returns an AuthManager object that implements oAuth to get authentication tokens.
   * @return an AuthManager object to get authenticated tokens.
   */
  public static AuthManager getOauthManager() {
    return new AuthManager(
        UserServiceFactory.getUserService(),
        new AuthorizationServiceOauthImpl(
            GoogleDataManager.GOOGLE_DATA_SCOPE,
            new GoogleOAuthParameters()),
        new TokenDaoJdoImpl(PMF.getInstance()));
  }
}
TOP

Related Classes of spanishgringo.logic.AuthManagerFactory

TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.