当前位置: 首页>>代码示例>>Java>>正文


Java UserService.createLogoutURL方法代码示例

本文整理汇总了Java中com.google.appengine.api.users.UserService.createLogoutURL方法的典型用法代码示例。如果您正苦于以下问题:Java UserService.createLogoutURL方法的具体用法?Java UserService.createLogoutURL怎么用?Java UserService.createLogoutURL使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在com.google.appengine.api.users.UserService的用法示例。


在下文中一共展示了UserService.createLogoutURL方法的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: logout

import com.google.appengine.api.users.UserService; //导入方法依赖的package包/类
public Resolution logout() {
    Subject subject = SecurityUtils.getSubject();
    if(subject.isAuthenticated()) {
        logger.debug("User not authenticated, redirecting to GAE logout URL");
        UserService userService = UserServiceFactory.getUserService();
        Serializable userId = ShiroUtils.getUserId(SecurityUtils.getSubject());
        SecurityUtils.getSubject().logout();
        HttpSession session = context.getRequest().getSession(false);
        if (session != null) {
            session.invalidate();
        }

        String msg = ElementsThreadLocals.getText("user.disconnected");
        SessionMessages.addInfoMessage(msg);
        logger.info("User {} logout", userId);
        String logoutUrl = userService.createLogoutURL(context.getRequest().getContextPath() + "/");
        return new RedirectResolution(logoutUrl);
    } else {
        return new RedirectResolution("/");
    }
}
 
开发者ID:hongliangpan,项目名称:manydesigns.cn,代码行数:22,代码来源:GAELoginAction.java

示例2: doGet

import com.google.appengine.api.users.UserService; //导入方法依赖的package包/类
public void doGet(HttpServletRequest req, HttpServletResponse resp) throws
    IOException, ServletException {

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

  String authURL = userService.createLogoutURL("/");
  String uploadURL = blobstoreService.createUploadUrl("/post");

  req.setAttribute("uploadURL", uploadURL);
  req.setAttribute("authURL", authURL);
  req.setAttribute("user", user);

  RequestDispatcher dispatcher = 
    req.getRequestDispatcher("WEB-INF/templates/upload.jsp");
  dispatcher.forward(req, resp);
}
 
开发者ID:dougkoellmer,项目名称:swarm,代码行数:18,代码来源:Upload.java

示例3: logoutGoogle

import com.google.appengine.api.users.UserService; //导入方法依赖的package包/类
static void logoutGoogle(String redirectUrl, HttpServletResponse response) throws IOException {
    UserService service = UserServiceFactory.getUserService();
    User user = service.getCurrentUser();
    if (user != null) {
        String logoutUrl = service.createLogoutURL(redirectUrl);
        response.sendRedirect(logoutUrl);
    }
}
 
开发者ID:cilogi,项目名称:lid,代码行数:9,代码来源:LogoutServlet.java

示例4: printGaeProperties

