Package com.google.appengine.api.users

Examples of com.google.appengine.api.users.UserService


   * @throws IOException
   */
  @RequestMapping(value = "/disconnect.*", method = RequestMethod.GET)
  public String deconnexion(HttpServletRequest req, HttpServletResponse resp)
      throws IOException {
    UserService userService = UserServiceFactory.getUserService();

    resp.addCookie(new Cookie("username", null));

    resp.sendRedirect(userService.createLogoutURL("/index.htm"));

    return null;

  }
View Full Code Here


  @RequestMapping(value = "/account.*", method = RequestMethod.GET)
  public ModelAndView account(HttpServletRequest req, HttpServletResponse resp)
      throws IOException {

    ModelAndView mav = new ModelAndView("page/account");
    UserService userService = UserServiceFactory.getUserService();
    User googleUser = userService.getCurrentUser();

    if (googleUser == null) {
      resp.sendRedirect(userService.createLoginURL("/account.htm"));
      return null;
    }

    resp.addCookie(new Cookie("username", googleUser.getEmail()));
   
View Full Code Here

  @RequestMapping(value = "/ajax/unsubscribe.*", method = RequestMethod.GET)
  public void ajaxUnsubscribe(HttpServletRequest req,
      HttpServletResponse resp, long id) throws Exception {
    System.out.println(id);

    UserService userService = UserServiceFactory.getUserService();
    User user = userService.getCurrentUser();

    if (user != null) {

      UserManager serv = new UserManager();
      serv.removeUserSubscription(user.getEmail(), id);
View Full Code Here

   
    email = req.getParameter("jid");
   
    if (email == null){
   
      UserService userService = UserServiceFactory.getUserService();
      User user = userService.getCurrentUser();
     
      if (user != null) {
        email = user.getEmail();
        method = "gtalk";
      } else {
        //redirection
        resp.sendRedirect(userService.createLoginURL("/inviteme.htm"));
        return null;
      }
    } else {
      method = "jabber";
    }
View Full Code Here

   * @TODO: make this alot better.
   */
  @SuppressWarnings("unchecked")
  public void doGet(HttpServletRequest req, HttpServletResponse resp)
       throws IOException {
  UserService userService = UserServiceFactory.getUserService();
    if (userService.getCurrentUser() != null) {
      if (userService.isUserAdmin()) {
      String user = userService.getCurrentUser().getEmail();
      if (req.getParameter("action") != null) {
        String action = req.getParameter("action");
        if (action.equalsIgnoreCase("flushTokens")) {
          PersistenceManager pm = PMF.get().getPersistenceManager();
          try {
View Full Code Here

  /**
   * Retrieves a new, unsaved, document.
   */
  @Override
  public DocumentServiceEntry getNewDocument() {
    UserService userService = UserServiceFactory.getUserService();
    DocumentServiceEntry doc = new DocumentServiceEntry();
    doc.setTitle("Untitled Document");
    doc.setIdentifier(doc.getTitle().replaceAll("[^a-zA-Z0-9_\\-\\.]", ""));
    doc.setAuthor(userService.getCurrentUser().getEmail());
    doc.setEditor(userService.getCurrentUser().getNickname());
    return doc;
  }
View Full Code Here

  /**
   * Retrieves the currently signed on user.
   */
  @Override
  public DocumentUser getUser() {
    UserService userService = UserServiceFactory.getUserService();
    User user = userService.getCurrentUser();
    if (user != null){
      String email = user.getEmail();
      AuthenticationToken at = AuthenticationToken.getUserToken(email);
      if (at != null) {
        DocumentUser docUser = new DocumentUser();
View Full Code Here

          AuthSubUtil.revokeToken(token.getToken(), AuthenticationKey.getAuthSubKey());
      } catch (Exception x) {
        x.printStackTrace();
      }
        AuthenticationToken.clearUserToken(token.getEmail());
        UserService userService = UserServiceFactory.getUserService();
        URI url = new URI(this.getThreadLocalRequest().getRequestURL().toString());
        return userService.createLogoutURL("http://" + url.getAuthority() + LOGOUT_RETURN_RELATIVE_PATH);
      } catch (Exception e) {
        e.printStackTrace();
        throw new DocumentServiceException(e.getMessage());
      }
    }
View Full Code Here

   * The current user is authenticated if:
   * 1. The user has logged in via the Google User service.
   * 2. The user has a valid AuthSub token in the data store.
   */
  public boolean isAuthenticated() {
    UserService userService = UserServiceFactory.getUserService();
    if (userService.getCurrentUser() != null) {
      String userEmail = userService.getCurrentUser().getEmail();
      AuthenticationToken authToken = store.getUserToken(userEmail);
      if (authToken != null) {
        return true;
      }
    }
View Full Code Here

   * @throws AuthenticationException
   * @throws Base64DecoderException
   */
  public AuthenticationToken autoPilot(HttpServletRequest req, HttpServletResponse resp, boolean passive)
      throws IOException, AuthenticationException, GeneralSecurityException, Base64DecoderException {
    UserService userService = UserServiceFactory.getUserService();
    if (userService.getCurrentUser() != null) {
      String userEmail = userService.getCurrentUser().getEmail();
      AuthenticationToken authToken = store.getUserToken(userEmail);
      //check token age and clear if token is too old
      if (authToken != null && authToken.isExpired()) {
      try {
        AuthSubUtil.revokeToken(authToken.getToken(), key);
      } catch (Exception x) { }
      store.clearUserToken(authToken.getEmail());
      authToken = null;
      }
      //check token validity to ensure that the token is still valid
      if (authToken != null) {
      try {
        Map<String, String> info = AuthSubUtil.getTokenInfo(authToken.getToken(), key);
        if (info == null || info.size() == 0) {
        store.clearUserToken(authToken.getEmail());
        authToken = null;
        }
      } catch (Exception x) {
        store.clearUserToken(authToken.getEmail());
        authToken = null;
      }
      }
      if (authToken != null) {
      authToken.setActivity(new Date());
        return authToken;
      } else {
        String token = null, qs = req.getQueryString();
        if (qs != null) {
          token = AuthSubUtil.getTokenFromReply(qs);
        }
        if (token != null && !token.equals("")) {
          token = URLDecoder.decode(token, "UTF-8");
          token = AuthSubUtil.exchangeForSessionToken(token, key);
          store.setUserToken(req.getUserPrincipal().getName(), token);
          resp.sendRedirect(getFullUrl(req));
        } else {
          if (!passive) {
            String authUrl = AuthSubUtil.getRequestUrl(
                getFullUrl(req),
                DocumentServiceImpl.AUTH_SCOPES, true, true);
            resp.sendRedirect(authUrl);
          }
        }
      }
    } else {
      if (!passive) {
        String authUrl = userService.createLoginURL(getFullUrl(req));
        resp.sendRedirect(authUrl);
      }
    }
    return null;
  }
View Full Code Here

TOP

Related Classes of com.google.appengine.api.users.UserService

Copyright © 2018 www.massapicom. 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.