当前位置: 首页>>代码示例>>Java>>正文


Java Executor.newInstance方法代码示例

本文整理汇总了Java中org.apache.http.client.fluent.Executor.newInstance方法的典型用法代码示例。如果您正苦于以下问题:Java Executor.newInstance方法的具体用法?Java Executor.newInstance怎么用?Java Executor.newInstance使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在org.apache.http.client.fluent.Executor的用法示例。


在下文中一共展示了Executor.newInstance方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: testProxyAuthWithSSL

import org.apache.http.client.fluent.Executor; //导入方法依赖的package包/类
@Test
public void testProxyAuthWithSSL() throws Exception {
    SSLContext sslContext = new SSLContextBuilder()
            .loadTrustMaterial(new File(keyStoreFile), keystorePW.toCharArray(), new TrustSelfSignedStrategy())
            .build();

    try (CloseableHttpClient httpclient = HttpClients.custom().setSSLContext(sslContext)
            .setSSLHostnameVerifier(new HostnameVerifier() {

                @Override
                public boolean verify(String hostname, SSLSession session) {
                    return true;
                }

            }).build()) {
        Executor ex = Executor.newInstance(httpclient);
        Response response = ex.execute(Request.Get("https://localhost:9200/blahobar.234324234/logs/1")
                .addHeader("Authorization", String.format("Bearer %s", token))
                .addHeader("X-Proxy-Remote-User", proxyUser));
        System.out.println(response.returnContent().asString());
    } catch (Exception e) {
        System.out.println(e);
        fail("Test Failed");
    }
}
 
开发者ID:fabric8io,项目名称:openshift-elasticsearch-plugin,代码行数:26,代码来源:HttpsProxyClientCertAuthenticatorIntegrationTest.java

示例2: setUpClass

import org.apache.http.client.fluent.Executor; //导入方法依赖的package包/类
@BeforeClass
public static void setUpClass() throws Exception {
    conf = new Configuration(CONF_FILE_PATH);
    MongoDBClientSingleton.init(conf);
    mongoClient = MongoDBClientSingleton.getInstance().getClient();

    BASE_URL = "http://" + conf.getHttpHost() + ":" + conf.getHttpPort();

    createURIs();

    final String host = MONGO_HOST;
    final int port = conf.getHttpPort();
    adminExecutor = Executor.newInstance().authPreemptive(new HttpHost(host, port, HTTP)).auth(new HttpHost(host), "admin", "changeit");
    user1Executor = Executor.newInstance().authPreemptive(new HttpHost(host, port, HTTP)).auth(new HttpHost(host), "user1", "changeit");
    user2Executor = Executor.newInstance().authPreemptive(new HttpHost(host, port, HTTP)).auth(new HttpHost(host), "user2", "changeit");
    unauthExecutor = Executor.newInstance();
}
 
开发者ID:SoftInstigate,项目名称:restheart,代码行数:18,代码来源:HttpClientAbstactIT.java

示例3: reload

import org.apache.http.client.fluent.Executor; //导入方法依赖的package包/类
public void reload(boolean initial) {
    if ( initial ) {
        Runnable onChange = new Runnable() {
            @Override
            public void run() {
                reload(false);
            }
        };

        INDEX_URL.addCallback(onChange);
        INDEX_USER.addCallback(onChange);
        INDEX_PASS.addCallback(onChange);
    }

    log.info("Using docker index url [{}] and user [{}]", INDEX_URL.get(), INDEX_USER.get());

    Executor executor = Executor.newInstance();
    if ( ! StringUtils.isBlank(INDEX_USER.get()) ) {
        executor = executor.auth(INDEX_USER.get(), INDEX_PASS.get());
    }

    this.executor = executor;
}
 
开发者ID:cloudnautique,项目名称:cloud-cattle,代码行数:24,代码来源:DockerClient.java

示例4: executor

