List of usage examples for javax.servlet.http HttpSession getId
public String getId();
From source file:com.liferay.portal.servlet.PortalSessionListener.java
public void sessionCreated(HttpSessionEvent event) { HttpSession ses = event.getSession(); PortalSessionContext.put(ses.getId(), ses); // Process session created events try {/* w w w . j av a 2 s . c om*/ EventsProcessor.process(PropsUtil.getArray(PropsUtil.SERVLET_SESSION_CREATE_EVENTS), ses); } catch (ActionException ae) { Logger.error(this, ae.getMessage(), ae); } }
From source file:edu.zipcloud.cloudstreetmarket.api.controllers.SessionController.java
@RequestMapping(value = "/current", method = GET) @ApiOperation(value = "Get the session Id of the current user") public String getCurrent(HttpServletRequest request) { HttpSession session = request.getSession(false); if (session != null) { return session.getId(); }/*from w w w. j a v a 2 s . c om*/ return ""; }
From source file:fi.okm.mpass.idp.authn.impl.AbstractSpringSocialOAuth2IdentityTest.java
protected MockHttpServletRequest initHttpRequestWithState() { MockHttpServletRequest httpRequest = Mockito.mock(MockHttpServletRequest.class); final String sessionId = "mockSessionId"; HttpSession httpSession = Mockito.mock(HttpSession.class); Mockito.when(httpSession.getId()).thenReturn(sessionId); Mockito.when(httpRequest.getSession()).thenReturn(httpSession); Mockito.when(httpRequest.getParameter("code")).thenReturn("mockCode"); Mockito.when(httpRequest.getParameter("state")) .thenReturn(AbstractSpringSocialOAuth2Identity.calculateHash(sessionId)); Mockito.when(httpRequest.getRequestURL()).thenReturn(new StringBuffer()); return httpRequest; }
From source file:edu.zipcloud.cloudstreetmarket.api.controllers.SessionController.java
@RequestMapping(value = "/{username}", method = GET) @ApiOperation(value = "Get the session Id of the current authenticated user") @PreAuthorize("isAuthenticated()") public String get(@ApiParam(value = "Username: johnd") @PathVariable(value = "username") String username, HttpServletRequest request, Principal principal) { if (principal == null || !principal.getName().equals(username)) { throw new AccessDeniedException("You must be authenticated as " + username + "!"); }//from w w w. ja va 2s. co m HttpSession session = request.getSession(false); if (session != null) { return session.getId(); } return ""; }
From source file:be.fedict.eid.applet.beta.SessionContextManagerBean.java
public SessionContextEntity getSessionContext() { HttpServletRequest httpServletRequest; try {//from ww w . j a v a2 s .c om httpServletRequest = (HttpServletRequest) PolicyContext .getContext("javax.servlet.http.HttpServletRequest"); } catch (PolicyContextException e) { throw new RuntimeException("JACC error: " + e.getMessage()); } HttpSession httpSession = httpServletRequest.getSession(); String httpSessionId = httpSession.getId(); SessionContextEntity sessionContextEntity = getSessionContextEntity(httpSessionId); return sessionContextEntity; }
From source file:net.big_oh.common.web.listener.request.ObservedHttpServletRequest.java
public ObservedHttpServletRequest(HttpServletRequest request) { super(request); httpMethod = request.getMethod();//from w w w . jav a2 s .com resourceRequested = request.getRequestURL().toString(); queryString = request.getQueryString(); contextName = request.getContextPath(); containerUserName = request.getRemoteUser(); HttpSession session = request.getSession(false); jSessionId = (session == null) ? null : session.getId(); }
From source file:ph.fingra.statisticsweb.controller.LoginLogoutController.java
@RequestMapping(value = "logout", method = RequestMethod.GET) public void logout(HttpSession session) { FingraphUser userDetails = (FingraphUser) session.getAttribute("userLoginInfo"); logger.debug("Welcome logout! {}, {}", session.getId(), userDetails.getUsername()); session.invalidate();/*from ww w . j a v a 2 s.c o m*/ }
From source file:gov.nih.nci.cabig.caaers.web.security.HttpSessionPurgeLogoutHandler.java
/** * This method will obtain the session clear the cache for that session. * * @param request//from w ww .ja v a 2 s . c o m * @param response * @param authentication */ public void logout(HttpServletRequest request, HttpServletResponse response, Authentication authentication) { try { HttpSession session = request.getSession(false); if (session != null) { String sessionId = session.getId(); Map map = applicationContext.getBeansOfType(AuthorizationDecisionCache.class, true, false); if (map != null) { for (Object cacheBean : map.values()) { ((AuthorizationDecisionCache) cacheBean).clear(sessionId); } } } } catch (Exception e) { //ignore if (logger.isDebugEnabled()) logger.debug("Ignore this error", e); } }
From source file:com.twinsoft.convertigo.engine.requesters.HttpSessionListener.java
public void valueUnbound(HttpSessionBindingEvent event) { try {/* www . j a va2 s.co m*/ Engine.logContext.debug("HTTP session stopping..."); HttpSession httpSession = event.getSession(); String httpSessionID = httpSession.getId(); if (Engine.theApp != null) Engine.theApp.contextManager.removeAll(httpSessionID); removeSession(httpSessionID); Engine.logContext.debug("HTTP session stopped [" + httpSessionID + "]"); } catch (Exception e) { Engine.logContext.error("Exception during unbinding HTTP session listener", e); } }
From source file:com.vportal.portal.events.SessionDestroyAction.java
public void run(HttpSession ses) throws ActionException { if (_log.isDebugEnabled()) { _log.debug(ses.getId()); }/*from w ww .ja v a 2s. co m*/ MethodKey methodkeyLiveSessions = new MethodKey("com.liferay.portal.util.WebAppPool", "get", String.class, String.class); Object[] argsLiveSessions = new Object[] { String.valueOf(MainServlet.DEFAULT_COMPANY_ID), PropsUtilExt.LIVE_SESSIONS }; int liveSessions = 0; try { liveSessions = Integer.parseInt(GetterUtil .get((String) PortalClassInvoker.invoke(false, methodkeyLiveSessions, argsLiveSessions), "0")); } catch (NumberFormatException e) { // TODO Auto-generated catch block e.printStackTrace(); } catch (Exception e) { // TODO Auto-generated catch block e.printStackTrace(); } if (liveSessions > 0) { liveSessions--; /*WebAppPool.put(String.valueOf(MainServlet.DEFAULT_COMPANY_ID), PropsUtilExt.LIVE_SESSIONS, String.valueOf(liveSessions));*/ MethodKey method = new MethodKey("com.liferay.portal.util.WebAppPool", "put", String.class, String.class, String.class); Object[] args = new Object[] { MainServlet.DEFAULT_COMPANY_ID, PropsUtilExt.LIVE_SESSIONS, String.valueOf(liveSessions) }; try { PortalClassInvoker.invoke(false, method, args); } catch (Exception e1) { // TODO Auto-generated catch block e1.printStackTrace(); } } }