Java Code Examples for org.apache.http.conn.ssl.AllowAllHostnameVerifier


Example 1
Project: janbanery   File: AndroidCompatibleRestClient.javaView source code 6 votesvote downvote up
public DefaultHttpClient getClient() {
  DefaultHttpClient ret;

  //sets up parameters
  HttpParams params = new BasicHttpParams();
  HttpProtocolParams.setVersion(params, new ProtocolVersion("HTTP", 1, 1));
  HttpProtocolParams.setContentCharset(params, "UTF-8");
  params.setBooleanParameter("http.protocol.expect-continue", false);

  //registers schemes for both http and https
  SchemeRegistry registry = new SchemeRegistry();
  registry.register(new Scheme("http", PlainSocketFactory.getSocketFactory(), 80));
  final SSLSocketFactory sslSocketFactory = SSLSocketFactory.getSocketFactory();
  sslSocketFactory.setHostnameVerifier(new AllowAllHostnameVerifier());
  registry.register(new Scheme("https", sslSocketFactory, 443));

  ThreadSafeClientConnManager manager = new ThreadSafeClientConnManager(params, registry);
  ret = new DefaultHttpClient(manager, params);
  return ret;
}
 
Example 2
Project: property-db   File: AbstractProxyTest.javaView source code 6 votesvote downvote up
public void testConnectToHttps() throws Exception {
    TestSSLContext testSSLContext = TestSSLContext.create();

    server.useHttps(testSSLContext.serverContext.getSocketFactory(), false);
    server.enqueue(new MockResponse()
            .setResponseCode(200)
            .setBody("this response comes via HTTPS"));
    server.play();

    HttpClient httpClient = newHttpClient();

    SSLSocketFactory sslSocketFactory = newSslSocketFactory(testSSLContext);
    sslSocketFactory.setHostnameVerifier(new AllowAllHostnameVerifier());
    httpClient.getConnectionManager().getSchemeRegistry()
            .register(new Scheme("https", sslSocketFactory, server.getPort()));

    HttpResponse response = httpClient.execute(
            new HttpGet("https://localhost:" + server.getPort() + "/foo"));
    assertEquals("this response comes via HTTPS", contentToString(response));

    RecordedRequest request = server.takeRequest();
    assertEquals("GET /foo HTTP/1.1", request.getRequestLine());
}
 
Example 3
Project: Musubi-Android   File: CertifiedHttpClient.javaView source code 6 votesvote downvote up
private SSLSocketFactory newSslSocketFactory() {
	try {
		KeyStore trusted = KeyStore.getInstance("BKS");
		InputStream in = mContext.getResources().openRawResource(
				R.raw.servercertificates);
		try {
			trusted.load(in, "ez24get".toCharArray());
		} finally {
			in.close();
		}
		SSLSocketFactory sf = new SSLSocketFactory(trusted);
		//don't check the host name because we are doing funny redirects.  the
		//actual cert is good enough because it is bundled.
		sf.setHostnameVerifier(new AllowAllHostnameVerifier());
		return sf;
	} catch (Exception e) {
		throw new AssertionError(e);
	}
}
 
Example 4
Project: eureka   File: JerseyEurekaHttpClientFactory.javaView source code 6 votesvote downvote up
/**
 * Since Jersey 1.19 depends on legacy apache http-client API, we have to as well.
 */
private ThreadSafeClientConnManager createConnectionManager() {
    try {
        ThreadSafeClientConnManager connectionManager;
        if (sslContext != null) {
            SchemeSocketFactory socketFactory = new SSLSocketFactory(sslContext, new AllowAllHostnameVerifier());
            SchemeRegistry sslSchemeRegistry = new SchemeRegistry();
            sslSchemeRegistry.register(new Scheme("https", 443, socketFactory));
            connectionManager = new ThreadSafeClientConnManager(sslSchemeRegistry);
        } else {
            connectionManager = new ThreadSafeClientConnManager();
        }
        return connectionManager;
    } catch (Exception e) {
        throw new IllegalStateException("Cannot initialize Apache connection manager", e);
    }
}
 