import com.google.appengine.api.users.UserService; //导入方法依赖的package包/类
private void printGaeProperties(StringBuilder sb)
{
	sb.append("<h2>GAE Properties</h2>");
	Environment env = ApiProxy.getCurrentEnvironment();
	Iterator<Entry<String, Object>> iter = env.getAttributes().entrySet().iterator();
	sb.append("<table><tr><th>Name</th><th>Value</th></tr>");
	sb.append("<tr><td>").append("getAppId()").append("</td><td>").append(env.getAppId()).append("</td></tr>");
	sb.append("<tr><td>").append("getVersionId()").append("</td><td>").append(env.getVersionId()).append("</td></tr>");
	sb.append("<tr><td>").append("getModuleId()").append("</td><td>").append(env.getModuleId()).append("</td></tr>");
	sb.append("<tr><td>").append("getAuthDomain()").append("</td><td>").append(env.getAuthDomain()).append("</td></tr>");
	sb.append("<tr><td>").append("getEmail()").append("</td><td>").append(env.getEmail()).append("</td></tr>");

	UserService userService = UserServiceFactory.getUserService();
	boolean userLoggedIn = userService.isUserLoggedIn();
	sb.append("<tr><td>").append("isUserLoggedIn()").append("</td><td>").append(userLoggedIn).append("</td></tr>");
	if (userLoggedIn)
	{
		String logoutUrl = "Click <a href=\"" + userService.createLogoutURL(request.getRequestURI()) + "\">here</a> to Logout";
		sb.append("<tr><td>").append("createLogoutURL()").append("</td><td>").append(logoutUrl).append("</td></tr>");
	}
	else
	{
		String loginUrl = "Click <a href=\"" + userService.createLoginURL(request.getRequestURI()) + "\">here</a> to Login";
		sb.append("<tr><td>").append("createLoginURL()").append("</td><td>").append(loginUrl).append("</td></tr>");
	}

	while (iter.hasNext())
	{
		Entry<String, Object> entry = iter.next();
		String paramName = entry.getKey();
		String paramValue = entry.getValue().toString();
		sb.append("<tr><td>").append(paramName).append("</td><td>").append(paramValue).append("</td></tr>");
	}
	sb.append("</table>");
}
 
开发者ID:zach-m,项目名称:gae-jersey-guice-jsf,代码行数:36,代码来源:InfoAPI.java

示例5: doGet

import com.google.appengine.api.users.UserService; //导入方法依赖的package包/类
public void doGet(HttpServletRequest req, HttpServletResponse res) throws IOException {
  res.setContentType("text/html");
  res.getWriter().println("<html>");
  res.getWriter().println("<head>");
  res.getWriter().println("<title>whoami</title>");
  res.getWriter().println("</head>");
  res.getWriter().println("<body>");

  UserService userService = UserServiceFactory.getUserService();

  if (userService.isUserLoggedIn()) {
    User user = userService.getCurrentUser();

    res.getWriter().println("<h1>You are " + user.getNickname() + ".</h1>");

    if (userService.isUserAdmin()) {
      res.getWriter().println("<h2>You are an admin! :)</h2>");
    } else {
      res.getWriter().println("<h2>You are not an admin... :(</h2>");
    }

    res.getWriter().println("<h1>Your user ID is " + user.getUserId() + ".</h1>");
  } else {
    res.getWriter().println("<h1>You are not logged in.</h1>");
  }

  String destURL = "/whoami";
  String loginURL = userService.createLoginURL(destURL);
  String logoutURL = userService.createLogoutURL(destURL);

  res.getWriter().println("<br>");
  res.getWriter().println("<a href=\"" + loginURL + "\">login</a>");
  res.getWriter().println("<br>");
  res.getWriter().println("<a href=\"" + logoutURL + "\">logout</a>");
  res.getWriter().println("</body>");
  res.getWriter().println("</html>");
}
 
开发者ID:GoogleCloudPlatform,项目名称:appengine-java-vm-runtime,代码行数:38,代码来源:LoginServlet.java

示例6: getUserInfo

import com.google.appengine.api.users.UserService; //导入方法依赖的package包/类
public UserInfoResult getUserInfo() throws AccessDeniedException {
  final UserService userService = UserServiceFactory.getUserService();
  final User user = tryGetCurrentUser(userService);
  final Store.Api api = store.getApi();
  try {
    final Key surfaceKey = getSurfaceKeys(api, user).get(0);
    final UserInfoResult result = new Service.UserInfoResult(new Author(user
        .getEmail(), user.getNickname()), getSurface(api, surfaceKey),
        userService.createLogoutURL(userService.createLoginURL("/")));
    return result;
  } finally {
    api.close();
  }
}
 
开发者ID:dougkoellmer,项目名称:swarm,代码行数:15,代码来源:ServiceImpl.java

示例7: doGet

