public abstract class HttpSessionBase extends Object implements ConfigurableLifecycle, HasKeystore, HasTruststore
Note 1:
Some certificates require the <java_home>/jre/lib/security/xxx_policy.jar files to be upgraded to unlimited strength. Typically, in such a case, an error message like
Error in loading the keystore: Private key decryption error: (java.lang.SecurityException: Unsupported keysize or algorithm parameters
is observed.
For IBM JDKs these files can be downloaded from http://www.ibm.com/developerworks/java/jdk/security/50/ (scroll down to 'IBM SDK Policy files')
Note 2: To debug ssl-related problems, set the following system property:
-Djavax.net.debug=true
-Djavax.net.debug=all
Note 3:
In case javax.net.ssl.SSLHandshakeException: unknown certificate
-exceptions are thrown,
probably the certificate of the other party is not trusted. Try to use one of the certificates in the path as your truststore by doing the following:
keytool
as follows:
keytool -import -alias yourAlias -file pathToSavedCertificate
Note 4:
In case cannot create or initialize SocketFactory: (IOException) Unable to verify MAC
-exceptions are thrown,
please check password or authAlias configuration of the corresponding certificate.
Modifier and Type | Field and Description |
---|---|
protected org.apache.logging.log4j.Logger |
log |
Constructor and Description |
---|
HttpSessionBase() |
Modifier and Type | Method and Description |
---|---|
boolean |
areCookiesDisabled() |
protected void |
buildHttpClient() |
void |
configure()
Configure this component.
|
void |
configureConnectionManager()
In order to support multiThreading and connectionPooling.
|
protected org.apache.http.HttpResponse |
execute(URI targetUri,
org.apache.http.client.methods.HttpRequestBase httpRequestBase) |
protected org.apache.http.conn.ssl.SSLConnectionSocketFactory |
getSSLConnectionSocketFactory() |
protected URI |
getURI(String url)
Makes sure only http(s) requests can be performed.
|
boolean |
isRunning() |
protected void |
preAuthenticate() |
void |
setAllowSelfSignedCertificates(boolean allowSelfSignedCertificates)
If
true , self signed certificates are accepted |
void |
setAuthAlias(String string)
Authentication alias used for authentication to the host
|
void |
setAuthDomain(String string)
Deprecated.
|
void |
setAuthenticatedTokenRequest(boolean authenticatedTokenRequest)
if set true, clientId and clientSecret will be added as Basic Authentication header to the tokenRequest, instead of as request parameters
|
void |
setClientAlias(String clientAuthAlias)
Alias used to obtain client_id and client_secret for authentication to
tokenEndpoint |
void |
setClientId(String clientId)
Client_id used in authentication to
tokenEndpoint |
void |
setClientSecret(String clientSecret)
Client_secret used in authentication to
tokenEndpoint |
void |
setConnectionIdleTimeout(int idleTimeout)
Maximum Time for connection to stay idle in the pool.
|
void |
setConnectionTimeToLive(int timeToLive)
Maximum Time to Live for connections in the pool.
|
void |
setDisableCookies(boolean disableCookies)
Disables the use of cookies, making the sender completely stateless
|
void |
setFollowRedirects(boolean b)
If
true , a redirect request will be honoured, e.g. |
protected void |
setHttpClient(org.apache.http.impl.client.CloseableHttpClient httpClient) |
void |
setIgnoreCertificateExpiredException(boolean b)
If
true , CertificateExpiredExceptions are ignored |
void |
setIgnoreRedirects(boolean b)
If true, besides http status code 200 (OK) also the code 301 (MOVED_PERMANENTLY), 302 (MOVED_TEMPORARILY) and 307 (TEMPORARY_REDIRECT) are considered successful
|
void |
setKeyManagerAlgorithm(String keyManagerAlgorithm)
Key manager algorithm.
|
void |
setKeystore(String string)
resource URL to keystore or certificate to be used for authentication.
|
void |
setKeystoreAlias(String string)
Alias to obtain specific certificate or key in keystore
|
void |
setKeystoreAliasAuthAlias(String string)
Authentication alias to authenticate access to certificate or key indicated by
keystoreAlias |
void |
setKeystoreAliasPassword(String string)
Default password to authenticate access to certificate or key indicated by
keystoreAlias |
void |
setKeystoreAuthAlias(String string)
Authentication alias used to obtain keystore password
|
void |
setKeystorePassword(String string)
Default password to access keystore
|
void |
setKeystoreType(KeystoreType value)
Type of keystore
|
void |
setMaxConnections(int i)
The maximum number of concurrent connections
|
void |
setMaxExecuteRetries(int i)
The maximum number of times the execution is retried
|
void |
setPassword(String string)
Password used for authentication to the host
|
void |
setPrefillProxyAuthCache(boolean b)
Create a pre-emptive login context for the proxy connection(s).
|
void |
setProtocol(String protocol)
Secure socket protocol (such as 'SSL' and 'TLS') to use when a SSLContext object is generated.
|
void |
setProxyAuthAlias(String string)
Alias used to obtain credentials for authentication to proxy
|
void |
setProxyHost(String string)
Proxy host
|
void |
setProxyPassword(String string)
Proxy password
|
void |
setProxyPort(int i)
Proxy port
|
void |
setProxyRealm(String string)
Proxy realm
|
void |
setProxyUsername(String string)
Proxy username
|
void |
setScope(String string)
Space or comma separated list of scope items requested for accessToken, e.g.
|
void |
setStaleChecking(boolean b)
Controls whether connections checked to be stale, i.e.
|
void |
setStaleTimeout(int timeout)
Used when StaleChecking=
true . |
void |
setTimeout(int i)
Timeout in ms of obtaining a connection/result.
|
void |
setTokenEndpoint(String string)
Endpoint to obtain OAuth accessToken.
|
void |
setTokenExpiry(int value)
If set to a non-negative value, then determines the time (in seconds) after which the token will be refreshed.
|
void |
setTrustManagerAlgorithm(String trustManagerAlgorithm)
Trust manager algorithm.
|
void |
setTruststore(String string)
Resource url to truststore.
|
void |
setTruststoreAuthAlias(String string)
Authentication alias used to obtain truststore password
|
void |
setTruststorePassword(String string)
Default password to access truststore
|
void |
setTruststoreType(KeystoreType value)
Type of truststore
|
void |
setUsername(String username)
Username used for authentication to the host
|
void |
setVerifyHostname(boolean b)
If
true , the hostname in the certificate will be checked against the actual hostname of the peer |
void |
start() |
void |
stop() |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
getKeyManagerAlgorithm, getKeystore, getKeystoreAlias, getKeystoreAliasAuthAlias, getKeystoreAliasPassword, getKeystoreAuthAlias, getKeystorePassword, getKeystoreType
getApplicationContext, getName
getConfigurationClassLoader
setApplicationContext
getTrustManagerAlgorithm, getTruststore, getTruststoreAuthAlias, getTruststorePassword, getTruststoreType, isAllowSelfSignedCertificates, isIgnoreCertificateExpiredException, isVerifyHostname
protected URI getURI(String url) throws URISyntaxException
URISyntaxException
public void configure() throws ConfigurationException
ConfigurableLifecycle
In the case of a container, this will propagate the start signal to all components that apply.
configure
in interface ConfigurableLifecycle
ConfigurationException
- in case it was not able to configure the component.public void configureConnectionManager()
public void start()
start
in interface org.springframework.context.Lifecycle
protected void buildHttpClient()
protected void setHttpClient(org.apache.http.impl.client.CloseableHttpClient httpClient)
public boolean isRunning()
isRunning
in interface org.springframework.context.Lifecycle
public void stop()
stop
in interface org.springframework.context.Lifecycle
protected void preAuthenticate()
@Nonnull protected org.apache.http.conn.ssl.SSLConnectionSocketFactory getSSLConnectionSocketFactory() throws ConfigurationException
ConfigurationException
protected org.apache.http.HttpResponse execute(URI targetUri, org.apache.http.client.methods.HttpRequestBase httpRequestBase) throws IOException
IOException
public void setTimeout(int i)
public void setMaxConnections(int i)
public void setMaxExecuteRetries(int i)
public void setAuthAlias(String string)
public void setUsername(String username)
@Deprecated @ConfigurationWarning(value="Please use the UPN or the full sAM-AccountName instead") public void setAuthDomain(String string)
john.doe
CORPDOMAIN
public void setPassword(String string)
public void setTokenEndpoint(String string)
authAlias
or username
( and password
) are specified,
then a PasswordGrant is used, otherwise a ClientCredentials grant. The obtained accessToken will be added to the regular requests
in an HTTP Header 'Authorization' with a 'Bearer' prefix.public void setTokenExpiry(int value)
expires_in
clause of the token response,
or when the regular server returns a 401 status with a challenge.
If not specified, and the accessTokens lifetime is not found in the token response, the accessToken will not be refreshed preemptively.public void setClientAlias(String clientAuthAlias)
tokenEndpoint
public void setClientId(String clientId)
tokenEndpoint
public void setClientSecret(String clientSecret)
tokenEndpoint
public void setScope(String string)
read write
. Only used when tokenEndpoint
is specifiedpublic void setAuthenticatedTokenRequest(boolean authenticatedTokenRequest)
public void setProxyHost(String string)
public void setProxyPort(int i)
public void setProxyAuthAlias(String string)
public void setProxyUsername(String string)
public void setProxyPassword(String string)
public void setProxyRealm(String string)
public void setPrefillProxyAuthCache(boolean b)
public void setDisableCookies(boolean disableCookies)
public boolean areCookiesDisabled()
public void setKeystore(String string)
setKeystore
in interface HasKeystore
public void setKeystoreType(KeystoreType value)
HasKeystore
setKeystoreType
in interface HasKeystore
public void setKeystoreAuthAlias(String string)
HasKeystore
setKeystoreAuthAlias
in interface HasKeystore
public void setKeystorePassword(String string)
HasKeystore
setKeystorePassword
in interface HasKeystore
public void setKeyManagerAlgorithm(String keyManagerAlgorithm)
HasKeystore
setKeyManagerAlgorithm
in interface HasKeystore
public void setKeystoreAlias(String string)
HasKeystore
setKeystoreAlias
in interface HasKeystore
public void setKeystoreAliasAuthAlias(String string)
HasKeystore
keystoreAlias
setKeystoreAliasAuthAlias
in interface HasKeystore
public void setKeystoreAliasPassword(String string)
HasKeystore
keystoreAlias
setKeystoreAliasPassword
in interface HasKeystore
public void setTruststore(String string)
HasTruststore
setTruststore
in interface HasTruststore
public void setTruststoreAuthAlias(String string)
HasTruststore
setTruststoreAuthAlias
in interface HasTruststore
public void setTruststorePassword(String string)
HasTruststore
setTruststorePassword
in interface HasTruststore
public void setTruststoreType(KeystoreType value)
HasTruststore
setTruststoreType
in interface HasTruststore
public void setTrustManagerAlgorithm(String trustManagerAlgorithm)
HasTruststore
setTrustManagerAlgorithm
in interface HasTruststore
public void setVerifyHostname(boolean b)
HasTruststore
true
, the hostname in the certificate will be checked against the actual hostname of the peersetVerifyHostname
in interface HasTruststore
public void setAllowSelfSignedCertificates(boolean allowSelfSignedCertificates)
HasTruststore
true
, self signed certificates are acceptedsetAllowSelfSignedCertificates
in interface HasTruststore
public void setIgnoreCertificateExpiredException(boolean b)
HasTruststore
true
, CertificateExpiredExceptions are ignoredsetIgnoreCertificateExpiredException
in interface HasTruststore
public void setFollowRedirects(boolean b)
true
, a redirect request will be honoured, e.g. to switch to HTTPSpublic void setIgnoreRedirects(boolean b)
public void setStaleChecking(boolean b)
public void setStaleTimeout(int timeout)
true
. Timeout after which an idle connection will be validated before being used.public void setConnectionTimeToLive(int timeToLive)
public void setConnectionIdleTimeout(int idleTimeout)
public void setProtocol(String protocol)
Copyright © 2023 Frank!Framework. All rights reserved.