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


Java ClientBuilder.hostnameVerifier方法代码示例

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


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

示例1: createClientFromConfig

import javax.ws.rs.client.ClientBuilder; //导入方法依赖的package包/类
private static Client createClientFromConfig(NiFiRegistryClientConfig registryClientConfig) {

        final ClientConfig clientConfig = new ClientConfig();
        clientConfig.register(jacksonJaxbJsonProvider());

        final ClientBuilder clientBuilder = ClientBuilder.newBuilder().withConfig(clientConfig);

        final SSLContext sslContext = registryClientConfig.getSslContext();
        if (sslContext != null) {
            clientBuilder.sslContext(sslContext);
        }

        final HostnameVerifier hostnameVerifier = registryClientConfig.getHostnameVerifier();
        if (hostnameVerifier != null) {
            clientBuilder.hostnameVerifier(hostnameVerifier);
        }

        return clientBuilder.build();
    }
 
开发者ID:apache,项目名称:nifi-registry,代码行数:20,代码来源:IntegrationTestBase.java

示例2: configure

import javax.ws.rs.client.ClientBuilder; //导入方法依赖的package包/类
@Override
public void configure(HttpConfig config, ScriptContext context) {
    ClientConfig cc = new ClientConfig();
    // support request body for DELETE (non-standard)
    cc.property(ClientProperties.SUPPRESS_HTTP_COMPLIANCE_VALIDATION, true);
    if (!config.isFollowRedirects()) {
        cc.property(ClientProperties.FOLLOW_REDIRECTS, false);
    }
    ClientBuilder clientBuilder = ClientBuilder.newBuilder()
            .withConfig(cc)
            .register(new LoggingInterceptor(context)) // must be first
            .register(MultiPartFeature.class);
    if (config.isSslEnabled()) {
        SSLContext sslContext;
        if (config.getSslTrustStore() != null) {
            String trustStoreFile = config.getSslTrustStore();                
            String password = config.getSslTrustStorePassword();
            char[] passwordChars = password == null ? null : password.toCharArray();
            String algorithm = config.getSslAlgorithm();
            String type = config.getSslTrustStoreType();
            if (type == null) {
                type = KeyStore.getDefaultType();
            }
            try {
                KeyStore trustStore = KeyStore.getInstance(type);
                InputStream is = FileUtils.getFileStream(trustStoreFile, context);
                trustStore.load(is, passwordChars);
                context.logger.debug("trust store key count: {}", trustStore.size());
                sslContext = SslConfigurator.newInstance()
                        .securityProtocol(algorithm) // will default to TLS if null
                        .trustStore(trustStore)
                        // .keyStore(trustStore)
                        .createSSLContext();
            } catch (Exception e) {
                context.logger.error("ssl config failed: {}", e.getMessage());
                throw new RuntimeException(e);
            }                
        } else {
            sslContext = HttpUtils.getSslContext(config.getSslAlgorithm());
        }
        HttpsURLConnection.setDefaultSSLSocketFactory(sslContext.getSocketFactory());
        clientBuilder.sslContext(sslContext);
        clientBuilder.hostnameVerifier((host, session) -> true);
    }
    client = clientBuilder.build();
    client.property(ClientProperties.CONNECT_TIMEOUT, config.getConnectTimeout());
    client.property(ClientProperties.READ_TIMEOUT, config.getReadTimeout());
    if (config.getProxyUri() != null) {
        client.property(ClientProperties.PROXY_URI, config.getProxyUri());
        if (config.getProxyUsername() != null && config.getProxyPassword() != null) {
            client.property(ClientProperties.PROXY_USERNAME, config.getProxyUsername());
            client.property(ClientProperties.PROXY_PASSWORD, config.getProxyPassword());
        }
    }
}
 
开发者ID:intuit,项目名称:karate,代码行数:56,代码来源:JerseyHttpClient.java

示例3: createBackup