import org.apache.http.client.fluent.Executor; //导入方法依赖的package包/类
private Executor executor() {
  if (executor == null) {
    if (this.host.startsWith("https://")) {
      try {
        SSLContext sslContext = SSLContexts.custom()
            .loadTrustMaterial(null, (chain, authType) -> true)
            .build();
        builder.setSSLContext(sslContext);
        builder.setSSLHostnameVerifier(NoopHostnameVerifier.INSTANCE);
      } catch (Exception ex) {
        Throwables.propagate(ex);
      }
    }
    client = builder.build();
    executor = Executor.newInstance(client);
    if (creds != null) {
      executor.auth(creds);
    }
  }
  return executor;
}
 
开发者ID:jooby-project,项目名称:jooby,代码行数:22,代码来源:Client.java

示例5: createExecutor

import org.apache.http.client.fluent.Executor; //导入方法依赖的package包/类
public static Executor createExecutor(CookieStore cookieStore) {
    @SuppressWarnings("deprecation") final Registry<CookieSpecProvider> cookieSpecRegistry =
            RegistryBuilder.<CookieSpecProvider>create().register(CookieSpecs.DEFAULT, new BrowserCompatSpecFactory()).build();
    final CloseableHttpClient client = HttpClients.custom()
            .setDefaultCookieSpecRegistry(cookieSpecRegistry)
            .setDefaultCookieStore(cookieStore)
            .build();
    return Executor.newInstance(client);
}
 
开发者ID:Roboroxx,项目名称:itunesconnect-api,代码行数:10,代码来源:Utils.java

示例6: loadManifest

import org.apache.http.client.fluent.Executor; //导入方法依赖的package包/类
public static Content loadManifest(String folder, String owner, String repo) throws IOException {
    String projecUrl = "https://api.github.com/repos/"+owner+"/"+repo;
    String title = null;
    log.debug("Tentative de connexion à l'url : "+projecUrl);
    String githubUser = System.getProperty("zw.github_user");
    String githubToken = System.getProperty("zw.github_token");

    Executor executor;
    if(githubUser != null && !"".equals(githubUser) && githubToken != null && !"".equals(githubToken)) {
        executor = Executor
                .newInstance()
                .auth(new HttpHost("api.github.com"), githubUser, githubToken);
    } else {
        executor = Executor.newInstance();
    }

    String json = executor.execute(Request.Get(projecUrl)).returnContent().asString();
    ObjectMapper mapper = new ObjectMapper();
    Map map = mapper.readValue(json, Map.class);
    if(map.containsKey("description")) {
        title = (String) map.get("description");
    }
    Content current = new Content("container", toSlug(title), title, Constant.DEFAULT_INTRODUCTION_FILENAME, Constant.DEFAULT_CONCLUSION_FILENAME, new ArrayList<>(), 2, "CC-BY", title, "TUTORIAL");
    // read all directory
    current.getChildren ().addAll (loadDirectory (folder.length () + File.separator.length (), new File(folder)));
    current.setBasePath (folder);
    generateMetadataAttributes(current.getFilePath());
    return current;
}
 
开发者ID:firm1,项目名称:zest-writer,代码行数:30,代码来源:GithubHttp.java

示例7: getExecutor

import org.apache.http.client.fluent.Executor; //导入方法依赖的package包/类
private static Executor getExecutor(boolean useSSL) throws KeyManagementException, NoSuchAlgorithmException {
	Executor executor = null;
	if (useSSL){
		executor = Executor.newInstance(Utility.getTrustedHttpClient());
	}
	else{
		executor = Executor.newInstance();
	}
	return executor;
}
 
开发者ID:CognitiveBuild,项目名称:Chatbot,代码行数:11,代码来源:Utility.java

示例8: WebreportsAPI

import org.apache.http.client.fluent.Executor; //导入方法依赖的package包/类
public WebreportsAPI(HttpClient apacheHttpClient,URI uri, String username, String password)
		throws JAXBException, Exception {
	this.baseURI = uri;
	
	client = Executor.newInstance(apacheHttpClient);
	this.username = username;
	this.password = password;
	initializeJAXB();
}
 
