List of usage examples for javax.servlet.http HttpServletRequest getSession
public HttpSession getSession();
From source file:com.adito.vfs.webdav.DAVServlet.java
/** * Get the {@link DAVProcessor} from the requests session. * /*from www. ja va 2 s. com*/ * @param req request * @return processor * @throws CoreException on any error * @throws Exception on any error */ public static DAVProcessor getDAVProcessor(HttpServletRequest req) throws CoreException, Exception { return getDAVProcessor(req.getSession()); }
From source file:com.adito.networkplaces.NetworkPlaceResourceType.java
private static SessionInfo getSessionInfo(HttpServletRequest request) { return (SessionInfo) request.getSession().getAttribute(Constants.SESSION_INFO); }
From source file:eu.eidas.node.utils.EidasNodeErrorUtil.java
private static String getErrorReportingUrl(final HttpServletRequest request, IEIDASSession eidasSession) { Object spUrl = request.getSession().getAttribute(EIDASParameters.SP_URL.toString()); Object errorUrl = eidasSession == null ? null : eidasSession.get(EIDASParameters.ERROR_REDIRECT_URL.toString()); Object errorInterceptorUrl = eidasSession == null ? null : eidasSession.get(EIDASParameters.ERROR_INTERCEPTOR_URL.toString()); if (errorUrl != null) { spUrl = errorUrl;/*from w w w .ja va 2 s . co m*/ } if (errorInterceptorUrl != null) { request.setAttribute("redirectUrl", spUrl); spUrl = errorInterceptorUrl; } return spUrl == null ? null : spUrl.toString(); }
From source file:com.jdon.strutsutil.FormBeanUtil.java
/** * ?attributeActionForm/*from w ww . j ava2 s . c o m*/ * * @param mapping * @param request */ public static void removeActionForm(ActionMapping mapping, HttpServletRequest request) { if (mapping.getAttribute() != null) { if ("request".equals(mapping.getScope())) request.removeAttribute(mapping.getAttribute()); else { HttpSession session = request.getSession(); session.removeAttribute(mapping.getAttribute()); request.removeAttribute(mapping.getAttribute()); } } }
From source file:edu.stanford.muse.webapp.Sessions.java
public static Pair<Boolean, String> exportArchive(HttpServletRequest request) throws Exception { HttpSession session = request.getSession(); Archive archive = JSPHelper.getArchive(session); String title = request.getParameter("title"); String base_dir = System.getProperty("user.home") + java.io.File.separator + "muse." + title; String session_name = "default"; boolean succeeded = false; String message = ""; Collection<EmailDocument> emailDocs = (Collection<EmailDocument>) JSPHelper.getSessionAttribute(session, "emailDocs"); if (emailDocs != null) { boolean trimArchive = request.getParameter("trimArchive") != null; boolean forPublicMode = request.getParameter("forPublicMode") != null; /* UNDESIRABLE as this will permanently change the index. if (trimArchive) {//from w ww . j ava2 s . c o m archive.trimArchive(emailDocs); // fine if its null, nothing will be done (shouldn't happen) } */ String dir = archive.export(trimArchive ? emailDocs : archive.getAllDocs(), forPublicMode ? true : false, base_dir, session_name); // TODO: may choose to invalidate session here since the state of archive has already changed succeeded = dir != null; if (!succeeded) message = "Archive export failed"; else message = "Archive successfully exported to " + dir; } else { message = "No messages in this session"; } return new Pair<Boolean, String>(succeeded, message); }
From source file:be.fedict.eid.idp.webapp.ProtocolEntryServlet.java
public static String getProtocolServiceContextPath(HttpServletRequest request) { HttpSession httpSession = request.getSession(); return (String) httpSession.getAttribute(CONTEXT_PATH_SESSION_ATTRIBUTE); }
From source file:com.adito.core.actions.AbstractMultiFormDispatchAction.java
private static ActionForm getActionForm(ActionMapping subMapping, HttpServletRequest request) { String formName = subMapping.getName(); if ("request".equals(subMapping.getScope())) return (ActionForm) request.getAttribute(formName); else//from w w w.j a v a 2 s. c o m return (ActionForm) request.getSession().getAttribute(formName); }
From source file:com.ofbizcn.securityext.login.LoginEvents.java
public static void setUsername(HttpServletRequest request, HttpServletResponse response) { HttpSession session = request.getSession(); Delegator delegator = (Delegator) request.getAttribute("delegator"); String domain = EntityUtilProperties.getPropertyValue("url.properties", "cookie.domain", delegator); // first try to get the username from the cookie synchronized (session) { if (UtilValidate.isEmpty(getUsername(request))) { // create the cookie and send it back Cookie cookie = new Cookie(usernameCookieName, request.getParameter("USERNAME")); cookie.setMaxAge(60 * 60 * 24 * 365); cookie.setPath("/"); cookie.setDomain(domain);/* www .ja v a 2s. c om*/ response.addCookie(cookie); } } }
From source file:de.metas.ui.web.login.LoginRestController.java
private static MSession createMSession(final Login loginService) { final HttpServletRequest httpRequest = ((ServletRequestAttributes) RequestContextHolder .currentRequestAttributes()).getRequest(); final HttpSession httpSess = httpRequest.getSession(); final String webSessionId = httpSess.getId(); ///*from w w w . ja v a2 s. co m*/ // final WebBrowser webBrowser = Page.getCurrent().getWebBrowser(); String remoteAddr = httpRequest.getRemoteAddr(); String remoteHost = httpRequest.getRemoteHost(); // // Check if we are behind proxy and if yes, get the actual client IP address // NOTE: when configuring apache, don't forget to activate reverse-proxy mode // see http://www.xinotes.org/notes/note/770/ final String forwardedFor = httpRequest.getHeader("X-Forwarded-For"); if (!Check.isEmpty(forwardedFor)) { remoteAddr = forwardedFor; remoteHost = forwardedFor; } final LoginContext ctx = loginService.getCtx(); final MSession sessionPO = MSession.get(ctx.getSessionContext(), remoteAddr, remoteHost, webSessionId); // Set HostKey // FIXME: commented out because this one is not working when running over websockets (i.e. HttpServletResponse does not exists) // see https://dev.vaadin.com/ticket/11808 // @formatter:off // final I_AD_Session session = InterfaceWrapperHelper.create(sessionPO, I_AD_Session.class); // HttpCookieHostKeyStorage.createUpdateHostKey(); // final String hostKey = hostKeyBL.getHostKey(); // session.setHostKey(hostKey); // InterfaceWrapperHelper.save(session); // @formatter:on // Update Login helper loginService.setRemoteAddr(remoteAddr); loginService.setRemoteHost(remoteHost); loginService.setWebSession(webSessionId); return sessionPO; }
From source file:com.adito.security.AbstractHTTPAuthenticationModule.java
/** * @param request/*w w w . j av a 2 s . c om*/ * @param response * @param realm * @throws IOException */ public static void sendAuthorizationError(HttpServletRequest request, HttpServletResponse response, String realm) throws IOException { if (log.isInfoEnabled()) log.info("Sending auth request for realm " + realm); response.setHeader("WWW-Authenticate", "Basic realm=\"" + realm + "\""); response.sendError(HttpServletResponse.SC_UNAUTHORIZED); request.getSession().setAttribute(Constants.AUTH_SENT, Boolean.TRUE); }