Package com.google.appengine.api.users

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


import com.googlecode.objectify.Objectify;

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);
View Full Code Here


  private static final long serialVersionUID = 1L;
  @Inject Objectify ofy;

  @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

  private static final long serialVersionUID = 1L;
  @Inject Objectify ofy;

  @Override
  protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
    UserService userService = UserServiceFactory.getUserService();
    String thisURL = req.getRequestURI();
    if (req.getUserPrincipal() != null) {
      resp.sendRedirect("home");
    } else {
      resp.getWriter().println("<p>Please <a href=\"" + userService.createLoginURL(thisURL) +
          "\">sign in</a>.</p>");
    }
  }
View Full Code Here

public class ProbeController {

  @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");
          }
        } else {
          resp.sendRedirect(userService.createLoginURL(req.getRequestURI()));
        }

    ModelAndView mav = new ModelAndView("probe/index");

    int nbusers = UserPresence.listUsers().size();
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

  @Override
  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);


    //Identify where the rules are stored
    RuleSource ruleSource = new RuleSource();
    ruleSource.setKnowledgeBaseLocation(knowledgeBaseFile);
    log.info("Using knowledgeBaseFile"+knowledgeBaseFile);

    if ((user != null)&&(knowledgeBaseFile!=null)&&!knowledgeBaseFile.equals("")&&(excelFile!=null)&&!excelFile.equals("")) {

      resp.setContentType("application/vnd.ms-excel");
      resp.setHeader("Content-Disposition",
      "attachment; filename=result.xls");

      //Check the RUL
      RedSecurityManager.checkUrl(knowledgeBaseFile);
      RedSecurityManager.checkUrl(excelFile);

      log.info("Using Excel File"+excelFile);


      URL url = new URL(excelFile);

      HSSFWorkbook wb;
      try {
        wb = commonSpreadsheetUtils.callRules(url,ruleSource, RedConstants.EXCEL_LOG_WORKSHEET_NAME);




        SpreadSheetOutputter.outputToStream(wb, resp.getOutputStream());
      } catch (Exception e) {

        log.warning(e.getMessage());
        throw new ServletException(e);
      }

    } else {

      resp.sendRedirect(userService.createLoginURL(req.getRequestURI()));
    }
  }
View Full Code Here

  @Override
  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);
    ruleSource.setKnowledgeBaseLocation(KNOWLEDGE_BASE_FILE);

    if (user != null) {

      resp.setContentType("application/vnd.ms-excel");
      resp.setHeader("Content-Disposition",
      "attachment; filename=result.xls");

      //Get the URL
      URL url = new URL(EXCEL_DATA_FILE);

      HSSFWorkbook wb;
      try {
        wb = commonSpreadsheetUtils.callRules(url,ruleSource, getExcelLogWorksheetName());

        SpreadSheetOutputter.outputToStream(wb, resp.getOutputStream());
      } catch (Exception e) {

        log.warning(e.getMessage());
        throw new ServletException(e);
      }

    } else {

      resp.sendRedirect(userService.createLoginURL(req.getRequestURI()));
    }
  }
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;
    }

    // redirection page d'accueil
    return "redirect:/account.htm";
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.