• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

Java InterceptingClientHttpRequestFactory类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Java中org.springframework.http.client.InterceptingClientHttpRequestFactory的典型用法代码示例。如果您正苦于以下问题:Java InterceptingClientHttpRequestFactory类的具体用法?Java InterceptingClientHttpRequestFactory怎么用?Java InterceptingClientHttpRequestFactory使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



InterceptingClientHttpRequestFactory类属于org.springframework.http.client包,在下文中一共展示了InterceptingClientHttpRequestFactory类的14个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。

示例1: init

import org.springframework.http.client.InterceptingClientHttpRequestFactory; //导入依赖的package包/类
/**
 * Init
 */
@PostConstruct
protected void init() {

    restTemplateForAuthenticationFlow = new CookieStoreRestTemplate();
    cookieStore = restTemplateForAuthenticationFlow.getCookieStore();

    logger.debug("Inject cookie store used in the rest template for authentication flow into the authRestTemplate so that they will match");
    authRestTemplate.restTemplate.setCookieStoreAndUpdateRequestFactory(cookieStore);

    List<ClientHttpRequestInterceptor> interceptors = Collections
            .<ClientHttpRequestInterceptor>singletonList(new ClientHttpRequestInterceptor() {
                @Override
                public ClientHttpResponse intercept(HttpRequest request, byte[] body, ClientHttpRequestExecution execution) throws IOException {
                    if (latestCsrfToken != null) {
                        // At the beginning of auth flow, there's no token yet
                        injectCsrfTokenIntoHeader(request, latestCsrfToken);
                    }
                    return execution.execute(request, body);
                }
            });

    restTemplateForAuthenticationFlow.setRequestFactory(new InterceptingClientHttpRequestFactory(restTemplateForAuthenticationFlow.getRequestFactory(), interceptors));
}
 
开发者ID:box,项目名称:mojito,代码行数:27,代码来源:FormLoginAuthenticationCsrfTokenInterceptor.java


示例2: clientHttpRequestFactory

import org.springframework.http.client.InterceptingClientHttpRequestFactory; //导入依赖的package包/类
@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(new java.net.Proxy(Type.HTTP,
				new InetSocketAddress(proxy.getHost(), proxy.getPort())));
	}
	return new InterceptingClientHttpRequestFactory(requestFactory, interceptors);
}
 
开发者ID:vikrammane23,项目名称:https-github.com-g0t4-jenkins2-course-spring-boot,代码行数:13,代码来源:RemoteClientConfiguration.java


示例3: getRequestFactory

import org.springframework.http.client.InterceptingClientHttpRequestFactory; //导入依赖的package包/类
@Override
public ClientHttpRequestFactory getRequestFactory() {
	ClientHttpRequestFactory delegate = super.getRequestFactory();
	if (!CollectionUtils.isEmpty(getInterceptors())) {
		return new InterceptingClientHttpRequestFactory(delegate, getInterceptors());
	}
	else {
		return delegate;
	}
}
 
开发者ID:lamsfoundation,项目名称:lams,代码行数:11,代码来源:InterceptingHttpAccessor.java


示例4: addAuthentication

import org.springframework.http.client.InterceptingClientHttpRequestFactory; //导入依赖的package包/类
private void addAuthentication() {
    if (StringUtils.isEmpty(username)) {
        throw new RuntimeException("Username is mandatory for Basic Auth");
    }

    List<ClientHttpRequestInterceptor> interceptors = Collections
            .singletonList(new BasicAuthInterceptor(username, password));
    setRequestFactory(new InterceptingClientHttpRequestFactory(getRequestFactory(),
            interceptors));
}
 
开发者ID:peavers,项目名称:swordfish-service,代码行数:11,代码来源:RestTemplateConfig.java


示例5: getRawRestTemplate

