List of usage examples for org.springframework.security.core.session SessionInformation isExpired
public boolean isExpired()
From source file:com.yqboots.security.web.controller.SessionController.java
@PreAuthorize(SecurityPermissions.SESSION_DELETE) @RequestMapping(params = { WebKeys.ID, WebKeys.ACTION_DELETE }, method = RequestMethod.GET) public String delete(@RequestParam final String id, final ModelMap model) { final SessionInformation sessionInformation = sessionRegistry.getSessionInformation(id); if (!sessionInformation.isExpired()) { sessionInformation.expireNow();//from w ww. ja v a 2 s . c o m } model.clear(); return REDIRECT_VIEW_PATH; }
From source file:com.kuprowski.redis.security.core.session.RedisSessionRegistry.java
@Override public List<SessionInformation> getAllSessions(Object principal, boolean includeExpiredSessions) { final Set<String> sessionsUsedByPrincipal = getSessionsUsedByPrincipal(principal); if (sessionsUsedByPrincipal == null) { return Collections.emptyList(); }// www .java 2s . c o m List<SessionInformation> list = new ArrayList<SessionInformation>(sessionsUsedByPrincipal.size()); for (String sessionId : sessionsUsedByPrincipal) { SessionInformation sessionInformation = getSessionInformation(sessionId); if (sessionInformation == null) { continue; } if (includeExpiredSessions || !sessionInformation.isExpired()) { list.add(sessionInformation); } } return list; }
From source file:com.artivisi.belajar.restful.ui.controller.HomepageController.java
@RequestMapping("/homepage/sessioninfo") @ResponseBody/*from w w w. jav a 2s . c om*/ public List<Map<String, String>> sessionInfo() { List<Map<String, String>> userAktif = new ArrayList<Map<String, String>>(); for (Object object : sessionRegistry.getAllPrincipals()) { List<SessionInformation> info = sessionRegistry.getAllSessions(object, true); for (SessionInformation i : info) { Object p = i.getPrincipal(); if (p != null && User.class.isAssignableFrom(p.getClass())) { Map<String, String> usermap = new HashMap<String, String>(); User u = (User) p; usermap.put("username", u.getUsername()); usermap.put("permission", u.getAuthorities().toString()); usermap.put("sessionid", i.getSessionId()); usermap.put("status", i.isExpired() ? "Expired" : "Aktif"); userAktif.add(usermap); } } } return userAktif; }
From source file:com.rr.wabshs.ui.users.userController.java
/** * The '/expireLoggedInUsers' request will display the list of users who are currently logged in.. * * @param request// ww w .j a v a 2 s .c om * @param response * @return the client engagement list view * @throws Exception */ @RequestMapping(value = "/expireLoggedInUsers", method = RequestMethod.GET) public ModelAndView listLoggedInUsers(HttpSession session) throws Exception { ModelAndView mav = new ModelAndView(); mav.setViewName("/expireLoggedInUsers"); List<loggedInUsers> loggedInUsers = new ArrayList<loggedInUsers>(); if (sessionRegistry.getAllPrincipals() != null) { for (Object principal : sessionRegistry.getAllPrincipals()) { loggedInUsers loggedInUser = new loggedInUsers(); UserDetails userDetails = (UserDetails) principal; for (SessionInformation information : sessionRegistry.getAllSessions(userDetails, true)) { if (!information.isExpired()) { loggedInUser.setUsername(userDetails.getUsername()); loggedInUsers.add(loggedInUser); } } } } mav.addObject("loggedInUsers", loggedInUsers); return mav; }
From source file:org.springframework.security.core.session.SessionRegistryImpl.java
public List<SessionInformation> getAllSessions(Object principal, boolean includeExpiredSessions) { final Set<String> sessionsUsedByPrincipal = principals.get(principal); if (sessionsUsedByPrincipal == null) { return Collections.emptyList(); }// w w w.j a v a2s.c om List<SessionInformation> list = new ArrayList<>(sessionsUsedByPrincipal.size()); for (String sessionId : sessionsUsedByPrincipal) { SessionInformation sessionInformation = getSessionInformation(sessionId); if (sessionInformation == null) { continue; } if (includeExpiredSessions || !sessionInformation.isExpired()) { list.add(sessionInformation); } } return list; }