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.netflix.genie.web.security.oauth2.pingfederate.PingFederateRemoteTokenServices.java
private Map<String, Object> postForMap(final String path, final MultiValueMap<String, String> formData) { final HttpHeaders headers = new HttpHeaders(); headers.setContentType(MediaType.APPLICATION_FORM_URLENCODED); @SuppressWarnings("rawtypes") final Map map = this.localRestTemplate .exchange(path, HttpMethod.POST, new HttpEntity<>(formData, headers), Map.class).getBody(); @SuppressWarnings("unchecked") final Map<String, Object> result = map; return result; }
From source file:com.teradata.benchto.driver.DriverAppIntegrationTest.java
private void verifyExecutionStarted(String benchmarkName, int executionNumber) { restServiceServer//ww w. j av a2 s .c o m .expect(matchAll(requestTo("http://benchmark-service:8080/v1/benchmark/" + benchmarkName + "/BEN_SEQ_ID/execution/" + executionNumber + "/start"), method(HttpMethod.POST))) .andRespond(withSuccess()); }
From source file:ru.anr.base.facade.web.api.RestClient.java
/** * POST method./*from w ww .jav a 2 s . c o m*/ * * @param path * Relative or absolute path * @param body * Request body (as expected by * {@link #setContentType(MediaType)}), default "application/json * @return Response with a body and state */ public ResponseEntity<String> post(String path, String body) { return exchange(path, HttpMethod.POST, body, String.class); }
From source file:com.auditbucket.client.AbRestClient.java
public void ensureFortress(String fortressName) { if (fortressName == null) return;//w ww .jav a 2 s . co m RestTemplate restTemplate = new RestTemplate(); restTemplate.getMessageConverters().add(new StringHttpMessageConverter()); HttpHeaders httpHeaders = getHeaders(userName, password); HttpEntity<FortressInputBean> request = new HttpEntity<>(new FortressInputBean(fortressName, false), httpHeaders); try { restTemplate.exchange(FORTRESS, HttpMethod.POST, request, FortressResultBean.class); if (defaultFortress != null && !defaultFortress.equals(fortressName)) { request = new HttpEntity<>(new FortressInputBean(defaultFortress, false), httpHeaders); restTemplate.exchange(FORTRESS, HttpMethod.POST, request, FortressResultBean.class); } } catch (HttpClientErrorException e) { // ToDo: Rest error handling pretty useless. need to know why it's failing logger.error("AB Client Audit error {}", getErrorMessage(e)); } catch (HttpServerErrorException e) { logger.error("AB Server Audit error {}", getErrorMessage(e)); } }
From source file:com.frequentis.maritime.mcsr.config.SecurityConfiguration.java
@Override protected void configure(HttpSecurity http) throws Exception { //super.configure(http); log.debug("Configuring HttpSecurity"); log.debug("RememberMe service {}", rememberMeServices); http.sessionManagement().sessionCreationPolicy(SessionCreationPolicy.STATELESS) .sessionAuthenticationStrategy(sessionAuthenticationStrategy()).and() .addFilterBefore(basicAuthenticationFilter(), LogoutFilter.class) .addFilterBefore(new SkippingFilter(keycloakPreAuthActionsFilter()), LogoutFilter.class) .addFilterBefore(new SkippingFilter(keycloakAuthenticationProcessingFilter()), X509AuthenticationFilter.class) .exceptionHandling().authenticationEntryPoint(authenticationEntryPoint()).and() // .addFilterAfter(new CsrfCookieGeneratorFilter(), CsrfFilter.class) // .exceptionHandling() // .accessDeniedHandler(new CustomAccessDeniedHandler()) // .authenticationEntryPoint(authenticationEntryPoint) // .and() .rememberMe().rememberMeServices(rememberMeServices).rememberMeParameter("remember-me") .key(jHipsterProperties.getSecurity().getRememberMe().getKey()).and().formLogin() .loginProcessingUrl("/api/authentication").successHandler(ajaxAuthenticationSuccessHandler) .failureHandler(ajaxAuthenticationFailureHandler).usernameParameter("j_username") .passwordParameter("j_password").permitAll().and().logout().logoutUrl("/api/logout") .logoutSuccessHandler(ajaxLogoutSuccessHandler).deleteCookies("JSESSIONID", "CSRF-TOKEN") .permitAll().and().headers().frameOptions().disable().and().authorizeRequests() .antMatchers("/api/register").hasAuthority(AuthoritiesConstants.ADMIN) .antMatchers("/api/elasticsearch/**").permitAll().antMatchers("/api/activate").permitAll() .antMatchers("/api/authenticate").permitAll() .antMatchers("/api/account/reset_password/inactivateit").permitAll() .antMatchers("/api/account/reset_password/finish").permitAll().antMatchers("/api/profile-info") .permitAll().antMatchers("/websocket/tracker").hasAuthority(AuthoritiesConstants.ADMIN) .antMatchers("/websocket/**").permitAll().antMatchers("/management/**") .hasAuthority(AuthoritiesConstants.ADMIN).antMatchers("/v2/api-docs/**").permitAll() .antMatchers(HttpMethod.PUT, "/api/**").authenticated().antMatchers(HttpMethod.POST, "/api/**") .authenticated().antMatchers(HttpMethod.DELETE, "/api/**").authenticated() .antMatchers(HttpMethod.TRACE, "/api/**").authenticated().antMatchers(HttpMethod.HEAD, "/api/**") .authenticated().antMatchers(HttpMethod.PATCH, "/api/**").authenticated() .antMatchers(HttpMethod.OPTIONS, "/api/**").permitAll().antMatchers(HttpMethod.GET, "/api/**") .permitAll().antMatchers("/swagger-resources/configuration/ui").permitAll() .antMatchers("/swagger-ui/index.html").permitAll().and().csrf().disable(); }
From source file:org.appverse.web.framework.backend.test.util.frontfacade.mvc.tests.predefined.BasicAuthEndPointsServiceEnabledPredefinedTests.java
@Test public void simpleAuthenticationServiceTestNoCredentials() throws Exception { CredentialsVO credentialsVO = new CredentialsVO(); HttpEntity<CredentialsVO> entity = new HttpEntity<CredentialsVO>(credentialsVO); ResponseEntity<AuthorizationData> responseEntity = restTemplate.exchange( "http://localhost:" + port + baseApiPath + simpleAuthenticationEndpointPath, HttpMethod.POST, entity, AuthorizationData.class); assertEquals(HttpStatus.UNAUTHORIZED, responseEntity.getStatusCode()); }
From source file:com.orange.ngsi.client.NgsiRestClientTest.java
@Test public void testAppendContextAttribute_JSON() throws Exception { String responseBody = json(jsonConverter, new StatusCode(CodeEnum.CODE_200)); mockServer.expect(requestTo(baseUrl + "/ngsi10/contextEntities/123/attributes/temp")) .andExpect(method(HttpMethod.POST)).andExpect(jsonPath("$.name").value("temp")) .andExpect(jsonPath("$.type").value("float")).andExpect(jsonPath("$.value").value("15.5")) .andRespond(withSuccess(responseBody, MediaType.APPLICATION_JSON)); StatusCode response = ngsiRestClient.appendContextAttribute(baseUrl, null, "123", "temp", Util.createUpdateContextAttributeTemperature()).get(); this.mockServer.verify(); assertEquals(CodeEnum.CODE_200.getLabel(), response.getCode()); }
From source file:com.orange.ngsi2.client.Ngsi2ClientTest.java
@Test public void testUpdateEntity_OK() throws Exception { mockServer.expect(requestTo(baseURL + "/v2/entities/room1?type=Room")).andExpect(method(HttpMethod.POST)) .andExpect(header("Content-Type", MediaType.APPLICATION_JSON_VALUE)) .andExpect(jsonPath("$.temperature.value").value(35.6)).andRespond(withNoContent()); ngsiClient//from w w w .j a va2 s . c o m .updateEntity("room1", "Room", Collections.singletonMap("temperature", new Attribute(35.6)), false) .get(); }
From source file:org.apigw.authserver.ServerRunning.java
public ResponseEntity<TokenResponseDTO> postForToken(String path, HttpHeaders headers, MultiValueMap<String, String> formData) { if (headers.getContentType() == null) { headers.setContentType(MediaType.APPLICATION_FORM_URLENCODED); }/*from w w w .j av a2s.c om*/ HttpEntity<MultiValueMap<String, String>> requestEntity = new HttpEntity<MultiValueMap<String, String>>( formData, headers); return client.exchange(getUrl(path), HttpMethod.POST, requestEntity, TokenResponseDTO.class); }
From source file:org.cloudfoundry.identity.uaa.login.feature.AutologinIT.java
@Test public void testPasswordRequired() throws Exception { HttpHeaders headers = getAppBasicAuthHttpHeaders(); Map<String, String> requestBody = new HashMap<>(); requestBody.put("username", testAccounts.getUserName()); try {/*from ww w.jav a2s .c o m*/ restOperations.exchange(baseUrl + "/autologin", HttpMethod.POST, new HttpEntity<>(requestBody, headers), Map.class); } catch (HttpClientErrorException e) { assertEquals(HttpStatus.UNAUTHORIZED, e.getStatusCode()); } }