List of usage examples for javax.servlet.http HttpServletRequest getRequestURI
public String getRequestURI();
From source file:com.music.web.util.RequestBlockingFilter.java
@Override public void doFilter(ServletRequest req, ServletResponse res, FilterChain chain) throws IOException, ServletException { HttpServletRequest request = (HttpServletRequest) req; HttpServletResponse response = (HttpServletResponse) res; String uri = request.getRequestURI(); for (String ignored : IGNORED_RESOURCES) { if (uri.contains(ignored)) { response.setStatus(HttpServletResponse.SC_NOT_FOUND); return; }/*from w ww . j a va 2s. co m*/ } String userAgent = request.getHeader("User-Agent"); // allow no user agent set, for restful calls if (!StringUtils.isEmpty(userAgent) && blockedAgents.contains(userAgent)) { response.setStatus(HttpServletResponse.SC_NOT_FOUND); return; } chain.doFilter(request, response); }
From source file:com.redhat.rhn.frontend.security.BaseAuthenticationService.java
protected boolean requestRestrictedWhitelist(final HttpServletRequest request) { return CollectionUtils.exists(getRestrictedWhitelistURIs(), new Predicate() { public boolean evaluate(Object uri) { return request.getRequestURI().startsWith(uri.toString()); }// ww w .j a va 2 s.co m }); }
From source file:de.punyco.thirtytwosquare.auth.GoogleAppEngineAuthenticationEntryPoint.java
@Override public void commence(HttpServletRequest request, HttpServletResponse response, AuthenticationException authException) throws IOException, ServletException { String loginURL = userService.createLoginURL(request.getRequestURI()); if (LOG.isDebugEnabled()) { LOG.debug("Redirecting to login URL '{}'", loginURL); }// w w w . j a va2 s . co m response.sendRedirect(loginURL); }
From source file:protocolo.config.AuthenticationInterceptor.java
@Override public boolean preHandle(HttpServletRequest request, HttpServletResponse response, Object o) throws Exception { if (request.getSession().getAttribute("usuario_logado") == null) { String uri = request.getRequestURI(); if (uri.endsWith("/Protocolo.uneb") || uri.endsWith("create-protocol") || uri.endsWith("/loginForm") || uri.endsWith("/login") || uri.endsWith("/add") || uri.endsWith("/search")) { return true; } else {/*from ww w .j a v a2 s . c om*/ response.sendRedirect("/Protocolo.uneb/loginForm"); return false; } } else { User user = (User) request.getSession().getAttribute("usuario_logado"); if (user.getType() == UserType.ADMIN) { String uri = request.getRequestURI(); if (uri.endsWith("/loginForm") || uri.endsWith("/login") || uri.endsWith("/menu")) { response.sendRedirect("/Protocolo.uneb/config"); return false; } else { return true; } } else { String uri = request.getRequestURI(); if (uri.endsWith("/loginForm") || uri.endsWith("/login")) { response.sendRedirect("/Protocolo.uneb/menu"); return false; } else { return true; } } } }
From source file:com.dianping.phoenix.router.ResponseFilter.java
@Override public void doFilter(ServletRequest request, ServletResponse response, FilterChain chain) throws IOException, ServletException { if (response instanceof HttpServletResponse && request instanceof HttpServletRequest) { HttpServletRequest hRequest = (HttpServletRequest) request; if (StringUtils.equalsIgnoreCase(SCRIPT_NAME, hRequest.getRequestURI())) { IOUtils.copy(this.getClass().getResourceAsStream(SCRIPT_NAME), response.getOutputStream()); return; }//from w w w .j a v a 2 s .c o m StatusAwareServletResponse statusAwareServletResponse = new StatusAwareServletResponse( (HttpServletResponse) response); chain.doFilter(request, statusAwareServletResponse); if (ACCEPTED_STATUS_CODE.contains(statusAwareServletResponse.getStatus()) && (StringUtils.isBlank(statusAwareServletResponse.getContentType()) || ACCEPTED_CONTENT_TYPE .contains(statusAwareServletResponse.getContentType().toLowerCase())) && hRequest.getHeader("x-requested-with") == null) { statusAwareServletResponse.getOutputStream().write(RESPONSE_APPEND_TEXT); } } else { chain.doFilter(request, response); } }
From source file:com.jaspersoft.jasperserver.api.security.externalAuth.cas.JSSoapProcessingFilter.java
protected boolean requiresAuthentication(HttpServletRequest request, HttpServletResponse response) { String uri = request.getRequestURI(); int pathParamIndex = uri.indexOf(';'); if (pathParamIndex > 0) { // strip everything after the first semi-colon uri = uri.substring(0, pathParamIndex); }/*w w w. j a v a2 s .co m*/ if ("".equals(request.getContextPath())) { return uri.endsWith(getFilterProcessesUrl()); } return uri.startsWith(request.getContextPath() + getFilterProcessesUrl()); }
From source file:com.surevine.alfresco.audit.listeners.UpdateWikiPageAuditEventListener.java
@Override public void setSpecificAuditMetadata(final Auditable auditable, final HttpServletRequest request, final JSONObject json, final BufferedHttpServletResponse response) { setMetadataFromNodeRef(auditable, nodeRefResolver.getNodeRef(request.getRequestURI())); }
From source file:com.thoughtworks.go.server.newsecurity.filters.helpers.ServerUnavailabilityResponse.java
private boolean requestIsOfType(String type, HttpServletRequest request) { String header = request.getHeader("Accept"); String contentType = request.getContentType(); String url = request.getRequestURI(); return header != null && header.contains(type) || url != null && url.endsWith(type) || contentType != null && contentType.contains(type); }
From source file:eu.trentorise.smartcampus.resourceprovider.filter.ResourceFilter.java
public String getFullURL(HttpServletRequest request) { String cp = request.getContextPath(); if (cp == null || cp.isEmpty()) { return request.getRequestURI(); }/*from ww w . j av a 2s.c om*/ return request.getRequestURI().substring(cp.length()); }
From source file:com.surevine.alfresco.audit.listeners.LockDocumentAuditEventListener.java
/** There are two possible sources for the action - the list view or the detailed view. * the presence of the string 'workspace/SpacesStore' suggests a noderef is present, otherwise the filename * is appended to the end of the URI./*from www . j av a2 s.co m*/ * @see com.surevine.alfresco.audit.listeners.PostAuditEventListener#setSpecificAuditMetadata(com.surevine.alfresco.audit.Auditable, javax.servlet.http.HttpServletRequest, org.json.JSONObject, com.surevine.alfresco.audit.BufferedHttpServletResponse) */ @Override public void setSpecificAuditMetadata(final Auditable auditable, final HttpServletRequest request, final JSONObject json, final BufferedHttpServletResponse response) throws JSONException { setMetadataFromNodeRef(auditable, nodeRefResolver.getNodeRef(request.getRequestURI())); }