public final class HttpClientSupport extends Object
HttpClient and related components.| Modifier and Type | Field and Description |
|---|---|
private static String |
CONTEXT_KEY_DYNAMIC_CONTEXT_HANDLERS
Context key for instances of dynamic context handlers to be invoked before and after the HTTP request.
|
| Modifier | Constructor and Description |
|---|---|
private |
HttpClientSupport()
Constructor to prevent instantiation.
|
| Modifier and Type | Method and Description |
|---|---|
static void |
addDynamicContextHandlerFirst(HttpClientContext context,
HttpClientContextHandler handler)
Add the specified instance of
HttpClientContextHandler
to the HttpClientContext in the first handler list position. |
static void |
addDynamicContextHandlerLast(HttpClientContext context,
HttpClientContextHandler handler)
Add the specified instance of
HttpClientContextHandler
to the HttpClientContext in the last handler list position. |
static SSLConnectionSocketFactory |
buildNoTrustSSLConnectionSocketFactory()
Deprecated.
use instead
buildNoTrustTLSSocketFactory() |
static LayeredConnectionSocketFactory |
buildNoTrustTLSSocketFactory()
Build a TLS-capable instance of
LayeredConnectionSocketFactory which accepts all peer certificates
and performs no hostname verification. |
static X509TrustManager |
buildNoTrustX509TrustManager()
Build an instance of
X509TrustManager which trusts all certificates. |
static SSLConnectionSocketFactory |
buildStrictSSLConnectionSocketFactory()
Deprecated.
use instead
buildStrictTLSSocketFactory() |
static LayeredConnectionSocketFactory |
buildStrictTLSSocketFactory()
Build an instance of TLS-capable
LayeredConnectionSocketFactory which uses
the standard JSSE default SSLContext and which performs
strict hostname verification. |
static List<HttpClientContextHandler> |
getDynamicContextHandlerList(HttpClientContext context)
Get the list of
HttpClientContextHandler for the HttpClientContext. |
static String |
toString(org.apache.http.HttpEntity entity,
Charset defaultCharset,
int maxLength)
Get the entity content as a String, using the provided default character set
if none is found in the entity.
|
static String |
toString(org.apache.http.HttpEntity entity,
int maxLength)
Read the contents of an entity and return it as a String.
|
static String |
toString(org.apache.http.HttpEntity entity,
String defaultCharset,
int maxLength)
Get the entity content as a String, using the provided default character set
if none is found in the entity.
|
private static final String CONTEXT_KEY_DYNAMIC_CONTEXT_HANDLERS
List<HttpClientContextHandler>.private HttpClientSupport()
@Nonnull public static LayeredConnectionSocketFactory buildStrictTLSSocketFactory()
LayeredConnectionSocketFactory which uses
the standard JSSE default SSLContext and which performs
strict hostname verification.@Nonnull public static LayeredConnectionSocketFactory buildNoTrustTLSSocketFactory()
LayeredConnectionSocketFactory which accepts all peer certificates
and performs no hostname verification.@Deprecated @Nonnull public static SSLConnectionSocketFactory buildStrictSSLConnectionSocketFactory()
buildStrictTLSSocketFactory()SSLConnectionSocketFactory which uses
the standard HttpClient default SSLContext and which uses
a strict hostname verifier SSLConnectionSocketFactory.STRICT_HOSTNAME_VERIFIER.@Deprecated @Nonnull public static SSLConnectionSocketFactory buildNoTrustSSLConnectionSocketFactory()
buildNoTrustTLSSocketFactory()SSLConnectionSocketFactory which accepts all peer certificates
and performs no hostname verification.@Nonnull public static X509TrustManager buildNoTrustX509TrustManager()
X509TrustManager which trusts all certificates.@Nonnull public static List<HttpClientContextHandler> getDynamicContextHandlerList(@Nonnull HttpClientContext context)
HttpClientContextHandler for the HttpClientContext.context - the client contextpublic static void addDynamicContextHandlerFirst(@Nonnull HttpClientContext context, @Nonnull HttpClientContextHandler handler)
HttpClientContextHandler
to the HttpClientContext in the first handler list position.context - the client contexthandler - the handler to addpublic static void addDynamicContextHandlerLast(@Nonnull HttpClientContext context, @Nonnull HttpClientContextHandler handler)
HttpClientContextHandler
to the HttpClientContext in the last handler list position.context - the client contexthandler - the handler to add@Nullable public static String toString(@Nonnull org.apache.http.HttpEntity entity, @Nullable Charset defaultCharset, int maxLength) throws IOException, org.apache.http.ParseException
If defaultCharset is null, the default "ISO-8859-1" is used.
entity - must not be nulldefaultCharset - character set to be applied if none found in the entitymaxLength - limit on size of contentHttpEntity.getContent() is null.org.apache.http.ParseException - if header elements cannot be parsedIOException - if an error occurs reading the input stream, or the size exceeds limitsUnsupportedCharsetException - when the content's charset is not available@Nullable public static String toString(@Nonnull org.apache.http.HttpEntity entity, @Nullable String defaultCharset, int maxLength) throws IOException, org.apache.http.ParseException
entity - must not be nulldefaultCharset - character set to be applied if none found in the entitymaxLength - limit on size of contentHttpEntity.getContent() is null.org.apache.http.ParseException - if header elements cannot be parsedIOException - if an error occurs reading the input stream, or the size exceeds limitsUnsupportedCharsetException - when the content's charset is not available@Nullable public static String toString(@Nonnull org.apache.http.HttpEntity entity, int maxLength) throws IOException, org.apache.http.ParseException
entity - the entity to convert to a string; must not be nullmaxLength - limit on size of contentHttpEntity.getContent() is null.org.apache.http.ParseException - if header elements cannot be parsedIOException - if an error occurs reading the input stream, or the size exceeds limitsUnsupportedCharsetException - when the content's charset is not availableCopyright © 1999–2020 Shibboleth Consortium. All rights reserved.