import com.google.appengine.api.users.UserService; //导入方法依赖的package包/类
public void doGet(HttpServletRequest req, HttpServletResponse resp) throws
    IOException, ServletException {

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

  String authURL = (user != null) ? userService.createLogoutURL("/")
    : userService.createLoginURL("/");

  PersistenceManager pm = PMF.get().getPersistenceManager();
  
  Query query = pm.newQuery(MediaObject.class, "owner == userParam");
  query.declareImports("import com.google.appengine.api.users.User");
  query.declareParameters("User userParam");

  List<MediaObject> results = (List<MediaObject>) query.execute(user);

  String[] errors = req.getParameterValues("error");
  if (errors == null) errors = new String[0];

  req.setAttribute("errors", errors);
  req.setAttribute("files", results);
  req.setAttribute("authURL", authURL);
  req.setAttribute("user", user);
  RequestDispatcher dispatcher =
    req.getRequestDispatcher("WEB-INF/templates/main.jsp");
  dispatcher.forward(req, resp);
}
 
开发者ID:dougkoellmer,项目名称:swarm,代码行数:29,代码来源:Index.java

示例8: getLogoutLink

import com.google.appengine.api.users.UserService; //导入方法依赖的package包/类
public final String getLogoutLink() {
    final String returnUrl = getUrl();
    final UserService userService = UserServiceFactory.getUserService();
    return userService.createLogoutURL(returnUrl);
}
 
开发者ID:MattHeard,项目名称:Dendrite,代码行数:6,代码来源:View.java

示例9: doGet

import com.google.appengine.api.users.UserService; //导入方法依赖的package包/类
public void doGet(HttpServletRequest req, HttpServletResponse resp)
    throws IOException, ServletException {

  String blobKeyString = req.getParameter("key");
  if (blobKeyString == null || blobKeyString.equals("")) {
    resp.sendRedirect("/?error=" + 
      URLEncoder.encode("BlobKey not provided", "UTF-8"));
    return;
  }

  BlobKey blobKey = new BlobKey(blobKeyString);
  PersistenceManager pm = PMF.get().getPersistenceManager();

  Query query = pm.newQuery(MediaObject.class, "blob == blobParam");
  query.declareImports("import " +
    "com.google.appengine.api.blobstore.BlobKey");
  query.declareParameters("BlobKey blobParam");

  List<MediaObject> results = (List<MediaObject>) query.execute(blobKey);
  if (results.isEmpty()) {
    resp.sendRedirect("/?error=" +
      URLEncoder.encode("BlobKey does not exist", "UTF-8"));
    return;
  }

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

  MediaObject result = results.get(0);
  if (!result.isPublic() && !result.getOwner().equals(user)) {
    resp.sendRedirect("/?error=" +
      URLEncoder.encode("Not authorized to access", "UTF-8"));
    return;
  }

  String rotation = req.getParameter("rotate");
  String displayURL = result.getURLPath() + "&rotate=" + rotation;
  String authURL = (user != null) ?
    userService.createLogoutURL("/") : userService.createLoginURL("/");

  req.setAttribute("displayURL", displayURL);
  req.setAttribute("authURL", authURL);
  req.setAttribute("user", user);
  req.setAttribute("rotation", rotation);
  req.setAttribute("item", result);
  req.setAttribute("blobkey", blobKeyString);

  RequestDispatcher dispatcher =
    req.getRequestDispatcher("WEB-INF/templates/display.jsp");
  dispatcher.forward(req, resp);
}
 
开发者ID:dougkoellmer,项目名称:swarm,代码行数:52,代码来源:Display.java

示例10: get

import com.google.appengine.api.users.UserService; //导入方法依赖的package包/类
public static UserServiceInfo get(String path) {
  UserService userService = UserServiceFactory.getUserService();
  return new UserServiceInfo(userService.getCurrentUser(), userService.createLoginURL(path),
      userService.createLogoutURL(path));
}
 
开发者ID:googlearchive,项目名称:appengine-angular-guestbook-java,代码行数:6,代码来源:UserServiceInfo.java


注:本文中的com.google.appengine.api.users.UserService.createLogoutURL方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。