List of usage examples for org.springframework.http HttpMethod POST
HttpMethod POST
To view the source code for org.springframework.http HttpMethod POST.
Click Source Link
From source file:com.apress.prospringintegration.web.MultipartHttpClient.java
public static void main(String[] args) { RestTemplate template = new RestTemplate(); String uri = "http://localhost:8080/http-adapter-1.0.0/inboundMultipartAdapter.html"; Resource picture = new ClassPathResource("com/apress/prospringintegration/web/test.png"); MultiValueMap map = new LinkedMultiValueMap(); map.add("name", "John Smith"); map.add("picture", picture); HttpHeaders headers = new HttpHeaders(); headers.setContentType(new MediaType("multipart", "form-data")); HttpEntity request = new HttpEntity(map, headers); ResponseEntity<?> httpResponse = template.exchange(uri, HttpMethod.POST, request, null); System.out.println("Status: " + httpResponse.getStatusCode().name()); }
From source file:edu.infsci2560.LoginHelper.java
public static ResponseEntity<String> login(TestRestTemplate template, String route, String userName, String password) {/*from w w w.j a v a 2 s .c om*/ HttpHeaders headers = getHeaders(template, route); headers.setAccept(Arrays.asList(MediaType.TEXT_HTML)); headers.setContentType(MediaType.APPLICATION_FORM_URLENCODED); MultiValueMap<String, String> form = new LinkedMultiValueMap<String, String>(); form.set("username", userName); form.set("password", password); ResponseEntity<String> entity = template.exchange(route, HttpMethod.POST, new HttpEntity<MultiValueMap<String, String>>(form, headers), String.class); return entity; }
From source file:nl.flotsam.greader.rest.RestInvoker.java
public static RestInvoker preparePostTo(String uri) { return new RestInvoker(HttpMethod.POST, uri); }
From source file:com.pablinchapin.tiendaliz.configuration.SecurityConfiguration.java
@Override protected void configure(HttpSecurity httpSecurity) throws Exception { httpSecurity.csrf().disable().authorizeRequests().antMatchers(HttpMethod.POST, "/api/**").authenticated() .antMatchers(HttpMethod.PUT, "/api/**").authenticated().antMatchers(HttpMethod.DELETE, "/api/**") .authenticated()//from w w w . j a va 2s. c om .anyRequest().permitAll().and().httpBasic().and().sessionManagement() .sessionCreationPolicy(SessionCreationPolicy.STATELESS); }
From source file:org.starfishrespect.myconsumption.server.business.security.WebSecurityConfig.java
/** * Define the security policy for the REST services. * BASIC authentication is supported./*ww w.ja va2 s .c om*/ */ @Override protected void configure(HttpSecurity http) throws Exception { http.authorizeRequests().antMatchers(HttpMethod.POST, "/users/**").permitAll() // needed to create a user on the first launch of the app .antMatchers(HttpMethod.POST, "/users/**/sensor/**").authenticated().antMatchers("/configs/**") .permitAll() // this resource does not need to be protected .anyRequest().authenticated().and().httpBasic().and().csrf().disable().sessionManagement() .sessionCreationPolicy(SessionCreationPolicy.STATELESS); }
From source file:com.pw.ism.TestSecurityConfig.java
@Override protected void configure(HttpSecurity http) throws Exception { http.authorizeRequests().antMatchers(HttpMethod.POST, "/newmessage", "/addheartbeat").permitAll() .antMatchers("/", "/css/**", "/js/**", "/images/**").permitAll().anyRequest().authenticated().and() .csrf().ignoringAntMatchers("/newmessage", "/addheartbeat").and().formLogin().loginPage("/login") .permitAll().and().logout().permitAll(); }
From source file:ca.qhrtech.security.BGLWebSecurityConfiguration.java
@Override public void configure(WebSecurity web) throws Exception { web.ignoring().antMatchers(HttpMethod.POST, "/user").and().ignoring().antMatchers("/jsondoc-ui.html").and() .ignoring().antMatchers("/jsondoc"); }
From source file:com.design.perpetual.ecobeethermostat.app.requests.AuthorizationTokenRequestor.java
public Optional<AuthorizationToken> getAuthorization(AppKey appKey) { if (appKey.isValidToken()) { HttpEntity<String> request = new HttpEntity(GenericRequestor.setContentTypeHeader()); String url = String.format(URL, appKey.getToken()); return (Optional<AuthorizationToken>) genericRequestor.request(url, HttpMethod.POST, AuthorizationToken.class, request); }// w ww.j av a 2 s . c o m return Optional.empty(); }
From source file:com.mc.printer.model.layout.ws.CommUpdateTask.java
@Override public Object doBackgrounp() { ComResponse<T> response = null; try {// w w w .j a va 2s . c o m //Spring3 RESTful client?POSThttp? response = restTemplate.exchange(URI + serviceId, HttpMethod.POST, new HttpEntity<T>(requestData), new ParameterizedTypeReference<ComResponse<T>>() { }).getBody(); } catch (RestClientException e) { //logger.error(e.getMessage()); return e; } return response; }
From source file:com.joseph.california.test.restapi.PersonRestControllerTest.java
@Test public void tesCreate() { Person p = null;/*from w w w . ja va 2 s . c o m*/ HttpEntity<Person> requestEntity = new HttpEntity<>(p, getContentType()); // Make the HTTP POST request, marshaling the request to JSON, and the response to a String ResponseEntity<String> responseEntity = restTemplate.exchange(URL + "api/person/create", HttpMethod.POST, requestEntity, String.class); }