當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。