本文整理汇总了Java中org.cloudfoundry.client.lib.HttpProxyConfiguration类的典型用法代码示例。如果您正苦于以下问题:Java HttpProxyConfiguration类的具体用法?Java HttpProxyConfiguration怎么用?Java HttpProxyConfiguration使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
HttpProxyConfiguration类属于org.cloudfoundry.client.lib包,在下文中一共展示了HttpProxyConfiguration类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。
示例1: setUpWithNonEmptyConstructorWithoutLuck
import org.cloudfoundry.client.lib.HttpProxyConfiguration; //导入依赖的package包/类
/**
* Failed attempt to instantiate CloudControllerClientImpl with existing constructors. Just here to illustrate the
* need to move the initialize() method out of the constructor.
*/
public void setUpWithNonEmptyConstructorWithoutLuck() throws Exception {
restUtil = mock(RestUtil.class);
when(restUtil.createRestTemplate(any(HttpProxyConfiguration.class), false)).thenReturn(restTemplate);
when(restUtil.createOauthClient(any(URL.class), any(HttpProxyConfiguration.class), false)).thenReturn
(oauthClient);
when(restTemplate.getRequestFactory()).thenReturn(clientHttpRequestFactory);
restUtil.createRestTemplate(null, false);
restUtil.createOauthClient(new URL(CCNG_API_URL), null, false);
controllerClient = new CloudControllerClientImpl(new URL("http://api.dummyendpoint.com/login"),
restTemplate, oauthClient, loggregatorClient,
new CloudCredentials(CCNG_USER_EMAIL, CCNG_USER_PASS),
CCNG_USER_ORG, CCNG_USER_SPACE);
}
开发者ID:SAP,项目名称:cf-java-client-sap,代码行数:20,代码来源:CloudControllerClientImplTest.java
示例2: buildProxyConfiguration
import org.cloudfoundry.client.lib.HttpProxyConfiguration; //导入依赖的package包/类
/**
* build proxy for cloud foundry http connection
* @param targetURL - target API URL
* @return the full target URL
*/
private static HttpProxyConfiguration buildProxyConfiguration(URL targetURL) {
ProxyConfiguration proxyConfig = Jenkins.getInstance().proxy;
if (proxyConfig == null) {
return null;
}
String host = targetURL.getHost();
for (Pattern p : proxyConfig.getNoProxyHostPatterns()) {
if (p.matcher(host).matches()) {
return null;
}
}
return new HttpProxyConfiguration(proxyConfig.name, proxyConfig.port);
}
开发者ID:IBM,项目名称:ibm-cloud-devops,代码行数:21,代码来源:AbstractDevOpsAction.java
示例3: testNoProxySetHTTP
import org.cloudfoundry.client.lib.HttpProxyConfiguration; //导入依赖的package包/类
public void testNoProxySetHTTP() throws Exception {
new ProxyHandler(null, -1, false, IProxyData.HTTP_PROXY_TYPE) {
@Override
protected void handleProxyChange() throws CoreException {
try {
HttpProxyConfiguration configuration = CloudFoundryClientFactory
.getProxy(new URL(VALID_V1_HTTP_URL));
assertNull(configuration);
// verify it is null for https as well
configuration = CloudFoundryClientFactory.getProxy(new URL(VALID_V1_HTTPS_URL));
assertNull(configuration);
}
catch (MalformedURLException e) {
throw CloudErrorUtil.toCoreException(e);
}
}
};
}
开发者ID:eclipse,项目名称:cft,代码行数:25,代码来源:CloudFoundryProxyTest.java
示例4: testNoProxySetHTTPS
import org.cloudfoundry.client.lib.HttpProxyConfiguration; //导入依赖的package包/类
public void testNoProxySetHTTPS() throws Exception {
new ProxyHandler(null, -1, false, IProxyData.HTTPS_PROXY_TYPE) {
@Override
protected void handleProxyChange() throws CoreException {
try {
HttpProxyConfiguration configuration = CloudFoundryClientFactory
.getProxy(new URL(VALID_V1_HTTPS_URL));
assertNull(configuration);
// verify it is null for https as well
configuration = CloudFoundryClientFactory.getProxy(new URL(VALID_V1_HTTP_URL));
assertNull(configuration);
}
catch (MalformedURLException e) {
throw CloudErrorUtil.toCoreException(e);
}
}
}.run();
}
开发者ID:eclipse,项目名称:cft,代码行数:25,代码来源:CloudFoundryProxyTest.java
示例5: testProxySetDirectHTTPS
import org.cloudfoundry.client.lib.HttpProxyConfiguration; //导入依赖的package包/类
public void testProxySetDirectHTTPS() throws Exception {
// Direct provider means not using proxy settings even if they are set.
// To set direct provider, disable proxies even when set
boolean enableProxies = false;
new ProxyHandler("invalid.proxy.test", 8080, enableProxies, IProxyData.HTTPS_PROXY_TYPE) {
@Override
protected void handleProxyChange() throws CoreException {
try {
HttpProxyConfiguration configuration = CloudFoundryClientFactory
.getProxy(new URL(VALID_V1_HTTPS_URL));
assertNull(configuration);
// verify it is null for https as well
configuration = CloudFoundryClientFactory.getProxy(new URL(VALID_V1_HTTP_URL));
assertNull(configuration);
}
catch (MalformedURLException e) {
throw CloudErrorUtil.toCoreException(e);
}
}
}.run();
}
开发者ID:eclipse,项目名称:cft,代码行数:27,代码来源:CloudFoundryProxyTest.java
示例6: testProxyDirectSetHTTP
import org.cloudfoundry.client.lib.HttpProxyConfiguration; //导入依赖的package包/类
public void testProxyDirectSetHTTP() throws Exception {
// Direct provider means not using proxy settings even if they are set.
// To set direct provider, disable proxies even when set
boolean enableProxies = false;
new ProxyHandler("invalid.proxy.test", 8080, enableProxies, IProxyData.HTTP_PROXY_TYPE) {
@Override
protected void handleProxyChange() throws CoreException {
try {
HttpProxyConfiguration configuration = CloudFoundryClientFactory
.getProxy(new URL(VALID_V1_HTTP_URL));
assertNull(configuration);
// verify it is null for https as well
configuration = CloudFoundryClientFactory.getProxy(new URL(VALID_V1_HTTPS_URL));
assertNull(configuration);
}
catch (MalformedURLException e) {
throw CloudErrorUtil.toCoreException(e);
}
}
}.run();
}
开发者ID:eclipse,项目名称:cft,代码行数:27,代码来源:CloudFoundryProxyTest.java
示例7: CFClientV1Support
import org.cloudfoundry.client.lib.HttpProxyConfiguration; //导入依赖的package包/类
public CFClientV1Support(CloudFoundryOperations cfClient, CloudSpace existingSessionConnection, CFInfo cloudInfo,
HttpProxyConfiguration httpProxyConfiguration, CloudFoundryServer cfServer, boolean trustSelfSigned) {
this.cloudInfo = cloudInfo;
this.oauth = getHeaderProvider(cfClient);
this.existingSessionConnection = existingSessionConnection;
this.restTemplate = RestUtils.createRestTemplate(httpProxyConfiguration, trustSelfSigned, true);
ClientHttpRequestFactory requestFactory = restTemplate.getRequestFactory();
restTemplate.setRequestFactory(authorize(requestFactory));
this.tokenUrl = cloudInfo.getTokenUrl();
this.authorizationUrl = cloudInfo.getAuthorizationUrl();
this.cfServer = cfServer;
}
开发者ID:eclipse,项目名称:cft,代码行数:17,代码来源:CFClientV1Support.java
示例8: getCloudFoundryOperations
import org.cloudfoundry.client.lib.HttpProxyConfiguration; //导入依赖的package包/类
public CloudFoundryOperations getCloudFoundryOperations(CloudCredentials credentials, URL url, CloudSpace session,
boolean selfSigned) {
// Proxies are always updated on each client call by the
// CloudFoundryServerBehaviour Request as well as the client login
// handler
// therefore it is not critical to set the proxy in the client on
// client
// creation
HttpProxyConfiguration proxyConfiguration = getProxy(url);
//@ TODO tentatively set selfSigned = true
selfSigned = true;
return session != null ? new CloudFoundryClient(credentials, url, session, selfSigned)
: new CloudFoundryClient(credentials, url, proxyConfiguration, selfSigned);
}
开发者ID:osswangxining,项目名称:dockerfoundry,代码行数:17,代码来源:DockerFoundryClientFactory.java
示例9: login
import org.cloudfoundry.client.lib.HttpProxyConfiguration; //导入依赖的package包/类
public static CloudFoundryOperations login(CloudCredentials credentials, URL apiUrl, String space, String org, String domain, boolean trustSelfSignedCerts, HttpProxyConfiguration httpProxyConfiguration) {
logger.info("Running on " + apiUrl + " on behalf of " + credentials.getEmail());
logger.info("Using space " + space + " of organization " + org + " with domain " + domain);
if (httpProxyConfiguration != null) {
logger.info("Using proxy to connnect to clound foundry: httpProxyHost=" + httpProxyConfiguration.getProxyHost() + " httpProxyPort=" + httpProxyConfiguration.getProxyPort() );
}
else {
logger.info("Connection to clound foundry will not use proxy. no proxy is set. ");
}
CloudFoundryClient clientWithinTargetSpace = new CloudFoundryClient(credentials, apiUrl, org, space, httpProxyConfiguration,
trustSelfSignedCerts);
clientWithinTargetSpace.login();
// getOrCreateDomain(domain);
return clientWithinTargetSpace;
}
开发者ID:orange-cloudfoundry,项目名称:elpaaso-core,代码行数:18,代码来源:CFClientFactory.java
示例10: createRequestFactory
import org.cloudfoundry.client.lib.HttpProxyConfiguration; //导入依赖的package包/类
public ClientHttpRequestFactory createRequestFactory(HttpProxyConfiguration httpProxyConfiguration, boolean trustSelfSignedCerts) {
HttpComponentsClientHttpRequestFactory requestFactory = new HttpComponentsClientHttpRequestFactory();
HttpClient httpClient = requestFactory.getHttpClient();
if (trustSelfSignedCerts) {
registerSslSocketFactory(httpClient);
} else {
// We don't use self signed certs in Designer so this code will always be executed
// TLSv1.0 has been disabled on Bluemix/Datapower
// We need to use TLSv1.2 or TLSv1.1 instead
registerSslSocketFactoryTLS(httpClient);
}
if (httpProxyConfiguration != null) {
HttpHost proxy = new HttpHost(httpProxyConfiguration.getProxyHost(), httpProxyConfiguration.getProxyPort());
httpClient.getParams().setParameter(ConnRoutePNames.DEFAULT_PROXY, proxy);
}
return requestFactory;
}
开发者ID:OpenNTF,项目名称:XPagesExtensionLibrary,代码行数:21,代码来源:RestUtil.java
示例11: CloudControllerClientFactory
import org.cloudfoundry.client.lib.HttpProxyConfiguration; //导入依赖的package包/类
public CloudControllerClientFactory(HttpProxyConfiguration httpProxyConfiguration, boolean trustSelfSignedCerts) {
this.restUtil = new RestUtil();
this.restTemplate = restUtil.createRestTemplate(httpProxyConfiguration, trustSelfSignedCerts);
this.httpProxyConfiguration = httpProxyConfiguration;
this.trustSelfSignedCerts = trustSelfSignedCerts;
this.objectMapper = new ObjectMapper();
}
开发者ID:SAP,项目名称:cf-java-client-sap,代码行数:10,代码来源:CloudControllerClientFactory.java
示例12: createRequestFactory
import org.cloudfoundry.client.lib.HttpProxyConfiguration; //导入依赖的package包/类
public ClientHttpRequestFactory createRequestFactory(HttpProxyConfiguration httpProxyConfiguration, boolean
trustSelfSignedCerts) {
HttpClientBuilder httpClientBuilder = HttpClients.custom().useSystemProperties();
if (trustSelfSignedCerts) {
httpClientBuilder.setSslcontext(buildSslContext());
httpClientBuilder.setHostnameVerifier(BROWSER_COMPATIBLE_HOSTNAME_VERIFIER);
}
if (httpProxyConfiguration != null) {
HttpHost proxy = new HttpHost(httpProxyConfiguration.getProxyHost(), httpProxyConfiguration.getProxyPort());
httpClientBuilder.setProxy(proxy);
if (httpProxyConfiguration.isAuthRequired()) {
BasicCredentialsProvider credentialsProvider = new BasicCredentialsProvider();
credentialsProvider.setCredentials(
new AuthScope(httpProxyConfiguration.getProxyHost(), httpProxyConfiguration.getProxyPort()),
new UsernamePasswordCredentials(httpProxyConfiguration.getUsername(), httpProxyConfiguration
.getPassword()));
httpClientBuilder.setDefaultCredentialsProvider(credentialsProvider);
}
HttpRoutePlanner routePlanner = new DefaultProxyRoutePlanner(proxy);
httpClientBuilder.setRoutePlanner(routePlanner);
}
HttpClient httpClient = httpClientBuilder.build();
HttpComponentsClientHttpRequestFactory requestFactory = new HttpComponentsClientHttpRequestFactory(httpClient);
return requestFactory;
}
开发者ID:SAP,项目名称:cf-java-client-sap,代码行数:32,代码来源:RestUtil.java
示例13: createRestTemplate
import org.cloudfoundry.client.lib.HttpProxyConfiguration; //导入依赖的package包/类
public RestTemplate createRestTemplate(HttpProxyConfiguration httpProxyConfiguration, boolean
trustSelfSignedCerts) {
RestTemplate restTemplate = new LoggingRestTemplate();
restTemplate.setRequestFactory(createRequestFactory(httpProxyConfiguration, trustSelfSignedCerts));
restTemplate.setErrorHandler(new CloudControllerResponseErrorHandler());
restTemplate.setMessageConverters(getHttpMessageConverters());
return restTemplate;
}
开发者ID:SAP,项目名称:cf-java-client-sap,代码行数:10,代码来源:RestUtil.java
示例14: testProxyManualSetHTTP
import org.cloudfoundry.client.lib.HttpProxyConfiguration; //导入依赖的package包/类
public void testProxyManualSetHTTP() throws Exception {
boolean setProxy = true;
new ProxyHandler("invalid.proxy.test", 8080, setProxy, IProxyData.HTTP_PROXY_TYPE) {
@Override
protected void handleProxyChange() throws CoreException {
try {
HttpProxyConfiguration configuration = CloudFoundryClientFactory
.getProxy(new URL(VALID_V1_HTTP_URL));
assertNotNull(configuration);
assertTrue(configuration.getProxyHost().equals("invalid.proxy.test"));
assertTrue(configuration.getProxyPort() == (8080));
// verify it is null for https, since proxy lookup should
// match the specified
// protocol in the given URL (i.e. HTTP proxy -> HTTP URL,
// HTTPS proxy -> HTTPS URL)
configuration = CloudFoundryClientFactory.getProxy(new URL(VALID_V1_HTTPS_URL));
// Need to add this code in case the server has a proxy set
// for either HTTP or HTTPS
if (configuration != null) {
assertTrue(!configuration.getProxyHost().equals("invalid.proxy.text"));
}
}
catch (MalformedURLException e) {
throw CloudErrorUtil.toCoreException(e);
}
}
}.run();
}
开发者ID:eclipse,项目名称:cft,代码行数:35,代码来源:CloudFoundryProxyTest.java
示例15: testProxySetManualHTTPS
import org.cloudfoundry.client.lib.HttpProxyConfiguration; //导入依赖的package包/类
public void testProxySetManualHTTPS() throws Exception {
boolean setProxy = true;
new ProxyHandler("invalid.proxy.test", 8080, setProxy, IProxyData.HTTPS_PROXY_TYPE) {
@Override
protected void handleProxyChange() throws CoreException {
try {
HttpProxyConfiguration configuration = CloudFoundryClientFactory
.getProxy(new URL(VALID_V1_HTTPS_URL));
assertNotNull(configuration);
assertTrue(configuration.getProxyHost().equals("invalid.proxy.test"));
assertTrue(configuration.getProxyPort() == (8080));
// verify it is null for http, since proxy lookup should
// match the specified
// protocol in the given URL (i.e. HTTP proxy -> HTTP URL,
// HTTPS proxy -> HTTPS URL)
configuration = CloudFoundryClientFactory.getProxy(new URL(VALID_V1_HTTP_URL));
// Need to add this code in case the server has a proxy set
// for either HTTP or HTTPS
if (configuration != null) {
assertTrue(!configuration.getProxyHost().equals("invalid.proxy.text"));
}
}
catch (MalformedURLException e) {
throw CloudErrorUtil.toCoreException(e);
}
}
}.run();
}
开发者ID:eclipse,项目名称:cft,代码行数:34,代码来源:CloudFoundryProxyTest.java
示例16: getCloudFoundryOperations
import org.cloudfoundry.client.lib.HttpProxyConfiguration; //导入依赖的package包/类
public CloudFoundryOperations getCloudFoundryOperations(CloudCredentials credentials, URL url, CloudSpace session,
boolean selfSigned) {
// Proxies are always updated on each client call by the
// CloudFoundryServerBehaviour Request as well as the client login
// handler
// therefore it is not critical to set the proxy in the client on
// client
// creation
HttpProxyConfiguration proxyConfiguration = getProxy(url);
return session != null ? new CloudFoundryClient(credentials, url, session, selfSigned)
: new CloudFoundryClient(credentials, url, proxyConfiguration, selfSigned);
}
开发者ID:eclipse,项目名称:cft,代码行数:15,代码来源:CloudFoundryClientFactory.java
示例17: getProxy
import org.cloudfoundry.client.lib.HttpProxyConfiguration; //导入依赖的package包/类
public static HttpProxyConfiguration getProxy(URL url) {
if (url == null) {
return null;
}
// In certain cases, the activator would have stopped and the plugin may
// no longer be available. Usually onl happens on shutdown.
CloudFoundryPlugin plugin = CloudFoundryPlugin.getDefault();
if (plugin != null) {
IProxyService proxyService = plugin.getProxyService();
if (proxyService != null) {
try {
IProxyData[] selectedProxies = proxyService.select(url.toURI());
// No proxy configured or not found
if (selectedProxies == null || selectedProxies.length == 0) {
return null;
}
IProxyData data = selectedProxies[0];
int proxyPort = data.getPort();
String proxyHost = data.getHost();
String user = data.getUserId();
String password = data.getPassword();
return proxyHost != null ? new HttpProxyConfiguration(proxyHost, proxyPort,
data.isRequiresAuthentication(), user, password) : null;
}
catch (URISyntaxException e) {
// invalid url (protocol, ...) => proxy will be null
}
}
}
return null;
}
开发者ID:eclipse,项目名称:cft,代码行数:34,代码来源:CloudFoundryClientFactory.java
示例18: getSsoUrl
import org.cloudfoundry.client.lib.HttpProxyConfiguration; //导入依赖的package包/类
public static String getSsoUrl(String apiurl, boolean trustSelfSignedCerts) throws Exception {
RestUtil restUtil = new RestUtil();
HttpProxyConfiguration httpProxyConfiguration = getProxy(new URL(apiurl));
RestTemplate restTemplate = restUtil.createRestTemplate(httpProxyConfiguration, trustSelfSignedCerts);
String infoV2Json = restTemplate.getForObject(getUrl(apiurl, "/v2/info"), String.class);
Map<String, Object> infoV2Map = JsonUtil.convertJsonToMap(infoV2Json);
String authorizationEndpoint = CloudUtil.parse(String.class, infoV2Map.get("authorization_endpoint"));
String passcodeJson = getJson(restTemplate, getUrl(authorizationEndpoint, "/login"));
Map<String, Object> passcodeMap = JsonUtil.convertJsonToMap(passcodeJson);
Object prompts = passcodeMap.get("prompts");
if (prompts instanceof Map) {
@SuppressWarnings("rawtypes")
Object text = ((Map)prompts).get("passcode");
if (text instanceof List) {
@SuppressWarnings("rawtypes")
List list = (List) text;
if (list.size() >= 2 && list.get(1) != null) {
String message = list.get(1).toString();
String[] elements = message.split(" ");
for (int i = 0; i < elements.length; i++) {
String element = elements[i];
if (element != null && element.startsWith("http")) {
// Strip trailing parentheses
String url = element;
while(url.endsWith(")")) {
url = url.substring(0, url.length()-1);
}
return url;
}
}
}
}
}
return null;
}
开发者ID:eclipse,项目名称:cft,代码行数:38,代码来源:CloudFoundryClientFactory.java
示例19: createRequestFactory
import org.cloudfoundry.client.lib.HttpProxyConfiguration; //导入依赖的package包/类
public static ClientHttpRequestFactory createRequestFactory(HttpProxyConfiguration httpProxyConfiguration, boolean trustSelfSignedCerts, boolean disableRedirectHandling) {
HttpClientBuilder httpClientBuilder = HttpClients.custom().useSystemProperties();
if (trustSelfSignedCerts) {
httpClientBuilder.setSslcontext(buildSslContext());
httpClientBuilder.setHostnameVerifier(BROWSER_COMPATIBLE_HOSTNAME_VERIFIER);
}
if (disableRedirectHandling) {
httpClientBuilder.disableRedirectHandling();
}
if (httpProxyConfiguration != null) {
HttpHost proxy = new HttpHost(httpProxyConfiguration.getProxyHost(), httpProxyConfiguration.getProxyPort());
httpClientBuilder.setProxy(proxy);
if (httpProxyConfiguration.isAuthRequired()) {
BasicCredentialsProvider credentialsProvider = new BasicCredentialsProvider();
credentialsProvider.setCredentials(
new AuthScope(httpProxyConfiguration.getProxyHost(), httpProxyConfiguration.getProxyPort()),
new UsernamePasswordCredentials(httpProxyConfiguration.getUsername(), httpProxyConfiguration.getPassword()));
httpClientBuilder.setDefaultCredentialsProvider(credentialsProvider);
}
HttpRoutePlanner routePlanner = new DefaultProxyRoutePlanner(proxy);
httpClientBuilder.setRoutePlanner(routePlanner);
}
HttpClient httpClient = httpClientBuilder.build();
HttpComponentsClientHttpRequestFactory requestFactory = new HttpComponentsClientHttpRequestFactory(httpClient);
return requestFactory;
}
开发者ID:eclipse,项目名称:cft,代码行数:34,代码来源:RestUtils.java
示例20: createRestTemplate
import org.cloudfoundry.client.lib.HttpProxyConfiguration; //导入依赖的package包/类
public RestTemplate createRestTemplate(HttpProxyConfiguration httpProxyConfiguration, boolean trustSelfSignedCerts) {
RestTemplate restTemplate = new LoggingRestTemplate();
restTemplate.setRequestFactory(createRequestFactory(httpProxyConfiguration, trustSelfSignedCerts));
restTemplate.setErrorHandler(new CloudControllerResponseErrorHandler());
restTemplate.setMessageConverters(getHttpMessageConverters());
return restTemplate;
}
开发者ID:OpenNTF,项目名称:XPagesExtensionLibrary,代码行数:9,代码来源:RestUtil.java
注:本文中的org.cloudfoundry.client.lib.HttpProxyConfiguration类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论