List of usage examples for javax.servlet.http HttpServletRequest getRequestURL
public StringBuffer getRequestURL();
From source file:net.sf.ehcache.constructs.web.filter.SimplePageCachingFilterWithBlankPageProblem.java
/** * {@inheritDoc}/*from ww w . java2s.c o m*/ */ protected void doFilter(final HttpServletRequest request, final HttpServletResponse response, final FilterChain chain) throws Exception { PageInfo pageInfo = buildPageInfo(request, response, chain); if (response.isCommitted()) { if (LOG.isWarnEnabled()) { LOG.warn("Response cannot be written as it was already committed for " + request.getRequestURL()); } } else { writeResponse(request, response, pageInfo); } }
From source file:org.sakaiproject.imagegallery.integration.standalone.ImageStreamingController.java
/** * @see org.springframework.web.servlet.mvc.AbstractController#handleRequestInternal(javax.servlet.http.HttpServletRequest, javax.servlet.http.HttpServletResponse) *//*from w w w . j a va 2 s . com*/ @Override protected ModelAndView handleRequestInternal(HttpServletRequest request, HttpServletResponse response) throws Exception { if (log.isInfoEnabled()) log.info("req contextPath=" + request.getContextPath() + ", pathInfo=" + request.getPathInfo() + ", query=" + request.getQueryString() + ", URI=" + request.getRequestURI() + ", URL=" + request.getRequestURL() + ", servlet=" + request.getServletPath()); String fileId = request.getPathInfo().substring(1); ImageFile imageFile = fileLibraryService.getImageFile(fileId); response.setContentType(imageFile.getContentType()); FileStreamer fileStreamer = (FileStreamer) fileLibraryService; fileStreamer.streamImage(fileId, response.getOutputStream()); return null; }
From source file:com.versatus.jwebshield.filter.SessionCheckFilter.java
/** * @see Filter#doFilter(ServletRequest, ServletResponse, FilterChain) */// www. j a va2s . c om @Override public void doFilter(ServletRequest request, ServletResponse response, FilterChain chain) throws IOException, ServletException { HttpServletRequest httpReq = (HttpServletRequest) request; HttpServletResponse httpRes = (HttpServletResponse) response; String reqInfo = "J-WebShield Alert: Session check failed! request URL=" + httpReq.getRequestURL().toString() + "| from IP address=" + httpReq.getRemoteAddr(); logger.debug("doFilter: RequestURL=" + httpReq.getRequestURL().toString()); UrlExclusionList exclList = (UrlExclusionList) request.getServletContext() .getAttribute(SecurityConstant.SESSION_CHECK_URL_EXCL_LIST_ATTR_NAME); try { if (!exclList.isEmpty() && exclList.isMatch(httpReq.getRequestURI())) { logger.info("doFilter: request (" + httpReq.getRequestURL().toString() + " matches exclusion pattern, skipping session check"); chain.doFilter(request, response); return; } } catch (Exception e) { logger.error("doFilter", e); } HttpSession session = httpReq.getSession(false); logger.debug("doFilter: session=" + session); logger.debug("doFilter: session attr. " + attributeToCheck + "=" + (session != null ? session.getAttribute(attributeToCheck) : "")); if (session == null || session.getAttribute(attributeToCheck) == null) { if (send401) { // TODO this is not working for regular requests, only for WS // calls httpRes.setStatus(HttpServletResponse.SC_UNAUTHORIZED); } else { logger.info(reqInfo + " redirecting to " + redirectPage); RequestDispatcher rd = httpReq.getRequestDispatcher(redirectPage); if (rd != null) { rd.forward(request, response); } return; } } logger.info("doFilter: session check complete"); // pass the request along the filter chain chain.doFilter(request, response); }
From source file:com.googlesource.gerrit.plugins.github.oauth.OAuthWebFilter.java
@Override public void doFilter(ServletRequest request, ServletResponse response, FilterChain chain) throws IOException, ServletException { HttpServletRequest httpRequest = (HttpServletRequest) request; HttpServletResponse httpResponse = (HttpServletResponse) response; log.debug("OAuthWebFilter(" + httpRequest.getRequestURL() + ") code=" + request.getParameter("code")); Cookie gerritCookie = getGerritCookie(httpRequest); try {/*from w w w. ja v a 2 s . c om*/ GitHubLogin ghLogin = loginProvider.get(httpRequest); if (OAuthProtocol.isOAuthLogout(httpRequest)) { logout(request, response, chain, httpRequest); } else if (OAuthProtocol.isOAuthRequest(httpRequest) && !ghLogin.isLoggedIn()) { login(request, httpRequest, httpResponse, ghLogin); } else { if (ghLogin != null && ghLogin.isLoggedIn()) { httpRequest = new AuthenticatedHttpRequest(httpRequest, config.httpHeader, ghLogin.getMyself().getLogin(), config.oauthHttpHeader, GITHUB_EXT_ID + ghLogin.getToken().accessToken); } if (OAuthProtocol.isOAuthFinalForOthers(httpRequest)) { httpResponse.sendRedirect(OAuthProtocol.getTargetOAuthFinal(httpRequest)); } else { chain.doFilter(httpRequest, response); } } } finally { HttpSession httpSession = httpRequest.getSession(); if (gerritCookie != null && httpSession != null) { String gerritCookieValue = gerritCookie.getValue(); String gerritSessionValue = (String) httpSession.getAttribute("GerritAccount"); if (gerritSessionValue == null) { httpSession.setAttribute("GerritAccount", gerritCookieValue); } else if (!gerritSessionValue.equals(gerritCookieValue)) { httpSession.invalidate(); } } } }
From source file:fi.okm.mpass.idp.authn.impl.AbstractSpringSocialOAuthIdentity.java
/** * Returns redirect url for authentication. * * @param httpRequest/*from w w w . j a v a 2s. c o m*/ * the request * @return redirect url */ public String getRedirectUrl(HttpServletRequest httpRequest) { log.trace("Entering"); if (httpRequest == null) { log.trace("Leaving"); return null; } OAuthToken requestToken = oauthOperations.fetchRequestToken(httpRequest.getRequestURL().toString(), null); httpRequest.getSession().setAttribute("ext_auth_request_token", requestToken); String authorizeUrl = oauthOperations.buildAuthorizeUrl(requestToken.getValue(), OAuth1Parameters.NONE); log.trace("Leaving"); return authorizeUrl; }
From source file:io.kamax.mxisd.controller.DefaultExceptionHandler.java
private String handle(HttpServletRequest req, String erroCode, String error) { JsonObject obj = new JsonObject(); obj.addProperty("errcode", erroCode); obj.addProperty("error", error); obj.addProperty("success", false); log.info("Request {} {} - Error {}: {}", req.getMethod(), req.getRequestURL(), erroCode, error); return gson.toJson(obj); }
From source file:com.goodhuddle.huddle.web.HuddleFilter.java
@Override protected void doFilterInternal(HttpServletRequest request, HttpServletResponse response, FilterChain chain) throws ServletException, IOException { String huddleSlug = StringUtils.trimToNull(request.getHeader("huddle")); if (log.isTraceEnabled()) { log.trace("Processing request '{}' for Huddle with slug: '{}'", request.getRequestURL(), huddleSlug); }//from w ww .j a v a 2 s. c om if (!request.getRequestURI().startsWith("/_huddles")) { Huddle huddle; if (huddleSlug != null) { if (huddleSlug.endsWith(".goodhuddle.com")) { huddleSlug = huddleSlug.substring(0, huddleSlug.length() - ".goodhuddle.com".length()); } if (huddleSlug.startsWith("www.")) { huddleSlug = huddleSlug.substring("www.".length()); } huddle = huddleService.getHuddle(huddleSlug); } else { List<Huddle> huddles = huddleService.getHuddles(); if (huddles.size() == 1) { huddle = huddles.get(0); } else { huddle = null; } } huddleContext.setHuddle(huddle); } chain.doFilter(request, response); }
From source file:com.arvato.thoroughly.filter.AccessLogFilter.java
@Override public void doFilter(ServletRequest arg0, ServletResponse arg1, FilterChain chain) throws ServletException, IOException { ServletRequest requestWrapper = arg0; try {//from w ww .j a v a2 s. c om final HttpServletRequest request = (HttpServletRequest) arg0; final String username = request.getRemoteUser(); LOGGER.trace("Username : " + username); final String ip = HttpHelper.getIpAddress(request); LOGGER.trace("Client ip is : " + ip); final StringBuffer URL = request.getRequestURL(); LOGGER.trace("URL of the client request is : " + URL.toString()); requestWrapper = new FilterRequestWrapper(request); String body = IOUtils.toString(requestWrapper.getInputStream()); LOGGER.trace("Request body is : " + body); } catch (Exception e) { LOGGER.error("An error occurred inside AccessLogFilter:" + e.getMessage()); } chain.doFilter(requestWrapper, arg1); }
From source file:org.cagrid.identifiers.namingauthority.impl.NamingAuthorityService.java
/** * @see HttpServlet#doGet(HttpServletRequest request, HttpServletResponse * response)// w ww. j a v a 2 s . com */ protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { LOG.debug("getPathInfo[" + request.getPathInfo() + "]"); LOG.debug("getQueryString[" + request.getQueryString() + "]"); LOG.debug("getRequestURI[" + request.getRequestURI() + "]"); LOG.debug("getRequestURL[" + request.getRequestURL() + "]"); LOG.debug("getServerName[" + request.getServerName() + "]"); LOG.debug("getServerPort[" + request.getServerPort() + "]"); LOG.debug("getServletPath[" + request.getServletPath() + "]"); LOG.debug("User Identity[" + request.getAttribute(GSIConstants.GSI_USER_DN)); processor.process(request, response); }
From source file:de.betterform.agent.web.servlet.XFormsRepeater.java
private void processForm(HttpServletRequest request, HttpServletResponse response, HttpSession session) throws ServletException { String url = request.getRequestURL().toString(); ServletContext context = this.getServletContext(); if (request.getAttribute("XFormsInputStream") != null) { System.out.println("Request has an extra Stream!: "); System.out.println("Context: " + context.getServletContextName()); System.out.println("Original Request URL: " + request.getAttribute("betterform.base.url")); url = (String) request.getAttribute(WebProcessor.FORWARD_URL); }/*from ww w. j av a 2 s . c om*/ // XFormsSession xFormsSession = null; WebProcessor webProcessor = null; try { webProcessor = new FluxProcessor(); webProcessor.setRequest(request); webProcessor.setResponse(response); webProcessor.setHttpSession(session); webProcessor.setBaseURI(url); webProcessor.setContext(context); webProcessor.configure(); webProcessor.setXForms(); webProcessor.init(); webProcessor.handleRequest(); } catch (Exception e) { if (webProcessor != null) { // attempt to shutdown processor try { webProcessor.shutdown(); } catch (XFormsException xfe) { // LOG.error("Could not shutdown Processor: Error: " + xfe.getMessage() + " Cause: " + xfe.getCause()); } // store exception session.setAttribute("betterform.exception", e); request.setAttribute("betterform.exception", e); request.setAttribute("betterform.referer", request.getRequestURL().toString()); session.setAttribute("betterform.referer", request.getRequestURL().toString()); //remove session from XFormsSessionManager WebUtil.removeSession(webProcessor.getKey()); throw new ServletException(e); } } }