本文整理了Java中javax.ws.rs.client.ClientBuilder.hostnameVerifier()
方法的一些代码示例,展示了ClientBuilder.hostnameVerifier()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。ClientBuilder.hostnameVerifier()
方法的具体详情如下:
包路径:javax.ws.rs.client.ClientBuilder
类名称:ClientBuilder
方法名:hostnameVerifier
[英]Set the hostname verifier to be used by the client to verify the endpoint's hostname against it's identification information.
[中]设置客户端使用的主机名验证器,以根据端点的标识信息验证端点的主机名。
代码示例来源:origin: apache/nifi
clientBuilder.hostnameVerifier(hostnameVerifier);
代码示例来源:origin: apache/nifi
/**
* A helper method for creating clients. The client will be created using
* the given configuration and security context. Additionally, the client
* will be automatically configured for JSON serialization/deserialization.
*
* @param config client configuration
* @param ctx security context, which may be null for non-secure client
* creation
* @return a Client instance
*/
private static Client createClientHelper(final ClientConfig config, final SSLContext ctx) {
ClientBuilder clientBuilder = ClientBuilder.newBuilder();
if (config != null) {
clientBuilder = clientBuilder.withConfig(config);
}
if (ctx != null) {
// Apache http DefaultHostnameVerifier that checks subject alternative names against the hostname of the URI
clientBuilder = clientBuilder.sslContext(ctx).hostnameVerifier(new DefaultHostnameVerifier());
}
clientBuilder = clientBuilder.register(ObjectMapperResolver.class).register(JacksonJaxbJsonProvider.class);
return clientBuilder.build();
}
代码示例来源:origin: Netflix/eureka
clientBuilder.hostnameVerifier(hostnameVerifier);
代码示例来源:origin: com.github.jmnarloch/spring-jax-rs-client-proxy
/**
* Registers the hostname verifier.
*
* @param hostnameVerifier the hostname verifier
* @return the builder instance
*/
public ClientBuilderConfigurer hostnameVerifier(HostnameVerifier hostnameVerifier) {
builder().hostnameVerifier(hostnameVerifier);
return this;
}
代码示例来源:origin: stackoverflow.com
ClientBuilder builder = ClientBuilder.newBuilder();
builder.sslContext(ConnectionFactory.getSslContext());
builder.hostnameVerifier(ConnectionFactory.getHostnameVerifier());
client = builder.build();
String baseURI = acsUser.getSelectedService().getWebserviceBaseUrl();
WebTarget webTarget = client.target(baseURI);
代码示例来源:origin: org.mule.tools.maven/mule-maven-plugin
protected void configureSecurityContext(ClientBuilder builder)
{
if (armInsecure)
{
try
{
SSLContext sslcontext = SSLContext.getInstance("TLS");
sslcontext.init(null, new TrustManager[] { new TrustAllManager() }, new java.security.SecureRandom());
builder.hostnameVerifier(new DummyHostnameVerifier()).sslContext(sslcontext);
}
catch (KeyManagementException | NoSuchAlgorithmException e)
{
throw new RuntimeException(e);
}
}
}
代码示例来源:origin: hopshadoop/hopsworks
public static <T> ClientWrapper<T> httpsInstance(Class<T> resultClass) {
try {
SSLContext sc = SSLContext.getInstance("SSL");
sc.init(null, trustAllCerts(), new java.security.SecureRandom());
Client client = ClientBuilder.newBuilder().sslContext(sc).hostnameVerifier(acceptAnyHost()).build();
return new ClientWrapper(client, resultClass);
} catch (NoSuchAlgorithmException | KeyManagementException ex) {
throw new IllegalStateException(ex);
}
}
代码示例来源:origin: dremio/dremio-oss
private void setTrustStore(ClientBuilder clientBuilder, DACConfig dacConfig)
throws IOException, GeneralSecurityException {
Optional<KeyStore> trustStore = Optional.empty();
if (checkCertificates) {
trustStore = new SSLConfigurator(dacConfig.getConfig(), DremioConfig.WEB_SSL_PREFIX, "web").getTrustStore();
if (trustStore.isPresent()) {
clientBuilder.trustStore(trustStore.get());
}
} else {
SSLContext sslContext = SSLHelper.newAllTrustingSSLContext("SSL");
HostnameVerifier verifier = SSLHelper.newAllValidHostnameVerifier();
clientBuilder.hostnameVerifier(verifier);
clientBuilder.sslContext(sslContext);
}
}
代码示例来源:origin: hopshadoop/hopsworks
public static <T> ClientWrapper<T> httpsInstance(KeyStore keystore, KeyStore truststore,
String password, HostnameVerifier hostnameVerifier, Class<T> resultClass) {
Client client = ClientBuilder.newBuilder().trustStore(truststore).keyStore(keystore, password.toCharArray()).
hostnameVerifier(hostnameVerifier).build();
return new ClientWrapper(client, resultClass);
}
代码示例来源:origin: gmessner/gitlab4j-api
protected Client createApiClient() {
ClientBuilder clientBuilder = ClientBuilder.newBuilder().withConfig(clientConfig);
if (ignoreCertificateErrors) {
clientBuilder.sslContext(openSslContext).hostnameVerifier(openHostnameVerifier);
}
apiClient = clientBuilder.build();
return (apiClient);
}
代码示例来源:origin: org.gitlab4j/gitlab4j-api
protected Client createApiClient() {
ClientBuilder clientBuilder = ClientBuilder.newBuilder().withConfig(clientConfig);
if (ignoreCertificateErrors) {
clientBuilder.sslContext(openSslContext).hostnameVerifier(openHostnameVerifier);
}
apiClient = clientBuilder.build();
return (apiClient);
}
代码示例来源:origin: org.coodex/concrete-jaxrs-client
JaxRSInvoker(Destination destination) {
super(destination);
client = isSSL(destination.getLocation()) ?
clientBuilder.hostnameVerifier(new HostnameVerifier() {
@Override
public boolean verify(String s, SSLSession sslSession) {
return true;
}
}).sslContext(getSSLContext(destination)).build() :
clientBuilder.build();
}
代码示例来源:origin: com.eclipsesource.jaxrs/consumer
public ResourceInvocationHandler( String baseUrl, Configuration configuration ) {
this( baseUrl, ClientBuilder.newBuilder().withConfig( configuration )
.sslContext( ClientHelper.createSSLContext() )
.hostnameVerifier( ClientHelper.createHostNameVerifier() )
.build() );
}
代码示例来源:origin: net.trajano.commons/commons-testing
/**
* Google should always have a valid SSL. Test this.
*/
@Test
public void testHttpsConnectionToGoogle() throws Exception {
final Client client = ClientBuilder
.newBuilder()
.hostnameVerifier(
DisableSslCertificateCheckUtil.NULL_HOSTNAME_VERIFIER)
.sslContext(
DisableSslCertificateCheckUtil
.buildUnsecureSslContext()).build();
client.target(
"https://accounts.google.com/.well-known/openid-configuration")
.request().get();
}
代码示例来源:origin: com.yahoo.athenz/athenz-instance-provider
public InstanceProviderClient(String url, SSLContext sslContext,
HostnameVerifier hostnameVerifier, int connectTimeout, int readTimeout) {
final ClientConfig config = new ClientConfig()
.property(ClientProperties.CONNECT_TIMEOUT, connectTimeout)
.property(ClientProperties.READ_TIMEOUT, readTimeout)
.connectorProvider(new ApacheConnectorProvider());
ClientBuilder builder = ClientBuilder.newBuilder();
if (sslContext != null) {
builder = builder.sslContext(sslContext);
}
client = builder.hostnameVerifier(hostnameVerifier)
.withConfig(config)
.build();
base = client.target(url);
}
代码示例来源:origin: com.elastisys.scale/commons.rest
/**
* Creates a HTTPS Jersey REST {@link Client} configured to not authenticate
* to the server.
* <p/>
* The created {@link Client} is configured to trust all server certificates
* and approve all host names. (This is similar to using the
* <code>--insecure</code> flag in <code>curl</code>.)
*
* @return The created {@link Client}.
*/
public static Client httpsNoAuth() {
return ClientBuilder.newBuilder().sslContext(SslUtils.trustAllCertsSslContext())
.hostnameVerifier(SslUtils.allowAllHostNames()).register(GsonMessageBodyReader.class)
.register(GsonMessageBodyWriter.class).build();
}
代码示例来源:origin: apache/cxf
@Test
public void testGetBookSslContext() throws Exception {
ClientBuilder builder = ClientBuilder.newBuilder();
SSLContext sslContext = createSSLContext();
builder.sslContext(sslContext);
builder.hostnameVerifier(new AllowAllHostnameVerifier());
Client client = builder.build();
WebTarget target = client.target("https://localhost:" + PORT + "/bookstore/securebooks/123");
Book b = target.request().accept(MediaType.APPLICATION_XML_TYPE).get(Book.class);
assertEquals(123, b.getId());
}
代码示例来源:origin: com.github.jakimli.pandaria/pandaria-core
private HttpClient(HttpContext context) {
ClientBuilder builder = ClientBuilder.newBuilder()
.property(SET_METHOD_WORKAROUND, true)
.property(SUPPRESS_HTTP_COMPLIANCE_VALIDATION, true)
.register(MultiPartFeature.class)
.register(logAny())
.sslContext(context.isHttpSslVerify() ? getDefaultContext() : emptyContext());
if (!context.isHttpSslVerify()) {
builder.hostnameVerifier(trustAll());
}
this.client = builder.build();
this.context = context;
}
代码示例来源:origin: JakimLi/pandaria
private HttpClient(HttpContext context) {
ClientBuilder builder = ClientBuilder.newBuilder()
.property(SET_METHOD_WORKAROUND, true)
.property(SUPPRESS_HTTP_COMPLIANCE_VALIDATION, true)
.register(MultiPartFeature.class)
.register(logAny())
.sslContext(context.isHttpSslVerify() ? getDefaultContext() : emptyContext());
if (!context.isHttpSslVerify()) {
builder.hostnameVerifier(trustAll());
}
this.client = builder.build();
this.context = context;
}
代码示例来源:origin: pravega/pravega
@Override
protected Client createJerseyClient() throws Exception {
SslConfigurator sslConfig = SslConfigurator.newInstance()
.trustStoreFile(getResourcePath("bookie.truststore.jks"));
SSLContext sslContext = sslConfig.createSSLContext();
return ClientBuilder.newBuilder().sslContext(sslContext)
.hostnameVerifier((s1, s2) -> true)
.build();
}
内容来源于网络,如有侵权,请联系作者删除!