Java Code Examples for org.apache.cxf.transports.http.configuration.HTTPClientPolicy#setMaxRetransmits()
The following examples show how to use
org.apache.cxf.transports.http.configuration.HTTPClientPolicy#setMaxRetransmits() .
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: RestUtil.java From peer-os with Apache License 2.0 | 7 votes |
public static WebClient createTrustedWebClient( String url ) { WebClient client = WebClient.create( url ); HTTPConduit httpConduit = ( HTTPConduit ) WebClient.getConfig( client ).getConduit(); HTTPClientPolicy httpClientPolicy = new HTTPClientPolicy(); httpClientPolicy.setConnectionTimeout( defaultConnectionTimeout ); httpClientPolicy.setReceiveTimeout( defaultReceiveTimeout ); httpClientPolicy.setMaxRetransmits( defaultMaxRetransmits ); httpConduit.setClient( httpClientPolicy ); SSLManager sslManager = new SSLManager( null, null, null, null ); TLSClientParameters tlsClientParameters = new TLSClientParameters(); tlsClientParameters.setDisableCNCheck( true ); tlsClientParameters.setTrustManagers( sslManager.getClientFullTrustManagers() ); httpConduit.setTlsClientParameters( tlsClientParameters ); return client; }
Example 2
Source File: RestUtil.java From peer-os with Apache License 2.0 | 6 votes |
public static WebClient createTrustedWebClient( String url, Object provider ) { WebClient client = WebClient.create( url, Arrays.asList( provider ) ); HTTPConduit httpConduit = ( HTTPConduit ) WebClient.getConfig( client ).getConduit(); HTTPClientPolicy httpClientPolicy = new HTTPClientPolicy(); httpClientPolicy.setConnectionTimeout( defaultConnectionTimeout ); httpClientPolicy.setReceiveTimeout( defaultReceiveTimeout ); httpClientPolicy.setMaxRetransmits( defaultMaxRetransmits ); httpConduit.setClient( httpClientPolicy ); SSLManager sslManager = new SSLManager( null, null, null, null ); TLSClientParameters tlsClientParameters = new TLSClientParameters(); tlsClientParameters.setDisableCNCheck( true ); tlsClientParameters.setTrustManagers( sslManager.getClientFullTrustManagers() ); httpConduit.setTlsClientParameters( tlsClientParameters ); return client; }
Example 3
Source File: WebClientBuilder.java From peer-os with Apache License 2.0 | 5 votes |
public static WebClient buildEnvironmentWebClient( final PeerInfo peerInfo, final String path, final Object provider ) { String effectiveUrl = String.format( ENVIRONMENT_URL_TEMPLATE, peerInfo.getIp(), peerInfo.getPublicSecurePort(), path.startsWith( "/" ) ? path : "/" + path ); WebClient client = WebClient.create( effectiveUrl, Arrays.asList( provider ) ); client.type( MediaType.APPLICATION_JSON ); client.accept( MediaType.APPLICATION_JSON ); HTTPConduit httpConduit = ( HTTPConduit ) WebClient.getConfig( client ).getConduit(); HTTPClientPolicy httpClientPolicy = new HTTPClientPolicy(); httpClientPolicy.setConnectionTimeout( DEFAULT_CONNECTION_TIMEOUT ); httpClientPolicy.setReceiveTimeout( DEFAULT_RECEIVE_TIMEOUT ); httpClientPolicy.setMaxRetransmits( DEFAULT_MAX_RETRANSMITS ); httpConduit.setClient( httpClientPolicy ); KeyStoreTool keyStoreManager = new KeyStoreTool(); KeyStoreData keyStoreData = new KeyStoreData(); keyStoreData.setupKeyStorePx2(); keyStoreData.setAlias( SecuritySettings.KEYSTORE_PX2_ROOT_ALIAS ); KeyStore keyStore = keyStoreManager.load( keyStoreData ); LOG.debug( String.format( "Getting key with alias: %s for url: %s", SecuritySettings.KEYSTORE_PX2_ROOT_ALIAS, effectiveUrl ) ); KeyStoreData trustStoreData = new KeyStoreData(); trustStoreData.setupTrustStorePx2(); KeyStore trustStore = keyStoreManager.load( trustStoreData ); SSLManager sslManager = new SSLManager( keyStore, keyStoreData, trustStore, trustStoreData ); TLSClientParameters tlsClientParameters = new TLSClientParameters(); tlsClientParameters.setDisableCNCheck( true ); tlsClientParameters.setTrustManagers( sslManager.getClientTrustManagers() ); tlsClientParameters.setKeyManagers( sslManager.getClientKeyManagers() ); tlsClientParameters.setCertAlias( SecuritySettings.KEYSTORE_PX2_ROOT_ALIAS ); httpConduit.setTlsClientParameters( tlsClientParameters ); return client; }
Example 4
Source File: RestUtil.java From peer-os with Apache License 2.0 | 5 votes |
public static WebClient createWebClient( String url, long connectTimeout, long receiveTimeout, int maxRetries ) { WebClient client = WebClient.create( url ); HTTPConduit httpConduit = ( HTTPConduit ) WebClient.getConfig( client ).getConduit(); HTTPClientPolicy httpClientPolicy = new HTTPClientPolicy(); httpClientPolicy.setConnectionTimeout( connectTimeout ); httpClientPolicy.setReceiveTimeout( receiveTimeout ); httpClientPolicy.setMaxRetransmits( maxRetries ); httpConduit.setClient( httpClientPolicy ); return client; }
Example 5
Source File: WebClientBuilder.java From peer-os with Apache License 2.0 | 4 votes |
public static WebClient buildPeerWebClient( final PeerInfo peerInfo, final String path, final Object provider, long connectTimeoutMs, long readTimeoutMs, int maxAttempts ) { String effectiveUrl = String.format( PEER_URL_TEMPLATE, peerInfo.getIp(), peerInfo.getPublicSecurePort(), path.startsWith( "/" ) ? path : "/" + path ); WebClient client; if ( provider == null ) { client = WebClient.create( effectiveUrl ); } else { client = WebClient.create( effectiveUrl, Collections.singletonList( provider ) ); } client.type( MediaType.APPLICATION_JSON ); client.accept( MediaType.APPLICATION_JSON ); HTTPConduit httpConduit = ( HTTPConduit ) WebClient.getConfig( client ).getConduit(); HTTPClientPolicy httpClientPolicy = new HTTPClientPolicy(); httpClientPolicy.setConnectionTimeout( connectTimeoutMs ); httpClientPolicy.setReceiveTimeout( readTimeoutMs ); httpClientPolicy.setMaxRetransmits( maxAttempts ); httpConduit.setClient( httpClientPolicy ); KeyStoreTool keyStoreManager = new KeyStoreTool(); KeyStoreData keyStoreData = new KeyStoreData(); keyStoreData.setupKeyStorePx2(); keyStoreData.setAlias( SecuritySettings.KEYSTORE_PX2_ROOT_ALIAS ); KeyStore keyStore = keyStoreManager.load( keyStoreData ); LOG.debug( String.format( "Getting key with alias: %s for url: %s", SecuritySettings.KEYSTORE_PX2_ROOT_ALIAS, effectiveUrl ) ); KeyStoreData trustStoreData = new KeyStoreData(); trustStoreData.setupTrustStorePx2(); KeyStore trustStore = keyStoreManager.load( trustStoreData ); SSLManager sslManager = new SSLManager( keyStore, keyStoreData, trustStore, trustStoreData ); TLSClientParameters tlsClientParameters = new TLSClientParameters(); tlsClientParameters.setDisableCNCheck( true ); tlsClientParameters.setTrustManagers( sslManager.getClientTrustManagers() ); tlsClientParameters.setKeyManagers( sslManager.getClientKeyManagers() ); tlsClientParameters.setCertAlias( SecuritySettings.KEYSTORE_PX2_ROOT_ALIAS ); httpConduit.setTlsClientParameters( tlsClientParameters ); return client; }
Example 6
Source File: WebClientBuilder.java From peer-os with Apache License 2.0 | 4 votes |
public static WebClient buildEnvironmentWebClient( final PeerInfo peerInfo, final String path, final Object provider, long connectTimeoutMs, long readTimeoutMs, int maxAttempts ) { String effectiveUrl = String.format( ENVIRONMENT_URL_TEMPLATE, peerInfo.getIp(), peerInfo.getPublicSecurePort(), path.startsWith( "/" ) ? path : "/" + path ); WebClient client = WebClient.create( effectiveUrl, Arrays.asList( provider ) ); client.type( MediaType.APPLICATION_JSON ); client.accept( MediaType.APPLICATION_JSON ); HTTPConduit httpConduit = ( HTTPConduit ) WebClient.getConfig( client ).getConduit(); HTTPClientPolicy httpClientPolicy = new HTTPClientPolicy(); httpClientPolicy.setConnectionTimeout( connectTimeoutMs ); httpClientPolicy.setReceiveTimeout( readTimeoutMs ); httpClientPolicy.setMaxRetransmits( maxAttempts ); httpConduit.setClient( httpClientPolicy ); KeyStoreTool keyStoreManager = new KeyStoreTool(); KeyStoreData keyStoreData = new KeyStoreData(); keyStoreData.setupKeyStorePx2(); keyStoreData.setAlias( SecuritySettings.KEYSTORE_PX2_ROOT_ALIAS ); KeyStore keyStore = keyStoreManager.load( keyStoreData ); LOG.debug( String.format( "Getting key with alias: %s for url: %s", SecuritySettings.KEYSTORE_PX2_ROOT_ALIAS, effectiveUrl ) ); KeyStoreData trustStoreData = new KeyStoreData(); trustStoreData.setupTrustStorePx2(); KeyStore trustStore = keyStoreManager.load( trustStoreData ); SSLManager sslManager = new SSLManager( keyStore, keyStoreData, trustStore, trustStoreData ); TLSClientParameters tlsClientParameters = new TLSClientParameters(); tlsClientParameters.setDisableCNCheck( true ); tlsClientParameters.setTrustManagers( sslManager.getClientTrustManagers() ); tlsClientParameters.setKeyManagers( sslManager.getClientKeyManagers() ); tlsClientParameters.setCertAlias( SecuritySettings.KEYSTORE_PX2_ROOT_ALIAS ); httpConduit.setTlsClientParameters( tlsClientParameters ); return client; }
Example 7
Source File: HttpClient.java From peer-os with Apache License 2.0 | 4 votes |
public static WebClient createTrustedWebClientWithAuth( String url, KeyStore keyStore, char[] keyStorePassword, byte[] serverFingerprint ) throws BazaarManagerException { try { WebClient client = WebClient.create( url ); // A client certificate is not provided in SSL context if async connection is used. // See details: #311 - Registration failure due to inability to find fingerprint. Map<String, Object> requestContext = WebClient.getConfig( client ).getRequestContext(); requestContext.put( "use.async.http.conduit", Boolean.FALSE ); HTTPConduit httpConduit = ( HTTPConduit ) WebClient.getConfig( client ).getConduit(); HTTPClientPolicy httpClientPolicy = new HTTPClientPolicy(); httpClientPolicy.setConnectionTimeout( SECONDS_30 ); httpClientPolicy.setReceiveTimeout( SECONDS_60 ); httpClientPolicy.setMaxRetransmits( DEFAULT_MAX_RETRANSMITS ); httpConduit.setClient( httpClientPolicy ); KeyManagerFactory keyManagerFactory = KeyManagerFactory.getInstance( KeyManagerFactory.getDefaultAlgorithm() ); keyManagerFactory.init( keyStore, keyStorePassword ); TLSClientParameters tlsClientParameters = new TLSClientParameters(); tlsClientParameters.setDisableCNCheck( true ); tlsClientParameters .setTrustManagers( new TrustManager[] { new FingerprintTrustManager( serverFingerprint ) } ); tlsClientParameters.setKeyManagers( keyManagerFactory.getKeyManagers() ); httpConduit.setTlsClientParameters( tlsClientParameters ); return client; } catch ( Exception e ) { throw new BazaarManagerException( e ); } }