List of usage examples for org.springframework.http.client InterceptingClientHttpRequestFactory InterceptingClientHttpRequestFactory
public InterceptingClientHttpRequestFactory(ClientHttpRequestFactory requestFactory,
@Nullable List<ClientHttpRequestInterceptor> interceptors)
From source file:com.github.ffremont.microservices.springboot.node.ApplicationConfiguration.java
@Bean public RestTemplate getRestTemplate() { RestTemplate rTemplate = new RestTemplate(); List<ClientHttpRequestInterceptor> interceptors = Collections.<ClientHttpRequestInterceptor>singletonList( new BasicAuthorizationInterceptor(this.username, this.password)); rTemplate.setRequestFactory(/*from ww w . ja v a 2s. co m*/ new InterceptingClientHttpRequestFactory(rTemplate.getRequestFactory(), interceptors)); return rTemplate; }
From source file:guru.nidi.ramltester.spring.RamlRestTemplate.java
private RamlRestTemplate(RamlChecker ramlChecker, boolean notSending, ReportStore reportStore, ClientHttpRequestFactory requestFactory) { this.ramlChecker = ramlChecker; this.notSending = notSending; this.reportStore = reportStore; this.originalRequestFactory = requestFactory; interceptor = new RamlRequestInterceptor(ramlChecker, notSending, reportStore); setRequestFactory(/* ww w .j a va2s . c om*/ new InterceptingClientHttpRequestFactory(new BufferingClientHttpRequestFactory(requestFactory), Collections.<ClientHttpRequestInterceptor>singletonList(interceptor))); }
From source file:uk.co.bcl.genie.utils.SalesCloudRestTemplate.java
private void addAuthentication(String username, String password) { logger.entry();/* w w w .j a va2 s. c o m*/ logger.debug("Adding authentication: " + username + "/********"); if (username == null) { return; } List<ClientHttpRequestInterceptor> interceptors = Collections .<ClientHttpRequestInterceptor>singletonList(new BasicAuthorizationInterceptor(username, password)); setRequestFactory(new InterceptingClientHttpRequestFactory(getRequestFactory(), interceptors)); logger.exit(); }
From source file:com.github.ibm.domino.client.BaseClient.java
protected void init(String pathSuffix) throws RuntimeException { if (database == null || database.isEmpty()) { throw new RuntimeErrorException(new Error("Database parameter not found")); }/* w ww . j av a2 s . com*/ if (ignoreHostNameMatching) { HttpsURLConnection.setDefaultHostnameVerifier((hostname, session) -> true); } StringBuilder p = new StringBuilder(); if (pathSuffix != null && !pathSuffix.isEmpty()) { p.append("/mail"); p.append("/").append(database); } p.append("/api/calendar"); if (pathSuffix != null && !pathSuffix.isEmpty()) { p.append("/").append(pathSuffix); } setPath(p.toString()); ObjectMapper mapper = new ObjectMapper(); mapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false); mapper.setSerializationInclusion(Include.NON_NULL); // mapper.configure(SerializationFeature. WRITE_NULL_MAP_VALUES, false); mapper.registerModule(new Jackson2HalModule()); MappingJackson2HttpMessageConverter converter = new MappingJackson2HttpMessageConverter(); converter.setSupportedMediaTypes( Arrays.asList(MediaType.APPLICATION_JSON, MediaType.APPLICATION_OCTET_STREAM)); converter.setObjectMapper(mapper); restTemplate = new RestTemplate(Collections.<HttpMessageConverter<?>>singletonList(converter)); List<ClientHttpRequestInterceptor> interceptors = Collections .<ClientHttpRequestInterceptor>singletonList(new BasicAuthorizationInterceptor(username, password)); restTemplate.setRequestFactory( new InterceptingClientHttpRequestFactory(restTemplate.getRequestFactory(), interceptors)); }
From source file:org.springframework.boot.devtools.remote.client.RemoteClientConfiguration.java
@Bean public ClientHttpRequestFactory clientHttpRequestFactory() { List<ClientHttpRequestInterceptor> interceptors = Arrays.asList(getSecurityInterceptor()); SimpleClientHttpRequestFactory requestFactory = new SimpleClientHttpRequestFactory(); Proxy proxy = this.properties.getRemote().getProxy(); if (proxy.getHost() != null && proxy.getPort() != null) { requestFactory.setProxy(/* ww w .j av a 2 s.c o m*/ new java.net.Proxy(Type.HTTP, new InetSocketAddress(proxy.getHost(), proxy.getPort()))); } return new InterceptingClientHttpRequestFactory(requestFactory, interceptors); }