Package com.google.appengine.api.users

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


public class HomeServlet extends HttpServlet {
  @Override
  protected void doPost(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
    UserService userService = UserServiceFactory.getUserService();
    Principal p = req.getUserPrincipal();
    User u = userService.getCurrentUser();
    if (p != null) {
      WebdavUser wu = ofy.find(WebdavUser.class, u.getUserId());
      String username = req.getParameter("username");
      String password = req.getParameter("password");
      wu.setUsername(username);
      wu.setPassword(password);
      ofy.put(wu);
View Full Code Here


  @Override
  protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
    UserService userService = UserServiceFactory.getUserService();
    String thisURL = req.getRequestURI();
    Principal p = req.getUserPrincipal();
    User u = userService.getCurrentUser();
    if (p != null) {
      WebdavUser wu = ofy.find(WebdavUser.class, u.getUserId());
      if (wu == null) {
        wu = new WebdavUser();
        wu.setPassword((new RandPass(RandPass.NONCONFUSING_ALPHABET).getPass(6)));
        wu.setUserId(u.getUserId());
        wu.setUsername(u.getNickname());
        Key<WebdavUser> wuKey = ofy.put(wu);

        WebdavFolder root = new WebdavFolder();
        root.setParent(wuKey);
        ofy.put(root);
      }
     
      resp.getWriter().println(
          String.format(
          "<p>Hello, %s! You can log in to http://freewebdav.appspot.com/webdav/ as %s/%s" +
          "<br><br> You can <a href=\"%s\">sign out</a>.</p>",
          u.toString(),
          wu.getUsername(),
          wu.getPassword(),         
          userService.createLogoutURL(thisURL) ));
    } else {
      resp.sendRedirect("login");
View Full Code Here

  @RequestMapping(value = "/probe.htm", method = RequestMethod.GET)
  public ModelAndView index(HttpServletRequest req, HttpServletResponse resp) throws IOException {
   
       UserService userService = UserServiceFactory.getUserService();
       User user = userService.getCurrentUser();
 
        if (user != null ){
          if (!userService.isUserAdmin()) {
            resp.sendRedirect("/index.htm");
          }
View Full Code Here

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

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

    if (user == null) {
      resp.sendRedirect(userService.createLoginURL("/account.htm"));
      return 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

  @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 void service(HttpServletRequest req, HttpServletResponse resp)
  throws IOException, ServletException {


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

    String knowledgeBaseFile = req.getParameter(PARAM_KNOWLEDGE_BASE);
    String excelFile = req.getParameter(PARAM_EXCEL_DATA_FILE);
View Full Code Here

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


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

    //Identify where the rules are stored
    RuleSource ruleSource = new RuleSource();
    //ruleSource.setRulesLocation(RULES_FILES);
View Full Code Here

  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()));
   

    DataManager dm = DataManagerFactory.getInstance();
    PersistenceManager pm = dm.newPersistenceManager();

    // fetch user
    Query qUser = pm.newQuery(talkfeed.data.User.class);
    qUser.setFilter("id == param");
    qUser.declareParameters("String param");
    qUser.setUnique(true);
    qUser.setRange(0, 1);
    talkfeed.data.User talkfeedUser = (talkfeed.data.User) qUser
        .execute(TextTools.cleanJID(googleUser.getEmail()));

    mav.getModel().put("showInvitation", talkfeedUser == null);
    qUser.closeAll();

    List<Blog> blogs = new ArrayList<Blog>();
View Full Code Here

TOP

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

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.