import org.springframework.http.client.InterceptingClientHttpRequestFactory; //导入依赖的package包/类
private RestTemplate getRawRestTemplate() {
    RestTemplate restTemplate = new RestTemplate();

    restTemplate.getMessageConverters().add(
            new ByteArrayHttpMessageConverter());

    restTemplate.setRequestFactory(
            new InterceptingClientHttpRequestFactory(
                    restTemplate.getRequestFactory(),
                    Collections.singletonList(
                            new BasicAuthorizationInterceptor("1", "1"))));
    return restTemplate;
}
 
开发者ID:JUGIstanbul,项目名称:second-opinion-api,代码行数:14,代码来源:MediaDownloadControllerIT.java


示例6: interceptorsIntegration

import org.springframework.http.client.InterceptingClientHttpRequestFactory; //导入依赖的package包/类
@Override
protected void interceptorsIntegration(List<ClientHttpRequestInterceptor> lInterceptors, Object sslConfiguration) {
    this.setInterceptors(lInterceptors);
    SimpleClientHttpRequestFactory chrf = new SimpleClientHttpRequestFactory();
    chrf.setOutputStreaming(false);
    this.setRequestFactory(
            new InterceptingClientHttpRequestFactory(
                    new BufferingClientHttpRequestFactory(chrf),
                    lInterceptors
            )
    );
}
 
开发者ID:zg2pro,项目名称:spring-rest-basis,代码行数:13,代码来源:Zg2proRestTemplate.java


示例7: testInterceptor

import org.springframework.http.client.InterceptingClientHttpRequestFactory; //导入依赖的package包/类
/**
 * hard to check the logs provided by the interceptor when there's no error
 * however this unit test garantees the interceptor does not alter the reply
 * from the rest service.
 */
@Test
public void testInterceptor() {
    List<ClientHttpRequestInterceptor> lInterceptors = new ArrayList<>();
    //spring boot default log level is info
    lInterceptors.add(new LoggingRequestInterceptor(StandardCharsets.ISO_8859_1, 100, Level.ERROR));
    SimpleClientHttpRequestFactory chrf = new SimpleClientHttpRequestFactory();
    chrf.setOutputStreaming(false);
    rt.getRestTemplate().setRequestFactory(new InterceptingClientHttpRequestFactory(
            new BufferingClientHttpRequestFactory(chrf),
            lInterceptors
    ));
    ResponseEntity<String> resp = rt.getForEntity(MockedControllers.TEST_URL_GET, String.class);
    assertThat(resp.getBody()).isEqualTo(MockedControllers.TEST_RETURN_VALUE);
}
 
开发者ID:zg2pro,项目名称:spring-rest-basis,代码行数:20,代码来源:LogsTest.java


示例8: init

import org.springframework.http.client.InterceptingClientHttpRequestFactory; //导入依赖的package包/类
/**
 * Initialize the internal restTemplate instance
 */
@PostConstruct
protected void init() {
    logger.debug("Create the RestTemplate instance that will be wrapped");

    makeRestTemplateWithCustomObjectMapper(restTemplate);

    logger.debug("Set interceptor for authentication");
    List<ClientHttpRequestInterceptor> interceptors = Collections
            .<ClientHttpRequestInterceptor>singletonList(formLoginAuthenticationCsrfTokenInterceptor);

    restTemplate.setRequestFactory(new InterceptingClientHttpRequestFactory(restTemplate.getRequestFactory(), interceptors));
}
 
开发者ID:box,项目名称:mojito,代码行数:16,代码来源:AuthenticatedRestTemplate.java


示例9: addAuthentication

import org.springframework.http.client.InterceptingClientHttpRequestFactory; //导入依赖的package包/类
private void addAuthentication(RestTemplate restTemplate, String username,
		String password) {
	if (username == null) {
		return;
	}
	List<ClientHttpRequestInterceptor> interceptors = Collections
			.<ClientHttpRequestInterceptor>singletonList(
					new BasicAuthorizationInterceptor(username, password));
	restTemplate.setRequestFactory(new InterceptingClientHttpRequestFactory(
			restTemplate.getRequestFactory(), interceptors));
}
 
开发者ID:vikrammane23,项目名称:https-github.com-g0t4-jenkins2-course-spring-boot,代码行数:12,代码来源:TestRestTemplate.java


示例10: addAuthentication