Example 5
Project: Rhybudd   File: TrustAllSSLSocketFactory.javaView source code 6 votesvote downvote up
public TrustAllSSLSocketFactory() throws KeyManagementException,NoSuchAlgorithmException, KeyStoreException,UnrecoverableKeyException 
{
	super(null);
	try 
	{
		SSLContext sslcontext = SSLContext.getInstance("TLS");
		sslcontext.init(null, new TrustManager[] { new TrustAllManager() }, null);
		factory = sslcontext.getSocketFactory();
		setHostnameVerifier(new AllowAllHostnameVerifier());
	} 
	catch (Exception ex) 
	{

	}
}
 
Example 6
Project: evodroid   File: TrustAllSSLSocketFactory.javaView source code 6 votesvote downvote up
public TrustAllSSLSocketFactory() throws KeyManagementException, NoSuchAlgorithmException, KeyStoreException, UnrecoverableKeyException { 
    super(null); 
        try { 
            SSLContext sslcontext = SSLContext.getInstance("TLS"); 
            sslcontext.init(null, new TrustManager[] { new TrustAllManager() }, null);
            factory = sslcontext.getSocketFactory();
            setHostnameVerifier(new AllowAllHostnameVerifier());             
        } catch(Exception ex) { } 
}
 
Example 7
Project: openjira   File: TrustAllSSLSocketFactory.javaView source code 6 votesvote downvote up
public TrustAllSSLSocketFactory() throws KeyManagementException, NoSuchAlgorithmException, KeyStoreException, UnrecoverableKeyException {
    super(null);
    try {
        SSLContext sslcontext = SSLContext.getInstance("TLS");
        sslcontext.init(null, new TrustManager[] {new TrustAllManager()}, null);
        factory = sslcontext.getSocketFactory();
        setHostnameVerifier(new AllowAllHostnameVerifier());
    } catch (Exception ex) {
    }
}
 
Example 8
Project: wildfly-core   File: HttpGenericOperationUnitTestCase.javaView source code 6 votesvote downvote up
private static CloseableHttpClient createHttpClient(String host, int port, String username, String password) {

        try {
            ConnectionSocketFactory sslConnectionFactory = new SSLSocketFactory(new TrustStrategy() {
                @Override
                public boolean isTrusted(X509Certificate[] chain, String authType) throws CertificateException {
                    return true;
                }
            }, new AllowAllHostnameVerifier());
            Registry<ConnectionSocketFactory> registry = RegistryBuilder.<ConnectionSocketFactory>create()
                    .register("https", sslConnectionFactory)
                    .register("http", PlainConnectionSocketFactory.getSocketFactory())
                    .build();
            CredentialsProvider credsProvider = new BasicCredentialsProvider();
            credsProvider.setCredentials(new AuthScope(host, port, MANAGEMENT_REALM, AuthSchemes.DIGEST),
                    new UsernamePasswordCredentials(username, password));
            PoolingHttpClientConnectionManager connectionPool = new PoolingHttpClientConnectionManager(registry);
            HttpClientBuilder.create().setConnectionManager(connectionPool).build();
            CloseableHttpClient httpClient = HttpClientBuilder.create()
                    .setConnectionManager(connectionPool)
                    .setRetryHandler(new StandardHttpRequestRetryHandler(5, true))
                    .setDefaultCredentialsProvider(credsProvider).build();
            return httpClient;
        } catch (Exception e) {
            throw new RuntimeException(e);
        }
    }
 
Example 9
Project: qaoverflow   File: TrustAllSSLSocketFactory.javaView source code 6 votesvote downvote up
public TrustAllSSLSocketFactory() throws KeyManagementException, NoSuchAlgorithmException, KeyStoreException, UnrecoverableKeyException { 
    super(null); 
        try { 
            SSLContext sslcontext = SSLContext.getInstance("TLS"); 
            sslcontext.init(null, new TrustManager[] { new TrustAllManager() }, null);
            factory = sslcontext.getSocketFactory();
            setHostnameVerifier(new AllowAllHostnameVerifier());             
        } catch(Exception ex) { } 
}
 
Example 10
Project: mylyn-redmine-connector   File: RedmineManagerFactory.javaView source code 6 votesvote downvote up
public static RedmineManager createWithUserAuthNoSslCheck(String url, String username, String password)
{
	SSLContext sslcontext = null;
	try
	{
		sslcontext = SSLContexts.custom()
					            .setSecureRandom(new SecureRandom())
					            .loadTrustMaterial(null, new TrustStrategy() 
					            {
					                public boolean isTrusted(X509Certificate[] chain, String authType) throws CertificateException 
					                {
					                    return true;
					                }
					            }).build();
	}
	catch(Exception e)
	{
		
	}
	 
	
	
	final CloseableHttpClient httpClient = HttpClients.custom()
									   .setHostnameVerifier(new AllowAllHostnameVerifier())
									   .setSslcontext(sslcontext)
									   .setMaxConnTotal(Integer.MAX_VALUE)
									   .setMaxConnPerRoute(Integer.MAX_VALUE)
									   .build();
	 
	
	Runnable shutdownListener = new Runnable()
	{	
		@Override
		public void run()
		{
			try
			{
				httpClient.close();
			}
			catch (IOException e)
			{
			
			}	
		}
	};
	
	return createWithUserAuth(url, username, password, TransportConfiguration.create(httpClient, shutdownListener));
}
 
Example 11
Project: openstack4j   File: HttpClientFactory.javaView source code 6 votesvote downvote up
private CloseableHttpClient buildClient(Config config) {
    HttpClientBuilder cb = HttpClientBuilder.create().setUserAgent(USER_AGENT);
    
    if (config.getProxy() != null) {
        try {
            URL url = new URL(config.getProxy().getHost());
            HttpHost proxy = new HttpHost(url.getHost(), config.getProxy().getPort(), url.getProtocol());
            cb.setProxy(proxy);
        } catch (MalformedURLException e) {
            LOG.error(e.getMessage(), e);
        }
    }
    
    if (config.isIgnoreSSLVerification())
    {
        cb.setSslcontext(UntrustedSSL.getSSLContext());
        cb.setHostnameVerifier(new AllowAllHostnameVerifier());
    }
    
    if (config.getSslContext() != null)
        cb.setSslcontext(config.getSslContext());

    if (config.getMaxConnections() > 0) {
        cb.setMaxConnTotal(config.getMaxConnections());
    }
    
    if (config.getMaxConnectionsPerRoute() > 0) {
        cb.setMaxConnPerRoute(config.getMaxConnectionsPerRoute());
    }
    
    RequestConfig.Builder rcb = RequestConfig.custom();
    
    if (config.getConnectTimeout() > 0)
        rcb.setConnectTimeout(config.getConnectTimeout());
    
    if (config.getReadTimeout() > 0)
        rcb.setSocketTimeout(config.getReadTimeout());
    
    if (INTERCEPTOR != null) {
        INTERCEPTOR.onClientCreate(cb, rcb, config);
    }
    
    return cb.setDefaultRequestConfig(rcb.build()).build();
}
 
Example 12
Project: categolj2-backend   File: AppConfig.javaView source code 6 votesvote downvote up
@Bean
RestTemplate restTemplate() throws Exception {
    SSLContext sslContext = SSLContexts.custom().loadTrustMaterial(null, new TrustSelfSignedStrategy()).useTLS().build();
    SSLConnectionSocketFactory connectionFactory = new SSLConnectionSocketFactory(sslContext, new AllowAllHostnameVerifier());

    HttpClient httpClient = HttpClientBuilder.create()
            .setSSLSocketFactory(connectionFactory)
            .build();
    return new RestTemplate(new HttpComponentsClientHttpRequestFactory(httpClient));
}
 
Example 13
Project: moskito-central   File: RESTHttpsConnector.javaView source code 6 votesvote downvote up
/**
 * During handshaking, if the URL's hostname and the server's identification hostname mismatch,
 * the verification mechanism can call back to this verifier to make a decision.
 *
 * @return {@link javax.net.ssl.HostnameVerifier} implementation instance according to connector's config.
 */
private HostnameVerifier getHostnameVerifier() {
    if (getConnectorConfig().isHostVerificationEnabled()) {
        return new BrowserCompatHostnameVerifier();
    }
    return new AllowAllHostnameVerifier();
}
 
Example 14
Project: hq   File: DefaultSSLProviderImpl.javaView source code 6 votesvote downvote up
private X509HostnameVerifier getHostnameVerifier() {
    return new X509HostnameVerifier() {
        private AllowAllHostnameVerifier internalVerifier = new AllowAllHostnameVerifier();
        public boolean verify(String host, SSLSession session) {
            return internalVerifier.verify(host, session);
        }
        public void verify(String host, String[] cns, String[] subjectAlts)
            throws SSLException {
            internalVerifier.verify(host, cns, subjectAlts);
        }
        public void verify(String host, X509Certificate cert)
            throws SSLException {
            internalVerifier.verify(host, cert);
        }
        public void verify(String host, SSLSocket ssl) throws IOException {
            try {
                internalVerifier.verify(host, ssl);
            } catch (SSLPeerUnverifiedException e) {
                SSLPeerUnverifiedException sslPeerUnverifiedException =
                    new SSLPeerUnverifiedException("The authenticity of host '" + host +
                                                   "' can't be established: " + e);
                sslPeerUnverifiedException.initCause(e);
                throw sslPeerUnverifiedException;
            }
        }
    };
}
 
Example 15
Project: atsd-api-java   File: HttpClient.javaView source code 6 votesvote downvote up
static PoolingHttpClientConnectionManager createConnectionManager(ClientConfiguration clientConfiguration, SslConfigurator sslConfig) {
    SSLContext sslContext = sslConfig.createSSLContext();
    X509HostnameVerifier hostnameVerifier;
    if (clientConfiguration.isIgnoreSSLErrors()) {
        ignoreSslCertificateErrorInit(sslContext);
        hostnameVerifier = new AllowAllHostnameVerifier();
    } else {
        hostnameVerifier = new StrictHostnameVerifier();
    }

    LayeredConnectionSocketFactory sslSocketFactory = new SSLConnectionSocketFactory(
            sslContext,
            hostnameVerifier);

    final Registry<ConnectionSocketFactory> registry = RegistryBuilder.<ConnectionSocketFactory>create()
            .register("http", PlainConnectionSocketFactory.getSocketFactory())
            .register("https", sslSocketFactory)
            .build();
    return new PoolingHttpClientConnectionManager(registry);
}
 
Example 16
Project: buddydroid   File: TrustAllSSLSocketFactory.javaView source code 6 votesvote downvote up
public TrustAllSSLSocketFactory() throws KeyManagementException, NoSuchAlgorithmException, KeyStoreException, UnrecoverableKeyException { 
    super(null); 
        try { 
            SSLContext sslcontext = SSLContext.getInstance("TLS"); 
            sslcontext.init(null, new TrustManager[] { new TrustAllManager() }, null);
            factory = sslcontext.getSocketFactory();
            setHostnameVerifier(new AllowAllHostnameVerifier());             
        } catch(Exception ex) { } 
}
 
Example 17
Project: YourAppIdea   File: TrustAllSSLSocketFactory.javaView source code 6 votesvote downvote up
public TrustAllSSLSocketFactory() throws KeyManagementException, NoSuchAlgorithmException, KeyStoreException, UnrecoverableKeyException {
    super(null);
        try {
            SSLContext sslcontext = SSLContext.getInstance("TLS");
            sslcontext.init(null, new TrustManager[] { new TrustAllManager() }, null);
            factory = sslcontext.getSocketFactory();
            setHostnameVerifier(new AllowAllHostnameVerifier());
        } catch(Exception ex) { }
}
 
Example 18
Project: Osmand   File: LiveMonitoringHelper.javaView source code 5 votesvote downvote up
public void sendData(LiveMonitoringData data) {
	String st = settings.LIVE_MONITORING_URL.get();
	List<String> prm = new ArrayList<String>();
	int maxLen = 0;
	for(int i = 0; i < 7; i++) {
		boolean b = st.contains("{"+i+"}");
		if(b) {
			maxLen = i;
		}
	}
	for (int i = 0; i < maxLen + 1; i++) {
		switch (i) {
		case 0:
			prm.add(data.lat + "");
			break;
		case 1:
			prm.add(data.lon + "");
			break;
		case 2:
			prm.add(data.time + "");
			break;
		case 3:
			prm.add(data.hdop + "");
			break;
		case 4:
			prm.add(data.alt + "");
			break;
		case 5:
			prm.add(data.speed + "");
			break;
		case 6:
			prm.add(data.bearing + "");
			break;

		default:
			break;
		}
	}
	String url = MessageFormat.format(st, prm.toArray());
	try {

		HttpParams params = new BasicHttpParams();
		HttpConnectionParams.setConnectionTimeout(params, 15000);
		DefaultHttpClient httpclient = new DefaultHttpClient(params);
		//allow certificates where hostnames doesn't match CN
		SSLSocketFactory sf = (SSLSocketFactory) httpclient.getConnectionManager().getSchemeRegistry().getScheme("https").getSocketFactory();
		sf.setHostnameVerifier(new AllowAllHostnameVerifier());
		// Parse the URL and let the URI constructor handle proper encoding of special characters such as spaces
		URL u = new URL(url);
		URI uri = new URI(u.getProtocol(), u.getUserInfo(), u.getHost(), u.getPort(), u.getPath(), u.getQuery(), u.getRef());
		HttpRequestBase method = new HttpGet(uri);
		log.info("Monitor " + uri);
		HttpResponse response = httpclient.execute(method);
		
		if(response.getStatusLine() == null || 
			response.getStatusLine().getStatusCode() != 200){
			
			String msg;
			if(response.getStatusLine() == null){
				msg = ctx.getString(R.string.failed_op); //$NON-NLS-1$
			} else {
				msg = response.getStatusLine().getStatusCode() + " : " + //$NON-NLS-1$//$NON-NLS-2$
						response.getStatusLine().getReasonPhrase();
			}
			log.error("Error sending monitor request: " +  msg);
		} else {
			InputStream is = response.getEntity().getContent();
			StringBuilder responseBody = new StringBuilder();
			if (is != null) {
				BufferedReader in = new BufferedReader(new InputStreamReader(is, "UTF-8")); //$NON-NLS-1$
				String s;
				while ((s = in.readLine()) != null) {
					responseBody.append(s);
					responseBody.append("\n"); //$NON-NLS-1$
				}
				is.close();
			}
			httpclient.getConnectionManager().shutdown();
			log.info("Monitor response (" + response.getFirstHeader("Content-Type") + "): " + responseBody.toString());
		}

		
	} catch (Exception e) {
		log.error("Failed connect to " + url + ": " + e.getMessage(), e);
	}
}
 
Example 19
Project: fullstop   File: TestAsyncIT.java View source code 5 votesvote downvote up
@Test
public void run() throws InterruptedException {

    threadPoolTaskExecutor.setCorePoolSize(8);
    threadPoolTaskExecutor.setMaxPoolSize(10);
    threadPoolTaskExecutor.setQueueCapacity(100);
    threadPoolTaskExecutor.setAllowCoreThreadTimeOut(true);
    threadPoolTaskExecutor.setKeepAliveSeconds(30);
    threadPoolTaskExecutor.setThreadGroupName("elb-check-group");
    threadPoolTaskExecutor.setThreadNamePrefix("elb-check-");
    threadPoolTaskExecutor.setRejectedExecutionHandler(new ThreadPoolExecutor.CallerRunsPolicy());
    threadPoolTaskExecutor.setDaemon(true);
    threadPoolTaskExecutor.setWaitForTasksToCompleteOnShutdown(true);
    threadPoolTaskExecutor.afterPropertiesSet();

    try {
        httpclient = HttpClientBuilder.create()
                                      .disableAuthCaching()
                                      .disableAutomaticRetries()
                                      .disableConnectionState()
                                      .disableCookieManagement()
                                      .disableRedirectHandling()
                                      .setDefaultRequestConfig(config)
                                      .setHostnameVerifier(new AllowAllHostnameVerifier())
                                      .setSslcontext(
                                              new SSLContextBuilder()
                                                      .loadTrustMaterial(
                                                              null,
                                                              (arrayX509Certificate, value) -> true)
                                                      .build())
                                      .build();
    }
    catch (NoSuchAlgorithmException | KeyManagementException | KeyStoreException e) {
        e.printStackTrace();
        // TODO: handle this!!!
    }

    List<String> addresses = newArrayList(
            "www.google.de", "www.google.it", "www.google.com",
            "www.google.de", "www.google.it", "www.google.com",
            "www.google.de", "www.google.it", "www.google.com",
            "www.google.de", "www.google.it", "www.google.com",
            "www.google.de", "www.google.it", "www.google.com",
            "www.google.de", "www.google.it", "www.google.com",
            "www.google.de", "www.google.it", "www.google.com",
            "www.google.de", "www.google.it", "www.google.com",
            "www.google.de", "www.google.it", "www.google.com",
            "www.google.de", "www.google.it", "www.google.com",
            "www.google.de", "www.google.it", "www.google.com",
            "www.google.de", "www.google.it", "www.google.com",
            "www.google.de", "www.google.it", "www.google.com",
            "www.google.de", "www.google.it", "www.google.com",
            "www.google.de", "www.google.it", "www.google.com",
            "www.google.de", "www.google.it", "www.google.com",
            "www.google.de", "www.google.it", "www.google.com",
            "www.google.de", "www.google.it", "www.google.com",
            "www.google.de", "www.google.it", "www.google.com",
            "www.google.de", "www.google.it", "www.google.com",
            "www.google.de", "www.google.it", "www.google.com",
            "www.google.de", "www.google.it", "www.google.com",
            "www.google.de", "www.google.it", "www.google.com",
            "www.google.de", "www.google.it", "www.google.com",
            "www.google.de", "www.google.it", "www.google.com",
            "www.google.de", "www.google.it", "www.google.com",
            "www.google.de", "www.google.it", "www.google.com",
            "www.google.de", "www.google.it", "www.google.com",
            "www.google.de", "www.google.it", "www.google.com",
            "www.google.de", "www.google.it", "www.google.com");

    for (String address : addresses) {

        for (Integer allowedPort : allowedPorts) {

            HttpCall httpCall = new HttpCall(httpclient, address, allowedPort);
            ListenableFuture<Void> listenableFuture = threadPoolTaskExecutor.submitListenable(httpCall);
            listenableFuture.addCallback(
                    new SuccessCallback<Void>() {
                        @Override public void onSuccess(Void result) {
                            log.info("address: {} and port: {}", address, allowedPort);
                        }
                    }, new FailureCallback() {
                        @Override public void onFailure(Throwable ex) {
                            log.warn(ex.getMessage(), ex);
                        }
                    });

            log.info("getActiveCount: {}", threadPoolTaskExecutor.getActiveCount());
            log.info("### - Thread: {}", Thread.currentThread().getId());
        }
    }

    //TODO: important use this to let the test run all thread!
    //TimeUnit.MINUTES.sleep(5);
}
 
