Java Code Examples for org.apache.cxf.configuration.jsse.TLSClientParameters#getTrustManagers()
The following examples show how to use
org.apache.cxf.configuration.jsse.TLSClientParameters#getTrustManagers() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: HttpConduitConfigurationTest.java From cxf with Apache License 2.0 | 6 votes |
private void verifyConduit(HTTPConduit conduit) { AuthorizationPolicy authp = conduit.getAuthorization(); assertNotNull(authp); assertEquals("Betty", authp.getUserName()); assertEquals("password", authp.getPassword()); TLSClientParameters tlscps = conduit.getTlsClientParameters(); assertNotNull(tlscps); assertTrue(tlscps.isDisableCNCheck()); assertEquals(3600000, tlscps.getSslCacheTimeout()); KeyManager[] kms = tlscps.getKeyManagers(); assertTrue(kms != null && kms.length == 1); assertTrue(kms[0] instanceof X509KeyManager); TrustManager[] tms = tlscps.getTrustManagers(); assertTrue(tms != null && tms.length == 1); assertTrue(tms[0] instanceof X509TrustManager); FiltersType csfs = tlscps.getCipherSuitesFilter(); assertNotNull(csfs); assertEquals(1, csfs.getInclude().size()); assertEquals(1, csfs.getExclude().size()); HTTPClientPolicy clientPolicy = conduit.getClient(); assertEquals(10240, clientPolicy.getChunkLength()); }
Example 2
Source File: MicroProfileClientFactoryBean.java From cxf with Apache License 2.0 | 5 votes |
@Override protected void initClient(AbstractClient client, Endpoint ep, boolean addHeaders) { super.initClient(client, ep, addHeaders); TLSClientParameters tlsParams = secConfig.getTlsClientParams(); if (tlsParams.getSSLSocketFactory() != null || tlsParams.getTrustManagers() != null || tlsParams.getHostnameVerifier() != null) { client.getConfiguration().getHttpConduit().setTlsClientParameters(tlsParams); } if (PropertyUtils.isTrue(configuration.getProperty(ClientProperties.HTTP_AUTOREDIRECT_PROP))) { client.getConfiguration().getHttpConduit().getClient().setAutoRedirect(true); } String proxyHost = (String) configuration.getProperty(ClientProperties.HTTP_PROXY_SERVER_PROP); if (proxyHost != null) { client.getConfiguration().getHttpConduit().getClient().setProxyServer(proxyHost); int proxyPort = (int) configuration.getProperty(ClientProperties.HTTP_PROXY_SERVER_PORT_PROP); client.getConfiguration().getHttpConduit().getClient().setProxyServerPort(proxyPort); } MicroProfileClientProviderFactory factory = MicroProfileClientProviderFactory.createInstance(getBus(), comparator); factory.setUserProviders(registeredProviders); ep.put(MicroProfileClientProviderFactory.CLIENT_FACTORY_NAME, factory); }
Example 3
Source File: ClientImpl.java From cxf with Apache License 2.0 | 4 votes |
@Override public Builder request() { checkClosed(); Map<String, Object> configProps = getConfiguration().getProperties(); initTargetClientIfNeeded(configProps); ClientProviderFactory pf = ClientProviderFactory.getInstance(WebClient.getConfig(targetClient).getEndpoint()); List<Object> providers = new LinkedList<>(); List<org.apache.cxf.feature.Feature> cxfFeatures = new LinkedList<>(); Configuration cfg = configImpl.getConfiguration(); for (Object p : cfg.getInstances()) { if (p instanceof org.apache.cxf.feature.Feature) { cxfFeatures.add((org.apache.cxf.feature.Feature)p); } else if (!(p instanceof Feature)) { Map<Class<?>, Integer> contracts = cfg.getContracts(p.getClass()); if (contracts == null || contracts.isEmpty()) { providers.add(p); } else { final Class<?> providerCls = ClassHelper.getRealClass(pf.getBus(), p); providers.add(new FilterProviderInfo<Object>(p.getClass(), providerCls, p, pf.getBus(), contracts)); } } } pf.setUserProviders(providers); ClientConfiguration clientCfg = WebClient.getConfig(targetClient); clientCfg.getRequestContext().putAll(configProps); clientCfg.getRequestContext().put(Client.class.getName(), ClientImpl.this); clientCfg.getRequestContext().put(Configuration.class.getName(), getConfiguration()); // Response auto-close Boolean responseAutoClose = getBooleanValue(configProps.get(HTTP_RESPONSE_AUTOCLOSE_PROP)); if (responseAutoClose != null) { clientCfg.getResponseContext().put("response.stream.auto.close", responseAutoClose); } // TLS TLSClientParameters tlsParams = secConfig.getTlsClientParams(); if (tlsParams.getSSLSocketFactory() != null || tlsParams.getTrustManagers() != null || tlsParams.getHostnameVerifier() != null) { clientCfg.getHttpConduit().setTlsClientParameters(tlsParams); } // Executor for the asynchronous calls Object executorServiceProp = configProps.get(AbstractClient.EXECUTOR_SERVICE_PROPERTY); if (executorServiceProp != null) { clientCfg.getResponseContext().put(AbstractClient.EXECUTOR_SERVICE_PROPERTY, executorServiceProp); } setConnectionProperties(configProps, clientCfg); // CXF Features for (org.apache.cxf.feature.Feature cxfFeature : cxfFeatures) { cxfFeature.initialize(clientCfg, clientCfg.getBus()); } // Start building the invocation return new InvocationBuilderImpl(WebClient.fromClient(targetClient), getConfiguration()); }
Example 4
Source File: AsyncHTTPConduit.java From cxf with Apache License 2.0 | 4 votes |
public synchronized SSLContext getSSLContext(TLSClientParameters tlsClientParameters) throws GeneralSecurityException { int hash = tlsClientParameters.hashCode(); if (hash == lastTlsHash && sslContext != null) { return sslContext; } SSLContext ctx = null; if (tlsClientParameters.getSslContext() != null) { ctx = tlsClientParameters.getSslContext(); } else { String provider = tlsClientParameters.getJsseProvider(); String protocol = tlsClientParameters.getSecureSocketProtocol() != null ? tlsClientParameters .getSecureSocketProtocol() : "TLS"; ctx = provider == null ? SSLContext.getInstance(protocol) : SSLContext .getInstance(protocol, provider); KeyManager[] keyManagers = tlsClientParameters.getKeyManagers(); if (keyManagers == null) { keyManagers = org.apache.cxf.configuration.jsse.SSLUtils.getDefaultKeyStoreManagers(LOG); } KeyManager[] configuredKeyManagers = org.apache.cxf.transport.https.SSLUtils.configureKeyManagersWithCertAlias( tlsClientParameters, keyManagers); TrustManager[] trustManagers = tlsClientParameters.getTrustManagers(); if (trustManagers == null) { trustManagers = org.apache.cxf.configuration.jsse.SSLUtils.getDefaultTrustStoreManagers(LOG); } ctx.init(configuredKeyManagers, trustManagers, tlsClientParameters.getSecureRandom()); if (ctx.getClientSessionContext() != null) { ctx.getClientSessionContext().setSessionTimeout(tlsClientParameters.getSslCacheTimeout()); } } sslContext = ctx; lastTlsHash = hash; sslState = null; sslURL = null; session = null; return ctx; }