Package com.google.appengine.api.users

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


public class LoginCommand implements Command
{
  @Override
  public void execute(CommandContext context)
  {
    UserService userService = UserServiceFactory.getUserService();

    try
    {
      context.redirect(userService.createLoginURL(
          context.getRequest().getPathInfo().toString()));
    }

    catch (IllegalStateException e)
    {
View Full Code Here


public class LogoutCommand implements Command
{
  @Override
  public void execute(CommandContext context)
  {
    UserService userService = UserServiceFactory.getUserService();

    if (userService.isUserLoggedIn())
    {

      try
      {
        context.redirect(userService.createLogoutURL(
            context.getRequest().getRequestURI()));
      }

      catch (IllegalStateException e)
      {
View Full Code Here

        String appXmppAddress = "something@" + versionId + ".latest." +
            appId + ".appspotchat.com";
        req.setAttribute("appId", appId);
        req.setAttribute("appXmppAddress", appXmppAddress);

        UserService userService = UserServiceFactory.getUserService();
        User user = userService.getCurrentUser();
        req.setAttribute("user", user);
        req.setAttribute("signoutUrl", userService.createLogoutURL("/"));
        req.setAttribute("isUserAdmin", userService.isUserAdmin());

        DatastoreService datastore = DatastoreServiceFactory.getDatastoreService();
        Query q = new Query("ChatUser").addSort("jid");
        PreparedQuery pq = datastore.prepare(q);
        List<Entity> results = pq.asList(FetchOptions.Builder.withLimit(100));
View Full Code Here

    public void doPost(HttpServletRequest req,
                       HttpServletResponse resp)
        throws IOException, ServletException {

        UserService users = UserServiceFactory.getUserService();
        if (!users.isUserAdmin()) {
            log.info("Non-admin user " + users.getCurrentUser().getEmail() +
                     " attempted to access form handler");
            resp.sendError(404);
            return;
        }
View Full Code Here

@SuppressWarnings("serial")
public class PrefsServlet extends HttpServlet {
    public void doPost(HttpServletRequest req,
            HttpServletResponse resp)
          throws IOException {
        UserService userService = UserServiceFactory.getUserService();
        User user = userService.getCurrentUser();

        DatastoreService ds = DatastoreServiceFactory.getDatastoreService();
        Key userKey = KeyFactory.createKey("UserPrefs", user.getUserId());
        Entity userPrefs = new Entity(userKey);
View Full Code Here

                      HttpServletResponse resp)
        throws IOException {
        resp.setContentType("text/html");
        PrintWriter out = resp.getWriter();

        UserService userService = UserServiceFactory.getUserService();
        if (userService.isUserLoggedIn()) {
            User user = userService.getCurrentUser();
            out.println("<p>You are signed in as " + user.getNickname() + ". ");
            if (userService.isUserAdmin()) {
                out.println("You are an administrator. ");
            }
            out.println("<a href=\"" + userService.createLogoutURL("/") +
                        "\">Sign out</a>.</p>");
        } else {
            out.println("<p>You are not signed in to Google Accounts. " +
                        "<a href=\"" +
                        userService.createLoginURL(req.getRequestURI()) +
                        "\">Sign in</a>.</p>");
        }

        out.println("<ul>" +
                    "<li><a href=\"/\">/</a></li>" +
View Full Code Here

  @SuppressWarnings("unused")
  protected void doGet(HttpServletRequest request,
      HttpServletResponse response) throws ServletException, IOException {
    response.setContentType("text/html;charset=UTF-8");
    UserService userService = UserServiceFactory.getUserService();
    User user = userService.getCurrentUser();
    String path = ((HttpServletRequest) request).getRequestURI();
    String action = "";
    String[] splittedURI = path.split("/");
    // if length = 3, this is for action request.
    if (splittedURI.length == 4) {
View Full Code Here

  @SuppressWarnings("unused")
  @Override
  protected void doPost(HttpServletRequest req, HttpServletResponse resp)
      throws ServletException, IOException {
    resp.setContentType("text/html;charset=UTF-8");
    UserService userService = UserServiceFactory.getUserService();
    User user = userService.getCurrentUser();
    // if (user != null) {
    String action = req.getParameter("action");
    if (action.equalsIgnoreCase("create")) {
      Category cate = new Category();
      if (req.getParameter("title") != null) {
View Full Code Here

  @SuppressWarnings("unused")
  protected void doGet(HttpServletRequest request,
      HttpServletResponse response) throws ServletException, IOException {
    response.setContentType("text/html;charset=UTF-8");
    UserService userService = UserServiceFactory.getUserService();
    User user = userService.getCurrentUser();
    String path = ((HttpServletRequest) request).getRequestURI();
    String action = "";
    String[] splittedURI = path.split("/");
    // if length = 3, this is for action request.
    if (splittedURI.length == 4) {
View Full Code Here

public class GuestbookServlet extends HttpServlet {
    @Override
    public void doGet(HttpServletRequest req, HttpServletResponse resp)
              throws IOException {
        UserService userService = UserServiceFactory.getUserService();
        User user = userService.getCurrentUser();

        if (user != null) {
            resp.setContentType("text/plain");
            resp.getWriter().println("Hello, " + user.getNickname());
        } else {
            resp.sendRedirect(userService.createLoginURL(req.getRequestURI()));
        }
    }
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.