import org.springframework.http.client.InterceptingClientHttpRequestFactory; //导入依赖的package包/类
private void addAuthentication(String username, String password) {
	if (username == null) {
		return;
	}
	List<ClientHttpRequestInterceptor> interceptors = Collections
			.<ClientHttpRequestInterceptor>singletonList(
					new BasicAuthorizationInterceptor(username, password));
	setRequestFactory(new InterceptingClientHttpRequestFactory(getRequestFactory(),
			interceptors));
}
 
开发者ID:vikrammane23,项目名称:https-github.com-g0t4-jenkins2-course-spring-boot,代码行数:11,代码来源:TestRestTemplate.java


示例11: RestService

import org.springframework.http.client.InterceptingClientHttpRequestFactory; //导入依赖的package包/类
public RestService(String url, String username, String password) {
    this.url = url;

    template = new RestTemplate();

    List<ClientHttpRequestInterceptor> interceptors = new ArrayList<>();

    if (username != null) {
        interceptors.add(new BasicAuthenticationInterceptor(username, password));
    }

    interceptors.add(new LoggingInterceptor());

    template.setRequestFactory(
            new InterceptingClientHttpRequestFactory(template.getRequestFactory(), interceptors));

    prismContext = ProxyCreator.getProxy(PrismContext.class, () -> {

        try {
            PrismContextFactory factory = new MidPointPrismContextFactory() {

                @Override
                protected void registerExtensionSchemas(SchemaRegistryImpl schemaRegistry)
                        throws SchemaException, FileNotFoundException {
                    super.registerExtensionSchemas(schemaRegistry);

                    RestService.this.registerExtensionSchemas(schemaRegistry);
                }
            };

            return factory.createPrismContext();
        } catch (SchemaException | FileNotFoundException ex) {
            throw new NinjaException("Couldn't load prism context", ex);
        }
    });
}
 
开发者ID:Evolveum,项目名称:midpoint,代码行数:37,代码来源:RestService.java


示例12: RamlRestTemplate

import org.springframework.http.client.InterceptingClientHttpRequestFactory; //导入依赖的package包/类
private RamlRestTemplate(RamlChecker ramlChecker, boolean notSending, ReportStore reportStore, ClientHttpRequestFactory requestFactory) {
    this.ramlChecker = ramlChecker;
    this.notSending = notSending;
    this.reportStore = reportStore;
    this.originalRequestFactory = requestFactory;
    final RamlRequestInterceptor interceptor = new RamlRequestInterceptor(ramlChecker, notSending, reportStore);
    setRequestFactory(new InterceptingClientHttpRequestFactory(
            new BufferingClientHttpRequestFactory(requestFactory), Collections.<ClientHttpRequestInterceptor>singletonList(interceptor)));
}
 
开发者ID:nidi3,项目名称:raml-tester,代码行数:10,代码来源:RamlRestTemplate.java


示例13: authenticated

import org.springframework.http.client.InterceptingClientHttpRequestFactory; //导入依赖的package包/类
@Test
public void authenticated() {
	assertThat(new TestRestTemplate("user", "password").getRestTemplate()
			.getRequestFactory())
					.isInstanceOf(InterceptingClientHttpRequestFactory.class);
}
 
开发者ID:vikrammane23,项目名称:https-github.com-g0t4-jenkins2-course-spring-boot,代码行数:7,代码来源:TestRestTemplateTests.java


示例14: authenticated

import org.springframework.http.client.InterceptingClientHttpRequestFactory; //导入依赖的package包/类
@Test
public void authenticated() {
	assertTrue(new TestRestTemplate("user", "password")
			.getRequestFactory() instanceof InterceptingClientHttpRequestFactory);
}
 
开发者ID:Nephilim84,项目名称:contestparser,代码行数:6,代码来源:TestRestTemplateTests.java



注:本文中的org.springframework.http.client.InterceptingClientHttpRequestFactory类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Java Lists类代码示例发布时间:2022-05-21
下一篇:
Java PointerUtils类代码示例发布时间:2022-05-21
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap