List of usage examples for javax.servlet.http HttpServletRequest getMethod
public String getMethod();
From source file:io.lavagna.web.security.login.PersonaLogin.java
@Override public boolean handleLogout(HttpServletRequest req, HttpServletResponse resp) throws IOException, ServletException { if ("POST".equalsIgnoreCase(req.getMethod())) { UserSession.invalidate(req, resp, userRepository); resp.setStatus(HttpServletResponse.SC_OK); resp.setContentType("application/json"); JsonObject jsonObject = new JsonObject(); jsonObject.add("redirectToSelf", new JsonPrimitive(true)); resp.getWriter().write(jsonObject.toString()); } else {/* w ww . j a va 2s . c o m*/ req.getRequestDispatcher(logoutPage).forward(req, resp); } return true; }
From source file:jp.or.openid.eiwg.scim.servlet.ResourceTypes.java
/** * ?/*from ww w. j a va 2s . c o m*/ * * @param request * @param response ? * @throws ServletException * @throws IOException */ protected void service(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { String method = request.getMethod(); if (method.equals("GET")) { doGet(request, response); } else { errorResponse(response, HttpServletResponse.SC_FORBIDDEN, null, MessageConstants.ERROR_NOT_SUPPORT_OPERATION); } }
From source file:com.thoughtworks.go.server.web.IgnoreResolver.java
private boolean isHttpMethod(HttpServletRequest request, String targetingMethod) { String method = (String) request.getAttribute("_method"); return StringUtils.isNotEmpty(method) ? method.equalsIgnoreCase(targetingMethod) : request.getMethod().equalsIgnoreCase(targetingMethod); }
From source file:com.xst.bigwhite.BigwhiteApplication.java
@Bean FilterRegistrationBean corsFilter(@Value("${tagit.origin:http://localhost:8080}") String origin) { return new FilterRegistrationBean(new Filter() { public void doFilter(ServletRequest req, ServletResponse res, FilterChain chain) throws IOException, ServletException { HttpServletRequest request = (HttpServletRequest) req; HttpServletResponse response = (HttpServletResponse) res; String method = request.getMethod(); // this origin value could just as easily have come from a // database response.setHeader("Access-Control-Allow-Origin", origin); response.setHeader("Access-Control-Allow-Methods", "POST,GET,OPTIONS,DELETE"); response.setHeader("Access-Control-Max-Age", Long.toString(60 * 60)); response.setHeader("Access-Control-Allow-Credentials", "true"); response.setHeader("Access-Control-Allow-Headers", "Origin,Accept,X-Requested-With,Content-Type,Access-Control-Request-Method,Access-Control-Request-Headers,Authorization"); if ("OPTIONS".equals(method)) { response.setStatus(HttpStatus.OK.value()); } else { chain.doFilter(req, res); }//from w w w . j a va 2 s. com } public void init(FilterConfig filterConfig) { } public void destroy() { } }); }
From source file:com.wavemaker.commons.web.filter.EtagFilter.java
@Override protected boolean isEligibleForEtag(HttpServletRequest request, HttpServletResponse response, int responseStatusCode, InputStream inputStream) { return (responseStatusCode >= 200 && responseStatusCode < 300) && HttpMethod.GET.name().equals(request.getMethod()); }
From source file:se.inera.certificate.proxy.mappings.remote.RemoteDispatcher.java
private HttpResponse makeRequest(HttpServletRequest request, URI newUrl) throws IOException { log.debug("CALLING: {}", newUrl); String method = request.getMethod(); if (method.equalsIgnoreCase("GET")) { return makeGetRequest(request, new HttpGet(newUrl)); } else if (method.contentEquals("POST")) { return makePostRequest(request, new HttpPost(newUrl)); } else if (method.contentEquals("PUT")) { return makePutRequest(request, new HttpPut(newUrl)); } else if (method.contentEquals("OPTIONS")) { return makeOptionsRequest(request, new HttpOptions(newUrl)); }/* w w w . ja va2s. c om*/ return new BasicHttpResponse(HttpVersion.HTTP_1_1, HttpStatus.SC_FORBIDDEN, "Unknown method:" + method); }
From source file:platform.filter.HttpPutDeleteFormContentFilter.java
@Override protected void doFilterInternal(final HttpServletRequest request, HttpServletResponse response, FilterChain filterChain) throws ServletException, IOException { if (("PUT".equals(request.getMethod()) || "DELETE".equals(request.getMethod()) || "PATCH".equals(request.getMethod())) && isFormContentType(request)) { HttpInputMessage inputMessage = new ServletServerHttpRequest(request) { @Override/*from w w w .j a va 2s. c o m*/ public InputStream getBody() throws IOException { return request.getInputStream(); } }; MultiValueMap<String, String> formParameters = formConverter.read(null, inputMessage); HttpServletRequest wrapper = new HttpPutFormContentRequestWrapper(request, formParameters); filterChain.doFilter(wrapper, response); } else { filterChain.doFilter(request, response); } }
From source file:org.ega_archive.elixircore.filter.CustomHiddenHttpMethodFilter.java
@Override protected void doFilterInternal(HttpServletRequest request, HttpServletResponse response, FilterChain filterChain) throws ServletException, IOException { String paramValue = request.getParameter(this.methodParam); if (("POST".equals(request.getMethod()) || "GET".equals(request.getMethod())) && StringUtils.hasLength(paramValue)) { String method = paramValue.toUpperCase(Locale.ENGLISH); HttpServletRequest wrapper = new HttpMethodRequestWrapper(request, method); filterChain.doFilter(wrapper, response); } else {/* ww w . j av a 2 s . com*/ filterChain.doFilter(request, response); } }
From source file:com.netflix.spinnaker.gate.interceptors.RequestLoggingInterceptor.java
@Override public void afterCompletion(HttpServletRequest request, HttpServletResponse response, Object handler, Exception ex) throws Exception { // 127.0.0.1 "GET /limecat.jpg HTTP/1.0" 200 2326 log.debug(String.format("%s \"%s %s %s\" %d %d", sourceIpAddress(request), request.getMethod(), getRequestEndpoint(request), request.getProtocol(), response.getStatus(), getResponseSize(response))); }
From source file:org.italiangrid.storm.webdav.server.LogRequestFilter.java
@Override public void doFilter(ServletRequest request, ServletResponse response, FilterChain chain) throws IOException, ServletException { chain.doFilter(request, response);//from w ww .j ava 2s . c o m SecurityContext ctxt = SecurityContextHolder.getContext(); HttpServletRequest req = (HttpServletRequest) request; HttpServletResponse res = (HttpServletResponse) response; String resMsg = String.format("%s %s %s %d [user:<%s>, authorities:<%s>]", req.getRemoteAddr(), req.getMethod(), req.getRequestURI(), res.getStatus(), ctxt.getAuthentication().getName(), ctxt.getAuthentication().getAuthorities()); log.info(resMsg); }