Package org.latexlab.docs.server.auth

Source Code of org.latexlab.docs.server.auth.AuthenticationTokenStore

package org.latexlab.docs.server.auth;

import com.google.appengine.api.users.UserService;
import com.google.appengine.api.users.UserServiceFactory;

/**
* Exposes methods for storing and retrieving authentication tokens
* to and from the data store.
*/
public class AuthenticationTokenStore {

  /**
   * Clears a user's authentication token, by email.
   *
   * @param email the user's email
   */
  public void clearUserToken(String email) {
    AuthenticationToken.clearUserToken(email);
  }

  /**
   * Retrieves the authentication token for the currently logged on user.
   *
   * @return the authentication token for the currently logged on user
   */
  public AuthenticationToken getUserToken() {
    UserService userService = UserServiceFactory.getUserService();
    if (userService.getCurrentUser() != null) {
      String email = userService.getCurrentUser().getEmail();
      return AuthenticationToken.getUserToken(email);
    }
    return null;
  }
 
  /**
   * Retrieves a user's authentication token, by email.
   *
   * @param email the user's email
   * @return the user's authentication token
   */
  public AuthenticationToken getUserToken(String email) {
    return AuthenticationToken.getUserToken(email);
  }

  /**
   * Stores a user's authentication token.
   *
   * @param email the user's email
   * @param token the user's authentication token
   */
  public void setUserToken(String email, String token) {
    AuthenticationToken.storeUserToken(email, token);
  }

}
TOP

Related Classes of org.latexlab.docs.server.auth.AuthenticationTokenStore

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.