import javax.ws.rs.client.ClientBuilder; //导入方法依赖的package包/类
public static BackupStats createBackup(DACConfig dacConfig, String userName, String password, KeyStore trustStore, URI uri) throws IOException {
  final JacksonJaxbJsonProvider provider = new JacksonJaxbJsonProvider();
  provider.setMapper(JSONUtil.prettyMapper());
  ClientBuilder clientBuilder = ClientBuilder.newBuilder()
      .register(provider)
      .register(MultiPartFeature.class);

  if (trustStore != null) {
    clientBuilder.trustStore(trustStore);
  } else {
    SSLContext sslContext = SSLHelper.newAllTrustingSSLContext("SSL");
    HostnameVerifier verifier = SSLHelper.newAllValidHostnameVerifier();
    clientBuilder.hostnameVerifier(verifier);
    clientBuilder.sslContext(sslContext);
  }

  final Client client = clientBuilder.build();
  WebTarget target = client.target(format("%s://%s:%d",
      dacConfig.webSSLEnabled ? "https" : "http", dacConfig.masterNode, dacConfig.getHttpPort())).path("apiv2");

  final UserLogin userLogin = new UserLogin(userName, password);
  final UserLoginSession userLoginSession = readEntity(UserLoginSession.class, target.path("/login").request(JSON).buildPost(Entity.json(userLogin)));


  return readEntity(BackupStats.class, target.path("/backup").request(JSON).header(HttpHeader.AUTHORIZATION.toString(),
    TokenUtils.AUTH_HEADER_PREFIX + userLoginSession.getToken()).buildPost(Entity.json(uri.toString())));
}
 
开发者ID:dremio,项目名称:dremio-oss,代码行数:28,代码来源:Backup.java

示例4: JerseyNiFiRegistryClient

import javax.ws.rs.client.ClientBuilder; //导入方法依赖的package包/类
private JerseyNiFiRegistryClient(final NiFiRegistryClient.Builder builder) {
    final NiFiRegistryClientConfig registryClientConfig = builder.getConfig();
    if (registryClientConfig == null) {
        throw new IllegalArgumentException("NiFiRegistryClientConfig cannot be null");
    }

    String baseUrl = registryClientConfig.getBaseUrl();
    if (StringUtils.isBlank(baseUrl)) {
        throw new IllegalArgumentException("Base URL cannot be blank");
    }

    if (baseUrl.endsWith("/")) {
        baseUrl = baseUrl.substring(0, baseUrl.length() - 1);
    }

    if (!baseUrl.endsWith(NIFI_REGISTRY_CONTEXT)) {
        baseUrl = baseUrl + "/" + NIFI_REGISTRY_CONTEXT;
    }

    try {
        new URI(baseUrl);
    } catch (final Exception e) {
        throw new IllegalArgumentException("Invalid base URL: " + e.getMessage(), e);
    }

    final SSLContext sslContext = registryClientConfig.getSslContext();
    final HostnameVerifier hostnameVerifier = registryClientConfig.getHostnameVerifier();

    final ClientBuilder clientBuilder = ClientBuilder.newBuilder();
    if (sslContext != null) {
        clientBuilder.sslContext(sslContext);
    }
    if (hostnameVerifier != null) {
        clientBuilder.hostnameVerifier(hostnameVerifier);
    }

    final int connectTimeout = registryClientConfig.getConnectTimeout() == null ? DEFAULT_CONNECT_TIMEOUT : registryClientConfig.getConnectTimeout();
    final int readTimeout = registryClientConfig.getReadTimeout() == null ? DEFAULT_READ_TIMEOUT : registryClientConfig.getReadTimeout();

    final ClientConfig clientConfig = new ClientConfig();
    clientConfig.property(ClientProperties.CONNECT_TIMEOUT, connectTimeout);
    clientConfig.property(ClientProperties.READ_TIMEOUT, readTimeout);
    clientConfig.register(jacksonJaxbJsonProvider());
    clientBuilder.withConfig(clientConfig);
    this.client = clientBuilder.build();

    this.baseTarget = client.target(baseUrl);
    this.bucketClient = new JerseyBucketClient(baseTarget);
    this.flowClient = new JerseyFlowClient(baseTarget);
    this.flowSnapshotClient = new JerseyFlowSnapshotClient(baseTarget);
    this.itemsClient = new JerseyItemsClient(baseTarget);
}
 
开发者ID:apache,项目名称:nifi-registry,代码行数:53,代码来源:JerseyNiFiRegistryClient.java


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