Package org.orgama.server.auth.service

Source Code of org.orgama.server.auth.service.GoogleAccountsTstAuthService

package org.orgama.server.auth.service;

import com.google.appengine.api.users.User;
import com.google.appengine.api.users.UserService;
import com.google.inject.Inject;
import com.google.inject.Provider;
import javax.servlet.http.HttpServletRequest;
import org.orgama.server.auth.source.GoogleAccountsAuthService;

/**
* Basically the same as the google accounts provider, but provides the user's
* email address as it's external user id.
* @author kguthrie
*/
public class GoogleAccountsTstAuthService
    extends GoogleAccountsAuthService {

  @Inject
  public GoogleAccountsTstAuthService(
      Provider<HttpServletRequest> requestProvider) {
    super(requestProvider);
  }

  /**
   * Returns null if the user is not logged in, but returns the email
   * address (of the account) if the user is logged in
   * @return
   */
  @Override
  public String getServiceSpecificUserId(String notUsed) {
   
    UserService userService = getUserService();
   
    if (!userService.isUserLoggedIn()) {
      return null;
    }
   
    String result = super.getServiceSpecificUserId(notUsed);
   
    if (result == null) {
      User user = userService.getCurrentUser();
   
      result = user.getEmail();
    }
   
    return result;
  }

}
TOP

Related Classes of org.orgama.server.auth.service.GoogleAccountsTstAuthService

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.