public static final class ApacheHttpTransport.Builder
extends java.lang.Object
ApacheHttpTransport
.
Implementation is not thread-safe.
Constructor and Description |
---|
ApacheHttpTransport.Builder() |
Modifier and Type | Method and Description |
---|---|
ApacheHttpTransport |
build()
Returns a new instance of
ApacheHttpTransport based on the options. |
ApacheHttpTransport.Builder |
doNotValidateCertificate()
Beta Disables validating server SSL certificates by setting the SSL socket factory using SslUtils.trustAllSSLContext() for the SSL context and
SSLSocketFactory.ALLOW_ALL_HOSTNAME_VERIFIER for the host name verifier. |
org.apache.http.params.HttpParams |
getHttpParams()
Returns the HTTP parameters.
|
org.apache.http.conn.ssl.SSLSocketFactory |
getSSLSocketFactory()
Returns the SSL socket factory (
SSLSocketFactory.getSocketFactory() by default). |
ApacheHttpTransport.Builder |
setProxy(org.apache.http.HttpHost proxy)
Sets the HTTP proxy to use
DefaultHttpRoutePlanner or null to use
setProxySelector(ProxySelector) with ProxySelector.getDefault() . |
ApacheHttpTransport.Builder |
setProxySelector(java.net.ProxySelector proxySelector)
Sets the HTTP proxy selector to use
ProxySelectorRoutePlanner or null for
DefaultHttpRoutePlanner . |
ApacheHttpTransport.Builder |
setSocketFactory(org.apache.http.conn.ssl.SSLSocketFactory socketFactory)
Sets the SSL socket factory (
SSLSocketFactory.getSocketFactory() by default). |
ApacheHttpTransport.Builder |
trustCertificates(java.security.KeyStore trustStore)
Sets the SSL socket factory based on a root certificate trust store.
|
ApacheHttpTransport.Builder |
trustCertificatesFromJavaKeyStore(java.io.InputStream keyStoreStream,
java.lang.String storePass)
Sets the SSL socket factory based on root certificates in a Java KeyStore.
|
ApacheHttpTransport.Builder |
trustCertificatesFromStream(java.io.InputStream certificateStream)
Sets the SSL socket factory based root certificates generated from the specified stream using
CertificateFactory.generateCertificates(InputStream) . |
public ApacheHttpTransport.Builder setProxy(org.apache.http.HttpHost proxy)
DefaultHttpRoutePlanner
or null
to use
setProxySelector(ProxySelector)
with ProxySelector.getDefault()
.
By default it is null
, which uses the proxy settings from system
properties.
For example:
setProxy(new HttpHost("127.0.0.1", 8080))
public ApacheHttpTransport.Builder setProxySelector(java.net.ProxySelector proxySelector)
ProxySelectorRoutePlanner
or null
for
DefaultHttpRoutePlanner
.
By default it is ProxySelector.getDefault()
which uses the proxy settings from system
properties.
public ApacheHttpTransport.Builder trustCertificatesFromJavaKeyStore(java.io.InputStream keyStoreStream, java.lang.String storePass) throws java.security.GeneralSecurityException, java.io.IOException
Example usage:
trustCertificatesFromJavaKeyStore(new FileInputStream("certs.jks"), "password");
keyStoreStream
- input stream to the key store (closed at the end of this method in a
finally block)storePass
- password protecting the key store filejava.security.GeneralSecurityException
java.io.IOException
public ApacheHttpTransport.Builder trustCertificatesFromStream(java.io.InputStream certificateStream) throws java.security.GeneralSecurityException, java.io.IOException
CertificateFactory.generateCertificates(InputStream)
.
Example usage:
trustCertificatesFromStream(new FileInputStream("certs.pem"));
certificateStream
- certificate streamjava.security.GeneralSecurityException
java.io.IOException
public ApacheHttpTransport.Builder trustCertificates(java.security.KeyStore trustStore) throws java.security.GeneralSecurityException
trustStore
- certificate trust store (use for example SecurityUtils.loadKeyStore(java.security.KeyStore, java.io.InputStream, java.lang.String)
or SecurityUtils.loadKeyStoreFromCertificates(java.security.KeyStore, java.security.cert.CertificateFactory, java.io.InputStream)
)java.security.GeneralSecurityException
@Beta public ApacheHttpTransport.Builder doNotValidateCertificate() throws java.security.GeneralSecurityException
Beta
SslUtils.trustAllSSLContext()
for the SSL context and
SSLSocketFactory.ALLOW_ALL_HOSTNAME_VERIFIER
for the host name verifier.
Be careful! Disabling certificate validation is dangerous and should only be done in testing environments.
java.security.GeneralSecurityException
public ApacheHttpTransport.Builder setSocketFactory(org.apache.http.conn.ssl.SSLSocketFactory socketFactory)
SSLSocketFactory.getSocketFactory()
by default).public org.apache.http.conn.ssl.SSLSocketFactory getSSLSocketFactory()
SSLSocketFactory.getSocketFactory()
by default).public org.apache.http.params.HttpParams getHttpParams()
public ApacheHttpTransport build()
ApacheHttpTransport
based on the options.Copyright © 2011-2018 Google. All Rights Reserved.