开发者ID:eyce9000,项目名称:iem4j,代码行数:10,代码来源:WebreportsAPI.java

示例9: ConsulFacadeBean

import org.apache.http.client.fluent.Executor; //导入方法依赖的package包/类
public ConsulFacadeBean(final String consulUrl, final Optional<String> username, final Optional<String> password,
		final int ttlInSeconds, final int lockDelayInSeconds, final boolean allowIslandMode, final int createSessionTries, final int retryPeriod, final double backOffMultiplier)
		throws MalformedURLException {
	this(consulUrl, username, password, Executor.newInstance());
	this.ttlInSeconds = ttlInSeconds;
	this.lockDelayInSeconds = lockDelayInSeconds;
	this.createSessionTries = createSessionTries;
	this.retryPeriod = retryPeriod;
	this.backOffMultiplier = backOffMultiplier;
}
 
开发者ID:jhberges,项目名称:camel-consul-leader,代码行数:11,代码来源:ConsulFacadeBean.java

示例10: createExecutor

import org.apache.http.client.fluent.Executor; //导入方法依赖的package包/类
private static Executor createExecutor(ClientConfig config) {
    Executor retval = Executor.newInstance();
    retval.auth(config.getEndpointHost(), config.getUsername(), config.getPassword());
    if (config.hasProxy() && config.isProxyAuthenticated()) {
        retval.auth(config.getProxyHost(), config.getProxyUsername(), config.getProxyPassword());
    }
    return retval;
}
 
开发者ID:woki,项目名称:adyen-api,代码行数:9,代码来源:Endpoint.java

示例11: HttpSession

import org.apache.http.client.fluent.Executor; //导入方法依赖的package包/类
public HttpSession(GerritServer server, @Nullable TestAccount account) {
  this.url = CharMatcher.is('/').trimTrailingFrom(server.getUrl());
  URI uri = URI.create(url);
  this.executor = Executor.newInstance();
  this.account = account;
  if (account != null) {
    executor.auth(
        new HttpHost(uri.getHost(), uri.getPort()), account.username, account.httpPassword);
  }
}
 
开发者ID:gerrit-review,项目名称:gerrit,代码行数:11,代码来源:HttpSession.java

示例12: Rest

import org.apache.http.client.fluent.Executor; //导入方法依赖的package包/类
/**
 * Constructor sets schema(http or https), host(google.com) and port number(8080) using one hostPort parameter
 * 
 * @param hostPort URL
 */
public Rest(String hostPort) {
    headers = new LinkedList<>();
    if (!hostPort.endsWith("/")) {
        hostPort = hostPort + "/";
    }
    this.hostPort = hostPort;

    contentType = ContentType.create("application/json", StandardCharsets.UTF_8);

    executor = Executor.newInstance(createHttpClient());
    executor.use(new BasicCookieStore());
}
 
开发者ID:Talend,项目名称:components,代码行数:18,代码来源:Rest.java

示例13: AbstractStreamsConnection

import org.apache.http.client.fluent.Executor; //导入方法依赖的package包/类
/**
 * Connection to IBM Streams
 * 
 * @param authorization
 *            String representing Authorization header used for connections.
 * @param allowInsecure
 *            Flag to allow insecure TLS/SSL connections. This is
 *            <strong>not</strong> recommended in a production environment
 * @param resourcesUrl
 *            String representing the root url to the REST API resources,
 *            for example: https://server:port/streams/rest/resources
 */
