Class AbstractHttpSession
- All Implemented Interfaces:
FrankElement,HasApplicationContext,HasName,IConfigurable,IScopeProvider,HasKeystore,HasTruststore,ConfigurableLifecycle,org.springframework.beans.factory.Aware,org.springframework.context.ApplicationContextAware,org.springframework.context.Lifecycle,org.springframework.context.Phased,org.springframework.context.SmartLifecycle
- Direct Known Subclasses:
AbstractHttpSender,HttpSession
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')
- local_policy.jar
- US_export_policy.jar
Note 2: To debug ssl-related problems, set the following system property:
-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:
- open the URL you are trying to reach in InternetExplorer
- click on the yellow padlock on the right in the bottom-bar. This opens the certificate information window
- click on tab 'Certificeringspad'
- double click on root certificate in the tree displayed. This opens the certificate information window for the root certificate
- click on tab 'Details'
- click on 'Kopieren naar bestand'
- click 'next', choose 'DER Encoded Binary X.509 (.CER)'
- click 'next', choose a filename
- click 'next' and 'finish'
- Start IBM key management tool ikeyman.bat, located in Program Files/IBM/WebSphere Studio/Application Developer/v5.1.2/runtimes/base_v51/bin (or similar)
- create a new key-database (Sleuteldatabase -> Nieuw...), or open the default key.jks (default password="changeit")
- add the generated certificate (Toevoegen...)
- store the key-database in JKS format
- if you didn't use the standard keydatabase, then reference the file in the truststore-attribute in Configuration.xml (include the file as a resource)
- use jks for the truststoreType-attribute
- restart your application
- instead of IBM ikeyman you can use the standard java tool
keytoolas 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.
- Since:
- 7.0
- Author:
- Niels Meijer
-
Nested Class Summary
Nested Classes -
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final Stringprotected final org.apache.logging.log4j.LoggerFields inherited from interface org.springframework.context.SmartLifecycle
DEFAULT_PHASE -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionbooleanvoidConfigure this component.protected org.apache.http.HttpResponseexecute(URI targetUri, org.apache.http.client.methods.HttpRequestBase httpRequestBase, PipeLineSession session) By forcing the use of the HttpResponseHandler the resultStream will automatically be closed when it has been read.org.apache.http.auth.Credentialsprotected org.apache.http.conn.ssl.SSLConnectionSocketFactoryprotected URIMakes sure only http(s) requests can be performed.booleanvoidsetAllowSelfSignedCertificates(boolean allowSelfSignedCertificates) Iftrue, self signed certificates are acceptedvoidsetAuthAlias(String string) Authentication alias used for authentication to the hostvoidsetAuthDomain(String string) Deprecated.voidsetAuthenticatedTokenRequest(boolean authenticatedTokenRequest) Deprecated, for removal: This API element is subject to removal in a future version.voidsetClientAlias(String clientAuthAlias) Alias used to obtain client_id and client_secret for authentication totokenEndpointvoidsetClientId(String clientId) Client_id used in authentication totokenEndpointvoidsetClientSecret(String clientSecret) Client_secret used in authentication totokenEndpointvoidsetConnectionIdleTimeout(int idleTimeout) Maximum Time for connection to stay idle in the pool.voidsetConnectionTimeToLive(int timeToLive) Maximum Time to Live for connections in the pool.voidsetDisableCookies(boolean disableCookies) Disables the use of cookies, making the sender completely statelessvoidsetFollowRedirects(boolean b) Iftrue, a redirect request will be honoured, e.g. to switch to HTTPSprotected voidsetHttpClient(org.apache.http.impl.client.CloseableHttpClient httpClient) protected voidsetHttpContext(org.apache.http.client.protocol.HttpClientContext httpContext) voidsetIgnoreCertificateExpiredException(boolean b) Iftrue, CertificateExpiredExceptions are ignoredvoidsetIgnoreRedirects(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 successfulvoidsetKeyManagerAlgorithm(String keyManagerAlgorithm) Key manager algorithm.voidsetKeystore(String string) resource URL to keystore or certificate to be used for authentication.voidsetKeystoreAlias(String string) Alias to obtain specific certificate or key in keystorevoidsetKeystoreAliasAuthAlias(String string) Authentication alias to authenticate access to certificate or key indicated bykeystoreAliasvoidsetKeystoreAliasPassword(String string) Default password to authenticate access to certificate or key indicated bykeystoreAliasvoidsetKeystoreAuthAlias(String string) Authentication alias used to obtain keystore passwordvoidsetKeystorePassword(String string) Default password to access keystorevoidsetKeystoreType(KeystoreType value) Type of keystorevoidsetMaxConnections(int i) The maximum number of concurrent connectionsvoidsetMaxExecuteRetries(int i) The maximum number of times the execution is retriedvoidsetOauthAuthenticationMethod(AbstractHttpSession.OauthAuthenticationMethod oauthAuthenticationMethod) Only used when tokenEndpoint has been configured.voidsetPassword(String string) Password used for authentication to the hostvoidsetPrefillProxyAuthCache(boolean b) Create a pre-emptive login context for the proxy connection(s).voidsetProtocol(String protocol) Secure socket protocol (such as 'TLSv1.2') to use when a SSLContext object is generated.voidsetProxyAuthAlias(String string) Alias used to obtain credentials for authentication to proxyvoidsetProxyHost(String string) Proxy hostvoidsetProxyPassword(String string) Proxy passwordvoidsetProxyPort(int i) Proxy portvoidsetProxyRealm(String string) Proxy realmvoidsetProxyUsername(String string) Proxy usernamevoidsetSamlAssertionExpiry(int expiry) The time to live (in seconds) until the generated SAML assertion should be valid.voidsetSamlAudience(String samlAudience) The audience to be added during the creation of the SAML assertion.voidsetSamlIssuer(String samlIssuer) The issuer to be added during the creation of the SAML assertion.voidsetSamlNameId(String samlNameId) The nameId to be added during the creation of the SAML assertion.voidSpace or comma separated list of scope items requested for accessToken, e.g.voidsetStaleChecking(boolean b) Controls whether connections checked to be stale, i.e. appear open, but are not.voidsetStaleTimeout(int timeout) Used whenstaleCheckingistrue.voidsetSupportedCipherSuites(String supportedCipherSuites) Allows you to choose which CipherSuites are used when connecting to an endpoint.voidsetTimeout(int i) Timeout in ms of obtaining a connection/result.voidsetTokenEndpoint(String string) Endpoint to obtain OAuth accessToken.voidsetTokenExpiry(int value) If set to a non-negative value, then determines the time (in seconds) after which the token will be refreshed.voidsetTrustManagerAlgorithm(String trustManagerAlgorithm) Trust manager algorithm.voidsetTruststore(String string) Resource URL to truststore to be used for authenticating peer.voidsetTruststoreAuthAlias(String string) Authentication alias used to obtain truststore passwordvoidsetTruststorePassword(String string) Default password to access truststorevoidsetTruststoreType(KeystoreType value) Type of truststorevoidsetUsername(String username) Username used for authentication to the hostvoidsetVerifyHostname(boolean b) Iftrue, the hostname in the certificate will be checked against the actual hostname of the peervoidstart()voidstop()Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface org.springframework.context.ApplicationContextAware
setApplicationContextMethods inherited from interface org.frankframework.lifecycle.ConfigurableLifecycle
getPhase, isAutoStartup, isConfiguredMethods inherited from interface org.frankframework.core.FrankElement
addConfigWarningMethods inherited from interface org.frankframework.core.HasApplicationContext
getApplicationContext, getConfigurationClassLoaderMethods inherited from interface org.frankframework.encryption.HasKeystore
getKeyManagerAlgorithm, getKeystore, getKeystoreAlias, getKeystoreAliasAuthAlias, getKeystoreAliasPassword, getKeystoreAuthAlias, getKeystorePassword, getKeystoreTypeMethods inherited from interface org.frankframework.encryption.HasTruststore
getTrustManagerAlgorithm, getTruststore, getTruststoreAuthAlias, getTruststorePassword, getTruststoreType, isAllowSelfSignedCertificates, isIgnoreCertificateExpiredException, isVerifyHostnameMethods inherited from interface org.springframework.context.SmartLifecycle
stop
-
Field Details
-
log
protected final org.apache.logging.log4j.Logger log -
AUTHENTICATION_METHOD_KEY
- See Also:
-
-
Constructor Details
-
AbstractHttpSession
public AbstractHttpSession()
-
-
Method Details
-
getURI
Makes sure only http(s) requests can be performed.- Throws:
URISyntaxException
-
configure
Description copied from interface:IConfigurableConfigure this component.configure()is called once at startup of the framework in the configure method of the owner of thisIConfigurable. Purpose of this method is to check whether the static configuration of the object is correct. As much as possible class-instantiating should take place in theconfigure(), to improve performance.In the case of a container, this will propagate the configure signal to all components that apply.
- Specified by:
configurein interfaceIConfigurable- Throws:
ConfigurationException- in case it was not able to configure the component.
-
start
public void start()- Specified by:
startin interfaceConfigurableLifecycle- Specified by:
startin interfaceorg.springframework.context.Lifecycle
-
setHttpClient
protected void setHttpClient(org.apache.http.impl.client.CloseableHttpClient httpClient) -
setHttpContext
protected void setHttpContext(org.apache.http.client.protocol.HttpClientContext httpContext) -
isRunning
public boolean isRunning()- Specified by:
isRunningin interfaceorg.springframework.context.Lifecycle
-
stop
public void stop()- Specified by:
stopin interfaceorg.springframework.context.Lifecycle
-
getDomainAwareCredentials
public org.apache.http.auth.Credentials getDomainAwareCredentials() -
getSSLConnectionSocketFactory
@Nonnull protected org.apache.http.conn.ssl.SSLConnectionSocketFactory getSSLConnectionSocketFactory() throws ConfigurationException- Throws:
ConfigurationException
-
execute
protected org.apache.http.HttpResponse execute(URI targetUri, org.apache.http.client.methods.HttpRequestBase httpRequestBase, PipeLineSession session) throws IOException, TimeoutException By forcing the use of the HttpResponseHandler the resultStream will automatically be closed when it has been read. See HttpResponseHandler and ReleaseConnectionAfterReadInputStream. We cannot close the connection as the response might be kept in a sessionKey for later use in the pipeline. IMPORTANT: It is possible that poorly written implementations won't read or close the response. This will cause the connection to become stale.- Throws:
IOExceptionTimeoutException
-
setTimeout
public void setTimeout(int i) Timeout in ms of obtaining a connection/result.- Default value
- 10000
-
setMaxConnections
public void setMaxConnections(int i) The maximum number of concurrent connections- Default value
- 10
-
setMaxExecuteRetries
public void setMaxExecuteRetries(int i) The maximum number of times the execution is retried- Default value
- 1 (for repeatable messages) else 0
-
setAuthAlias
Authentication alias used for authentication to the host -
setUsername
Username used for authentication to the host -
setAuthDomain
@Deprecated @ConfigurationWarning("Please use the UPN or the full sAM-AccountName instead") public void setAuthDomain(String string) Deprecated.Corporate domain name. Should only be used in combination with sAMAccountName, never with an UPN.
Assuming the following user:
UPN: john.doe@CorpDomain.biz
sAMAccountName: CORPDOMAIN\john.doe
The username attribute may be set tojohn.doe
The AuthDomain attribute may be set toCORPDOMAIN -
setPassword
Password used for authentication to the host -
setTokenEndpoint
Endpoint to obtain OAuth accessToken. IfauthAliasorusername( andpassword) 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. -
setTokenExpiry
public void setTokenExpiry(int value) If set to a non-negative value, then determines the time (in seconds) after which the token will be refreshed. Otherwise the token will be refreshed when it is half way its lifetime as defined by theexpires_inclause 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.- Default value
- -1
-
setClientAlias
Alias used to obtain client_id and client_secret for authentication totokenEndpoint -
setClientId
Client_id used in authentication totokenEndpoint -
setClientSecret
Client_secret used in authentication totokenEndpoint -
setScope
Space or comma separated list of scope items requested for accessToken, e.g.read write. Only used whentokenEndpointis specified -
setAuthenticatedTokenRequest
@Deprecated(forRemoval=true, since="9.0") @ConfigurationWarning("Use oauthAuthenticationMethod to set this behaviour") public void setAuthenticatedTokenRequest(boolean authenticatedTokenRequest) Deprecated, for removal: This API element is subject to removal in a future version.if set true, clientId and clientSecret will be added as Basic Authentication header to the tokenRequest, instead of as request parameters -
setOauthAuthenticationMethod
public void setOauthAuthenticationMethod(AbstractHttpSession.OauthAuthenticationMethod oauthAuthenticationMethod) Only used when tokenEndpoint has been configured. Sets the OAuth authentication method and controls which authentication flow should be used. -
setSamlNameId
The nameId to be added during the creation of the SAML assertion. -
setSamlIssuer
The issuer to be added during the creation of the SAML assertion. -
setSamlAudience
The audience to be added during the creation of the SAML assertion. -
setSamlAssertionExpiry
public void setSamlAssertionExpiry(int expiry) The time to live (in seconds) until the generated SAML assertion should be valid. A new assertion will be generated when the previous assertion is no longer valid. -
setProxyHost
Proxy host -
setProxyPort
public void setProxyPort(int i) Proxy port- Default value
- 80
-
setProxyAuthAlias
Alias used to obtain credentials for authentication to proxy -
setProxyUsername
Proxy username- Default value
-
setProxyPassword
Proxy password- Default value
-
setProxyRealm
Proxy realm- Default value
-
setPrefillProxyAuthCache
public void setPrefillProxyAuthCache(boolean b) Create a pre-emptive login context for the proxy connection(s). -
setDisableCookies
public void setDisableCookies(boolean disableCookies) Disables the use of cookies, making the sender completely stateless- Default value
- false
-
areCookiesDisabled
public boolean areCookiesDisabled() -
setKeystore
resource URL to keystore or certificate to be used for authentication. If none specified, the JVMs default keystore will be used.- Specified by:
setKeystorein interfaceHasKeystore
-
setKeystoreType
Description copied from interface:HasKeystoreType of keystore- Specified by:
setKeystoreTypein interfaceHasKeystore
-
setKeystoreAuthAlias
Description copied from interface:HasKeystoreAuthentication alias used to obtain keystore password- Specified by:
setKeystoreAuthAliasin interfaceHasKeystore
-
setKeystorePassword
Description copied from interface:HasKeystoreDefault password to access keystore- Specified by:
setKeystorePasswordin interfaceHasKeystore
-
setKeyManagerAlgorithm
Description copied from interface:HasKeystoreKey manager algorithm. Can be left empty to use the servers default algorithm- Specified by:
setKeyManagerAlgorithmin interfaceHasKeystore
-
setKeystoreAlias
Description copied from interface:HasKeystoreAlias to obtain specific certificate or key in keystore- Specified by:
setKeystoreAliasin interfaceHasKeystore
-
setKeystoreAliasAuthAlias
Description copied from interface:HasKeystoreAuthentication alias to authenticate access to certificate or key indicated bykeystoreAlias- Specified by:
setKeystoreAliasAuthAliasin interfaceHasKeystore
-
setKeystoreAliasPassword
Description copied from interface:HasKeystoreDefault password to authenticate access to certificate or key indicated bykeystoreAlias- Specified by:
setKeystoreAliasPasswordin interfaceHasKeystore
-
setTruststore
Resource URL to truststore to be used for authenticating peer. If none specified, the JVMs default truststore will be used.- Specified by:
setTruststorein interfaceHasTruststore
-
setTruststoreAuthAlias
Description copied from interface:HasTruststoreAuthentication alias used to obtain truststore password- Specified by:
setTruststoreAuthAliasin interfaceHasTruststore
-
setTruststorePassword
Description copied from interface:HasTruststoreDefault password to access truststore- Specified by:
setTruststorePasswordin interfaceHasTruststore
-
setTruststoreType
Description copied from interface:HasTruststoreType of truststore- Specified by:
setTruststoreTypein interfaceHasTruststore
-
setTrustManagerAlgorithm
Description copied from interface:HasTruststoreTrust manager algorithm. Can be left empty to use the servers default algorithm- Specified by:
setTrustManagerAlgorithmin interfaceHasTruststore
-
setVerifyHostname
Description copied from interface:HasTruststoreIftrue, the hostname in the certificate will be checked against the actual hostname of the peer- Specified by:
setVerifyHostnamein interfaceHasTruststore
-
setAllowSelfSignedCertificates
Description copied from interface:HasTruststoreIftrue, self signed certificates are accepted- Specified by:
setAllowSelfSignedCertificatesin interfaceHasTruststore
-
setIgnoreCertificateExpiredException
Description copied from interface:HasTruststoreIftrue, CertificateExpiredExceptions are ignored- Specified by:
setIgnoreCertificateExpiredExceptionin interfaceHasTruststore
-
setFollowRedirects
public void setFollowRedirects(boolean b) Iftrue, a redirect request will be honoured, e.g. to switch to HTTPS- Default value
- true
-
setIgnoreRedirects
public 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- Default value
- false
-
setStaleChecking
public void setStaleChecking(boolean b) Controls whether connections checked to be stale, i.e. appear open, but are not.- Default value
- true
-
setStaleTimeout
public void setStaleTimeout(int timeout) Used whenstaleCheckingistrue. Timeout after which an idle connection will be validated before being used.- Default value
- 5000 ms
-
setConnectionTimeToLive
public void setConnectionTimeToLive(int timeToLive) Maximum Time to Live for connections in the pool. No connection will be re-used past its timeToLive value.- Default value
- 900 s
-
setConnectionIdleTimeout
public void setConnectionIdleTimeout(int idleTimeout) Maximum Time for connection to stay idle in the pool. Connections that are idle longer will periodically be evicted from the pool- Default value
- 10 s
-
setProtocol
Secure socket protocol (such as 'TLSv1.2') to use when a SSLContext object is generated.- See Also:
- Default value
- TLSv1.2
-
setSupportedCipherSuites
Allows you to choose which CipherSuites are used when connecting to an endpoint. Works in tandem withprotocolas the provided Suite may not be valid for the provided Protocol See the Java Security Standard Algorithm Names Specification for all available options. Note that these may differ depending on the JRE you're using.- See Also:
-