IMPLTYPE - Real implementation classpublic abstract class AbstractGenericSMPClient<IMPLTYPE extends AbstractGenericSMPClient<IMPLTYPE>> extends Object implements com.helger.commons.traits.IGenericImplTrait<IMPLTYPE>
Note: this class is also licensed under Apache 2 license, as it was not part of the original implementation
| Constructor and Description |
|---|
AbstractGenericSMPClient(URI aSMPHost)
Constructor with a direct SMP URL.
|
| Modifier and Type | Method and Description |
|---|---|
protected org.apache.http.protocol.HttpContext |
createHttpContext() |
<T> T |
executeGenericRequest(org.apache.http.client.methods.HttpUriRequest aRequest,
org.apache.http.client.ResponseHandler<T> aResponseHandler)
Execute a generic request on the SMP.
|
<T> T |
executeRequest(org.apache.http.client.methods.HttpUriRequest aRequest,
org.apache.http.client.ResponseHandler<T> aResponseHandler)
Execute a generic request on the SMP.
|
int |
getConnectionTimeoutMS() |
static SMPClientException |
getConvertedException(Exception ex)
Convert the passed generic HTTP exception into a more specific exception.
|
org.apache.http.HttpHost |
getProxy() |
org.apache.http.auth.Credentials |
getProxyCredentials() |
int |
getRequestTimeoutMS() |
String |
getSMPHostURI() |
boolean |
isCheckCertificate() |
boolean |
isUseDNSClientCache() |
boolean |
isUseProxySystemProperties() |
IMPLTYPE |
setCheckCertificate(boolean bCheckCertificate)
Check the certificate retrieved from a signed SMP response?
|
IMPLTYPE |
setConnectionTimeoutMS(int nConnectionTimeoutMS)
Set the connection timeout in milliseconds.
|
IMPLTYPE |
setProxy(org.apache.http.HttpHost aProxy)
Set the proxy to be used to access the SMP server.
|
IMPLTYPE |
setProxyCredentials(org.apache.http.auth.Credentials aProxyCredentials)
Set the proxy credentials to be used to access the SMP server.
|
IMPLTYPE |
setRequestTimeoutMS(int nRequestTimeoutMS)
Set the request timeout in milliseconds.
|
IMPLTYPE |
setUseDNSClientCache(boolean bUseDNSClientCache)
Enable or disable DNS client caching.
|
IMPLTYPE |
setUseProxySystemProperties(boolean bUseProxySystemProperties)
Set the usage of the HTTP proxy system properties.
|
String |
toString() |
public AbstractGenericSMPClient(@Nonnull URI aSMPHost)
aSMPHost - The address of the SMP service. Must be port 80 and basic http only
(no https!). Example: http://smpcompany.company.org@Nonnull public String getSMPHostURI()
null
. Always has a trailing "/".@Nullable public org.apache.http.HttpHost getProxy()
null by default.getProxyCredentials()@Nonnull public IMPLTYPE setProxy(@Nullable org.apache.http.HttpHost aProxy)
setProxyCredentials(Credentials)setUseProxySystemProperties(boolean) is enabled, any
proxy that is set via this method is reset!aProxy - May be null to indicate no proxy.setProxyCredentials(Credentials)@Nullable public org.apache.http.auth.Credentials getProxyCredentials()
null by default. This is only used if a proxy is set.getProxy()@Nonnull public IMPLTYPE setProxyCredentials(@Nullable org.apache.http.auth.Credentials aProxyCredentials)
aProxyCredentials - May be null to indicate no proxy credentials (the
default). Usually they are of type
UsernamePasswordCredentials.setProxy(HttpHost)public boolean isUseProxySystemProperties()
true if the system properties for HTTP proxy handling
are enabled, false if they are disabled. By default
they are disabled.@Nonnull public IMPLTYPE setUseProxySystemProperties(boolean bUseProxySystemProperties)
setProxy(HttpHost) is automatically
reset, because the manual proxy host has precedence over the system
properties (internally in Apache HTTPClient) - use the 'http.proxyHost'
system property instead!SMPClientConfiguration.isUseProxySystemProperties()).bUseProxySystemProperties - true to use system properties, false to
not use them.public boolean isUseDNSClientCache()
true if DNS client caching is enabled (default),
false if it is disabled.@Nonnull public IMPLTYPE setUseDNSClientCache(boolean bUseDNSClientCache)
bUseDNSClientCache - true to use DNS caching, false to disable
it.public int getConnectionTimeoutMS()
@Nonnull public IMPLTYPE setConnectionTimeoutMS(int nConnectionTimeoutMS)
nConnectionTimeoutMS - The connection timeout milliseconds to use. Only values > 0 are
considered.public int getRequestTimeoutMS()
@Nonnull public IMPLTYPE setRequestTimeoutMS(int nRequestTimeoutMS)
nRequestTimeoutMS - The request timeout milliseconds to use. Only values > 0 are
considered.@Nonnull public IMPLTYPE setCheckCertificate(boolean bCheckCertificate)
bCheckCertificate - true to enable SMP response checking (on by default) or
false to disable it.public boolean isCheckCertificate()
true if SMP client response certificate checking is
enabled, false if it is disabled. By default this
check is enabled (see
SMPHttpResponseHandlerSigned.DEFAULT_CHECK_CERTIFICATE).@Nonnull @OverrideOnDemand protected org.apache.http.protocol.HttpContext createHttpContext()
@Nonnull public <T> T executeRequest(@Nonnull org.apache.http.client.methods.HttpUriRequest aRequest, @Nonnull org.apache.http.client.ResponseHandler<T> aResponseHandler) throws IOException
executeGenericRequest(HttpUriRequest, ResponseHandler) this method
does NOT convert the IOException from HTTP communication problems
to IOException.T - Expected response typeaRequest - The request to be executed. The proxy + connection and request
timeout are set in this method.aResponseHandler - The response handler to be used. May not be null.IOException - On HTTP communication errorexecuteGenericRequest(HttpUriRequest, ResponseHandler)@Nonnull public static SMPClientException getConvertedException(@Nonnull Exception ex)
ex - The generic exception. May not be null.@Nonnull public <T> T executeGenericRequest(@Nonnull org.apache.http.client.methods.HttpUriRequest aRequest, @Nonnull org.apache.http.client.ResponseHandler<T> aResponseHandler) throws SMPClientException
executeRequest(HttpUriRequest, ResponseHandler) but includes the
conversion of Exceptions to SMPClientException objects.T - Expected response typeaRequest - The request to be executed. The proxy + connection and request
timeout are set in this method.aResponseHandler - The response handler to be used. May not be null.SMPClientException - One of the converted exceptionsexecuteRequest(HttpUriRequest, ResponseHandler),
getConvertedException(Exception)Copyright © 2015–2017 Philip Helger. All rights reserved.