List of usage examples for javax.servlet.http HttpSession getId
public String getId();
From source file:de.iew.sketchpad.controllers.SketchPadController.java
protected boolean setColorImpl(HttpServletRequest request, RgbColor color) { boolean webServiceResult = false; HttpSession session = request.getSession(false); if (session != null) { String sessionId = session.getId(); if (log.isDebugEnabled()) { log.debug("Session Id " + session.getId()); }//from www . j ava 2 s. c o m // @TODO addColor //this.sketchPadService.setColor(sessionId, color); } return webServiceResult; }
From source file:nl.ctrlaltdev.harbinger.evidence.Evidence.java
public Evidence(Evidence src, HttpServletRequest req) { this(src);/*from www. ja va 2 s . co m*/ this.ip = req.getRemoteAddr(); this.forwardedFor = req.getHeader("X-Forwarded-For"); HttpSession session = req.getSession(false); this.session = session == null ? null : session.getId(); this.url = req.getRequestURI(); }
From source file:com.huateng.ebank.framework.web.struts.BaseAction.java
public void setValue2DataBus(HttpServletRequest request, String databusId, String fieldId, String fieldValue) throws AppException { try {// w ww .j av a 2 s . co m if (fieldValue == null) fieldValue = ""; HttpSession session = null; session = request.getSession(); DataBus dataBus = CommonQueryDataBusMng.getDataBus(session.getId(), databusId, session); dataBus.setField(fieldId, fieldValue); } catch (AppException appEx) { throw new AppException(appEx.getModuleName(), appEx.getErrCd(), ErrorCodeUtil.convertErrorMessage(log, appEx), appEx); } catch (Exception ex) { throw new AppException(Module.SYSTEM_MODULE, Rescode.DEFAULT_RESCODE, ex); } }
From source file:aish.vaishno.facebookoauth.access.FaceBookHelper.java
@Produces(MediaType.APPLICATION_JSON) @GET//from w ww. j av a 2s . c o m @Path(value = "loginRedirectUrl") public String getLoginRedirectUrl() { HttpSession session = (HttpSession) FacesContext.getCurrentInstance().getExternalContext() .getSession(false); System.out.println("******* SESSION ID: " + session.getId()); String returnValue = "https://graph.facebook.com/oauth/authorize?client_id=" + APP_ID + "&redirect_uri=" + REDIRECT_URI + "&scope=email"; return returnValue; }
From source file:org.owasp.webgoat.controller.Start.java
/** * <p>checkWebSession.</p>//from w ww.j a v a2 s. c o m * * @param session a {@link javax.servlet.http.HttpSession} object. * @return a boolean. */ public boolean checkWebSession(HttpSession session) { Object o = session.getAttribute(WebSession.SESSION); if (o == null) { logger.error("No valid WebSession object found, has session timed out? [" + session.getId() + "]"); return false; } if (!(o instanceof WebSession)) { logger.error("Invalid WebSession object found, this is probably a bug! [" + o.getClass() + " | " + session.getId() + "]"); return false; } return true; }
From source file:com.evolveum.midpoint.web.application.AsyncWebProcessManagerImpl.java
private Key createProcessIdentifier(String processId) { RequestCycle rc = RequestCycle.get(); Request req = rc.getRequest(); HttpSession session = ((ServletWebRequest) req).getContainerRequest().getSession(); return new Key(session.getId(), processId); }
From source file:com.liusoft.dlog4j.upload.SecurityFCKUploadServlet.java
/** * ?/*from w w w . ja v a 2 s . c o m*/ */ protected void doPost(HttpServletRequest req, HttpServletResponse res) throws ServletException, IOException { //??????(??) SessionUserObject loginUser = UserLoginManager.getLoginUser(req, res, true); if (loginUser != null) { super.doPost(req, res);//post?? Integer errno = (Integer) req.getAttribute("errno"); if (errno != null && errno.intValue() == 0) { //? FckUploadFileBean fbean = new FckUploadFileBean(); try { Long fileSize = (Long) req.getAttribute("file.size"); Integer fileType = (Integer) req.getAttribute("file.type"); String savePath = (String) req.getAttribute("file.path"); String uriPath = (String) req.getAttribute("file.uri"); if (fileSize != null) fbean.setFileSize(fileSize.intValue()); if (fileType != null) fbean.setFileType(fileType.intValue()); fbean.setSavePath(savePath); fbean.setUri(uriPath); HttpSession ssn = req.getSession(true); //SESSION_ID??Cookie RequestUtils.setCookie(req, res, Globals.SESSION_ID_KEY_IN_COOKIE, ssn.getId(), -1); fbean.setSessionId(ssn.getId()); fbean.setUser(new UserBean(loginUser.getId())); fbean.setUploadTime(new Date()); FCKUploadFileDAO.createUploadFileItem(fbean); } catch (Exception e) { log.error("Writting upload file info failed.", e); } } return; } res.sendError(HttpServletResponse.SC_FORBIDDEN); }
From source file:grails.plugin.springsecurity.web.filter.DebugFilter.java
protected void invokeWithWrappedRequest(HttpServletRequest request, HttpServletResponse response, FilterChain filterChain) throws IOException, ServletException { request.setAttribute(ALREADY_FILTERED_ATTR_NAME, true); request = new HttpServletRequestWrapper(request) { @Override/*from www . j a va 2 s . c om*/ public HttpSession getSession() { boolean sessionExists = super.getSession(false) != null; HttpSession session = super.getSession(); if (!sessionExists) { log(true, "New HTTP session created: {}", session.getId()); } return session; } @Override public HttpSession getSession(boolean create) { return create ? getSession() : super.getSession(false); } }; try { filterChainProxy.doFilter(request, response, filterChain); } finally { request.removeAttribute(ALREADY_FILTERED_ATTR_NAME); } }
From source file:edu.harvard.i2b2.fhir.oauth2.ws.WebsiteFilter.java
@Override public void doFilter(ServletRequest request, ServletResponse response, FilterChain chain) throws IOException, ServletException { String url = ((HttpServletRequest) request).getRequestURI().toString(); String servletPath = ((HttpServletRequest) request).getServletPath(); logger.info("url:" + url); String query = ((HttpServletRequest) request).getQueryString(); if (query == null) query = ""; String fullUrl = url + "?" + query; LogEntry le = new LogEntry(); HttpSession session = ((HttpServletRequest) request).getSession(); le.setUrl(fullUrl);//from w ww. ja va 2s .c o m le.setDateAccessed(new Date()); le.setSessionId(session.getId()); String accessToken = "-"; String clientId = "-"; if (session.getAttribute("accessToken") != null) { accessToken = ((AccessToken) session.getAttribute("accessToken")).getTokenString(); clientId = ((AccessToken) session.getAttribute("accessToken")).getClientId(); } le.setAccessToken(accessToken); le.setClientId(clientId); le.setUserId(-1); if ((servletPath.startsWith("/user") //|| servletPath.startsWith("/config") || servletPath.startsWith("/client"))) { Object u = ((HttpServletRequest) request).getSession().getAttribute("authenticatedUser"); if (u == null) { logger.info("User is not authenticated. Hence redirecting to login page"); HttpServletResponse httpServletResponse = (HttpServletResponse) response; httpServletResponse.sendRedirect("../login/signin.xhtml"); } if (u != null) { le.setUserId(User.class.cast(u).getId()); } } logEntryService.create(le); chain.doFilter(new PublicClientWrapper((HttpServletRequest) request), response); }
From source file:it.govpay.web.filters.SessionTimeoutFilter.java
@Override public void doFilter(ServletRequest request, ServletResponse response, FilterChain filterChain) throws IOException, ServletException { if ((request instanceof HttpServletRequest) && (response instanceof HttpServletResponse)) { HttpServletRequest httpServletRequest = (HttpServletRequest) request; // HttpServletResponse httpServletResponse = (HttpServletResponse) response; String requestPath = httpServletRequest.getRequestURI(); this.log.debug("Richiesta risorsa: " + requestPath); String principal = null;//from ww w.j a v a 2 s . c om if (httpServletRequest.getUserPrincipal() != null) { principal = httpServletRequest.getUserPrincipal().getName(); } this.log.debug("Utente: " + principal); // is session expire control required for this request? if (this.isSessionControlRequiredForThisResource(httpServletRequest)) { HttpSession sessione = httpServletRequest.getSession(false); this.log.debug("Session: " + (sessione != null ? sessione.getId() : "Null")); // is session invalid? if (this.isSessionInvalid(httpServletRequest)) { //String redirPageUrl = httpServletRequest.getContextPath() + "/"; if (sessione != null) sessione.invalidate(); this.log.debug("La sessione non e' valida, effettuo redirect..."); //se la pagina richiesta e' quella di login allora redirigo direttamente a quella, altrimenti a quella di timeout //redirPageUrl += StringUtils.contains(httpServletRequest.getRequestURI(), getLoginPage()) ? getLoginPage() : getTimeoutPage(); // redirPageUrl += getRedirPage(httpServletRequest); // log.info("session is invalid! redirecting to page : " + redirPageUrl); //httpServletResponse.sendRedirect(redirPageUrl); //return; } } } filterChain.doFilter(request, response); }