List of usage examples for org.springframework.http HttpMethod GET
HttpMethod GET
To view the source code for org.springframework.http HttpMethod GET.
Click Source Link
From source file:net.orpiske.tcs.service.config.SecurityConfig.java
@Override protected void configure(HttpSecurity http) throws Exception { /**/* ww w . jav a 2 s. c o m*/ * Disabling CSRF because ... well ... because ... f**** you. I know it's good * but I need to research more about it. For now, I just want to get this site * up an running. * * Ref.: * http://spring.io/blog/2013/08/21/spring-security-3-2-0-rc1-highlights-csrf-protection/ */ http.csrf().disable(); http.authorizeRequests().antMatchers(HttpMethod.POST, "/domain/**").hasRole("USER").and().httpBasic(); http.authorizeRequests().antMatchers(HttpMethod.GET, "/domain/**").permitAll(); http.authorizeRequests().antMatchers(HttpMethod.POST, "/references/**").hasRole("USER").and().httpBasic(); http.authorizeRequests().antMatchers("/tagcloud/**", "/tagcloud/domain/**").permitAll(); }
From source file:com.logaritex.hadoop.configuration.manager.SimpleHttpService.java
@Override public <R> R get(String url, Class<R> clazz, Object... params) { R response = restTemplate/* w w w.j av a 2s .c o m*/ .exchange(baseUrl + url, HttpMethod.GET, new HttpEntity<Object>(httpHeaders), clazz, params) .getBody(); return response; }
From source file:br.com.d4j.apostei.api.SecurityConfiguration.java
/** * {@inheritDoc}//from www . j a va2s .c om */ @Override protected void configure(HttpSecurity http) throws Exception { // http.httpBasic().and().authorizeRequests().// // antMatchers("/", "/**").permitAll().anyRequest().permitAll(); http.httpBasic().and().authorizeRequests().// and().formLogin().loginPage("/login").permitAll().// and().logout().permitAll().and().authorizeRequests().// antMatchers(HttpMethod.GET, "/post/**").hasRole("ADMIN").// antMatchers("/", "/**").permitAll().anyRequest().authenticated().// and().csrf().disable(); }
From source file:net.acesinc.convergentui.content.ContentFetchCommand.java
@Override protected ContentResponse run() throws Exception { log.debug("Getting live content from [ " + location + " ]"); try {/*from w w w . j a v a2s . com*/ HttpServletRequest request = requestContext.getRequest(); MultiValueMap<String, String> headers = this.helper.buildZuulRequestHeaders(request); if (request.getQueryString() != null && !request.getQueryString().isEmpty()) { MultiValueMap<String, String> params = this.helper.buildZuulRequestQueryParams(request); } HttpHeaders requestHeaders = new HttpHeaders(); for (String key : headers.keySet()) { for (String s : headers.get(key)) { requestHeaders.add(key, s); } } HttpEntity requestEntity = new HttpEntity(null, requestHeaders); ResponseEntity<Object> exchange = this.restTemplate.exchange(location, HttpMethod.GET, requestEntity, Object.class); ContentResponse response = new ContentResponse(); response.setContent(exchange.getBody()); response.setContentType(exchange.getHeaders().getContentType()); response.setError(false); return response; } catch (Exception e) { log.debug("Error fetching live content from [ " + location + " ]", e); throw e; } }
From source file:com.tce.oauth2.spring.client.services.TodoService.java
public List<Todo> findAll(String accessToken) { HttpHeaders headers = new HttpHeaders(); headers.add("Authorization", "Bearer " + accessToken); HttpEntity<String> entity = new HttpEntity<String>(headers); ResponseEntity<Todo[]> response = restTemplate.exchange(OAUTH_RESOURCE_SERVER_URL + "/rest/todos", HttpMethod.GET, entity, Todo[].class); Todo[] todos = response.getBody();/* w ww. ja v a 2 s. c o m*/ return Arrays.asList(todos); }
From source file:net.paslavsky.springrest.HttpHeadersHelperTest.java
@DataProvider public Object[][] data() { DateFormat dateFormat = createDateFormat(); final long currentTime = System.currentTimeMillis(); final String currentTimeStr = dateFormat.format(new Date(currentTime)); return new Object[][] { new Object[] { "Other", new Object[] { 123 }, "123" }, new Object[] { "Other", new Object[] { "123" }, "123" }, new Object[] { "Other", new String[] { "123" }, "123" }, new Object[] { "Other", Arrays.asList("123"), "123" }, new Object[] { "Other", "123", "123" }, new Object[] { "Accept", MediaType.APPLICATION_JSON, MediaType.APPLICATION_JSON_VALUE }, new Object[] { "Accept", Arrays.asList(MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML), MediaType.APPLICATION_JSON_VALUE + ", " + MediaType.APPLICATION_XML_VALUE }, new Object[] { "Accept-Charset", java.nio.charset.Charset.forName("UTF-8"), "utf-8" }, new Object[] { "Allow", HttpMethod.GET, "GET" }, new Object[] { "Allow", new TreeSet<HttpMethod>(Arrays.asList(HttpMethod.PUT, HttpMethod.POST)), "POST,PUT" }, new Object[] { "Connection", "close", "close" }, new Object[] { "Content-Disposition", "form-data; name=\"AttachedFile1\"; filename=\"photo-1.jpg\"", "form-data; name=\"AttachedFile1\"; filename=\"photo-1.jpg\"" }, new Object[] { "Content-Disposition", new String[] { "AttachedFile1", "photo-1.jpg" }, "form-data; name=\"AttachedFile1\"; filename=\"photo-1.jpg\"" }, new Object[] { "Content-Disposition", "AttachedFile1", "form-data; name=\"AttachedFile1\"" }, new Object[] { "Content-Length", 123l, "123" }, new Object[] { "Content-Type", MediaType.APPLICATION_JSON, MediaType.APPLICATION_JSON_VALUE }, new Object[] { "Content-Type", MediaType.APPLICATION_JSON_VALUE, MediaType.APPLICATION_JSON_VALUE }, new Object[] { "Date", currentTime, currentTimeStr }, new Object[] { "ETag", "W/\"123456789\"", "W/\"123456789\"" }, new Object[] { "Expires", currentTime, currentTimeStr }, new Object[] { "If-Modified-Since", currentTime, currentTimeStr }, new Object[] { "If-None-Match", "737060cd8c284d8af7ad3082f209582d", "737060cd8c284d8af7ad3082f209582d" }, new Object[] { "Last-Modified", currentTime, currentTimeStr }, new Object[] { "Location", "http://example.com/", "http://example.com/" }, new Object[] { "Location", URI.create("http://example.com/"), "http://example.com/" }, new Object[] { "Origin", "www.a.com", "www.a.com" }, new Object[] { "Pragma", "no-cache", "no-cache" }, new Object[] { "Upgrade", "HTTP/2.0, SHTTP/1.3, IRC/6.9, RTA/x11", "HTTP/2.0, SHTTP/1.3, IRC/6.9, RTA/x11" }, }; }
From source file:fi.helsinki.opintoni.server.FlammaServer.java
public void expectTeacherNews() { server.expect(requestTo(flammaBaseUrl + "/infotaulu/atom-tiedotteet-opetusasiat.xml")) .andExpect(method(HttpMethod.GET)) .andRespond(withSuccess(toText("flamma/teachernews.xml"), MediaType.TEXT_XML)); }
From source file:com.github.ffremont.microservices.springboot.node.services.MsService.java
public List<MicroServiceRest> getMicroServices() { MasterUrlBuilder builder = new MasterUrlBuilder(cluster, node, masterhost, masterPort, masterCR); HttpHeaders headers = new HttpHeaders(); headers.setAccept(Arrays.asList(MediaType.parseMediaType(MS_JSON_TYPE_MIME))); HttpEntity<MicroServiceRest> entity = new HttpEntity<>(headers); ResponseEntity<MicroServiceRest[]> response = restTempate.exchange(builder.build(), HttpMethod.GET, entity, MicroServiceRest[].class); return HttpStatus.OK.equals(response.getStatusCode()) ? new ArrayList<>(Arrays.asList(response.getBody())) : null;/*from w w w.jav a 2s.co m*/ }
From source file:org.zalando.github.spring.StatusesTemplateTest.java
@Test public void listStatuses() throws Exception { mockServer//w w w. ja va 2s. c o m .expect(requestTo( "https://api.github.com/repos/zalando-stups/blub/commits/abcdefgh1234567/statuses")) .andExpect(method(HttpMethod.GET)) // .andExpect(header("Authorization", "Bearer ACCESS_TOKEN")) .andRespond(withSuccess(jsonResource("statusList"), APPLICATION_JSON)); List<Status> statusList = statusesTemplate.listStatuses("zalando-stups", "blub", "abcdefgh1234567"); Assertions.assertThat(statusList).isNotNull(); Assertions.assertThat(statusList.size()).isEqualTo(1); Assertions.assertThat(statusList.get(0).getId()).isEqualTo(1); }
From source file:com.wavemaker.commons.web.filter.EtagFilter.java
@Override protected void doFilterInternal(HttpServletRequest request, HttpServletResponse response, FilterChain filterChain) throws ServletException, IOException { //Disabling etag for ie browser as it is not honouring etag header. boolean requestedFromIeBrowser = isRequestFromIeBrowser(request); if (request.getRequestURL().indexOf("/services") != -1) { logger.debug("Etag Request for url {}, IE browser {}, user-agent {}, servlet Path {} ", request.getRequestURL(), requestedFromIeBrowser, request.getHeader("User-Agent"), request.getServletPath()); }/*from w w w.java2s .co m*/ //Setting no cache for ie as etag is disabled for it. if (requestedFromIeBrowser && (request.getServletPath().startsWith("/services") || request.getServletPath().startsWith("/app") || request.getServletPath().startsWith("/pages") || request.getServletPath().startsWith("/prefabs") || request.getServletPath().endsWith(".json"))) { response.setHeader("Cache-Control", "no-cache, no-store, must-revalidate"); // HTTP 1.1 response.setHeader("Pragma", "no-cache"); // HTTP 1.0 response.setDateHeader("Expires", 0); // Proxies. } if (HttpMethod.GET.name().equals(request.getMethod()) && !requestedFromIeBrowser) { response.setHeader("Cache-Control", "max-age=0"); // HTTP 1.1 super.doFilterInternal(request, response, filterChain); } else { filterChain.doFilter(request, response); } }