AbstractStreamsConnection(String authorization, String resourcesUrl,
        boolean allowInsecure) throws IOException {
    this.authorization = authorization;
    this.resourcesUrl = resourcesUrl;
    // Create the executor with a custom verifier if insecure connections
    // were requested
    try {
        if (allowInsecure) {
            // Insecure host connections were requested, try to set up
            CloseableHttpClient httpClient = HttpClients.custom()
                    .setHostnameVerifier(new AllowAllHostnameVerifier())
                    .setSslcontext(new SSLContextBuilder()
                            .loadTrustMaterial(null, new TrustStrategy() {
                                public boolean isTrusted(X509Certificate[] arg0, String arg1) throws CertificateException {
                                    return true;
                                }
                            }).build()).build();
            executor = Executor.newInstance(httpClient);
            traceLog.info("Insecure Host Connection enabled");
        } else {
            // Default, secure host connections
            executor = Executor.newInstance();
        }
    } catch (NoSuchAlgorithmException | KeyStoreException | KeyManagementException e) {
        // Insecure was requested but could not be set up
        executor = Executor.newInstance();
        traceLog.info("Could not set up Insecure Host Connection");
    }
}
 
开发者ID:IBMStreams,项目名称:streamsx.topology,代码行数:42,代码来源:AbstractStreamsConnection.java

示例14: newExecutor

import org.apache.http.client.fluent.Executor; //导入方法依赖的package包/类
@NotNull private Executor newExecutor() {
    return Executor.newInstance(HttpClientBuilder.create().build());
}
 
开发者ID:vertretungsplanme,项目名称:substitution-schedule-parser,代码行数:4,代码来源:LoginHandlerTest.java

示例15: activate

import org.apache.http.client.fluent.Executor; //导入方法依赖的package包/类
@Activate
protected void activate(Map<String, Object> config) throws Exception {
    boolean useSSL = PropertiesUtil.toBoolean(config.get(PROP_USE_SSL), DEFAULT_USE_SSL);

    String scheme = useSSL ? "https" : "http";
    String hostname = PropertiesUtil.toString(config.get(PROP_HOST_DOMAIN), null);
    int port = PropertiesUtil.toInteger(config.get(PROP_GATEWAY_PORT), 0);

    if (hostname == null || port == 0) {
        throw new IllegalArgumentException("Configuration not valid. Both host and port must be provided.");
    }

    baseUrl = String.format("%s://%s:%s", scheme, hostname, port);

    int connectTimeout = PropertiesUtil.toInteger(config.get(PROP_CONNECT_TIMEOUT), DEFAULT_CONNECT_TIMEOUT);
    int soTimeout = PropertiesUtil.toInteger(config.get(PROP_SO_TIMEOUT), DEFAULT_SOCKET_TIMEOUT);

    HttpClientBuilder builder = httpClientBuilderFactory.newBuilder();

    RequestConfig requestConfig = RequestConfig.custom()
            .setConnectTimeout(connectTimeout)
            .setSocketTimeout(soTimeout)
            .build();
    builder.setDefaultRequestConfig(requestConfig);

    boolean disableCertCheck = PropertiesUtil.toBoolean(config.get(PROP_DISABLE_CERT_CHECK), DEFAULT_DISABLE_CERT_CHECK);

    if (useSSL && disableCertCheck) {
        SSLContext sslContext = new SSLContextBuilder().loadTrustMaterial(null, new TrustStrategy() {
            public boolean isTrusted(X509Certificate[] arg0, String arg1) throws CertificateException {
                return true;
            }
        }).build();
        builder.setHostnameVerifier(new AllowAllHostnameVerifier()).setSslcontext(sslContext);
    }
    httpClient = builder.build();
    executor = Executor.newInstance(httpClient);

    String username = PropertiesUtil.toString(config.get(PROP_USERNAME), null);
    String password = PropertiesUtil.toString(config.get(PROP_PASSWORD), null);
    if (username != null && password != null) {
        HttpHost httpHost = new HttpHost(hostname, port, useSSL ? "https" : "http");
        executor.auth(httpHost, username, password).authPreemptive(httpHost);
    }
}
 
开发者ID:Adobe-Consulting-Services,项目名称:acs-aem-commons,代码行数:46,代码来源:HttpClientFactoryImpl.java


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