Class SecureHttpRequestFactory
java.lang.Object
org.springframework.http.client.SimpleClientHttpRequestFactory
com.thanlinardos.spring_enterprise_library.https.SecureHttpRequestFactory
- All Implemented Interfaces:
org.springframework.http.client.ClientHttpRequestFactory
public class SecureHttpRequestFactory
extends org.springframework.http.client.SimpleClientHttpRequestFactory
A custom HTTP request factory that configures SSL settings for HTTPS connections.
It extends the SimpleClientHttpRequestFactory to provide SSL context configuration.
-
Constructor Summary
ConstructorsConstructorDescriptionSecureHttpRequestFactory(SSLContext sslContext) Constructs a SecureHttpRequestFactory with the specified SSL context. -
Method Summary
Modifier and TypeMethodDescriptionprotected voidprepareConnection(HttpURLConnection connection, String httpMethod) Prepares the given HttpURLConnection by configuring SSL settings if it's an instance of HttpsURLConnection.Methods inherited from class org.springframework.http.client.SimpleClientHttpRequestFactory
createRequest, openConnection, setBufferRequestBody, setChunkSize, setConnectTimeout, setConnectTimeout, setOutputStreaming, setProxy, setReadTimeout, setReadTimeout
-
Constructor Details
-
SecureHttpRequestFactory
Constructs a SecureHttpRequestFactory with the specified SSL context.- Parameters:
sslContext- the SSL context to be used for HTTPS connections
-
-
Method Details
-
prepareConnection
protected void prepareConnection(@Nonnull HttpURLConnection connection, @Nonnull String httpMethod) throws IOException Prepares the given HttpURLConnection by configuring SSL settings if it's an instance of HttpsURLConnection. It sets the SSL socket factory and hostname verifier for secure connections.- Overrides:
prepareConnectionin classorg.springframework.http.client.SimpleClientHttpRequestFactory- Parameters:
connection- the HttpURLConnection to be preparedhttpMethod- the HTTP method (e.g., GET, POST) to be used- Throws:
IOException- if an I/O error occurs
-