Example 20
Project: notes2cloud   File: Utils.java View source code 5 votesvote downvote up
public Utils() {
  try {
    Properties dflt = new Properties();
    InputStream is = ClassLoader.getSystemResourceAsStream("notes2cloud.properties");
    if (is == null)
      throw new RuntimeException("Can't find notes2cloud.properties on classpath");
    dflt.load(is);
    is.close();

    String userFileName = System.getProperty("user.home") + File.separator + "notes2cloud.properties";
    File userFile = new File(userFileName);
    if (!userFile.exists())
      throw new RuntimeException("Cannot find user property file " + userFileName);
    if (!userFile.canRead())
      throw new RuntimeException("User property file not readable " + userFileName);
    FileInputStream fis = new FileInputStream(userFile);
    props = new Properties(dflt);
    props.load(fis);
    fis.close();

  } catch (Exception e) {
    throw new RuntimeException("Error loading properties", e);
  }

  try {
    HttpParams params = new BasicHttpParams();
    params.setParameter(ClientPNames.COOKIE_POLICY, org.apache.http.client.params.CookiePolicy.BROWSER_COMPATIBILITY);
    params.setParameter(CoreProtocolPNames.USER_AGENT, getProperty("userAgent"));
    http = new DefaultHttpClient(new SingleClientConnManager());

    if ("false".equals(getProperty("sslValidation"))) {
      SSLContext sslContext = SSLContext.getInstance("SSL");
      sslContext.init(null, new TrustManager[]{new X509TrustManager() {
        public void checkClientTrusted(X509Certificate[] arg0, String arg1) throws CertificateException {
        }

        public void checkServerTrusted(X509Certificate[] arg0, String arg1) throws CertificateException {
        }

        public X509Certificate[] getAcceptedIssuers() {
          return new X509Certificate[0];
        }
      }}, null);
      SSLSocketFactory factory = new SSLSocketFactory(sslContext, new AllowAllHostnameVerifier());
      Scheme https = new Scheme("https", 443, factory);
      SchemeRegistry schemeRegistry = http.getConnectionManager().getSchemeRegistry();
      schemeRegistry.register(https);
    }

    URI uri = new URI(getProperty("cloud.baseUrl"));
    http.getCredentialsProvider().setCredentials(
      new AuthScope(uri.getHost(), uri.getPort()),
      new UsernamePasswordCredentials(getProperty("cloud.userId"), getProperty("cloud.password")));

  } catch (Exception e) {
    throw new RuntimeException("Error creating httpclient", e);
  }
}
 
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值