Skip to content

Commit cd38f1c

Browse files
committed
added new commit
2 parents 673132e + 8e29e80 commit cd38f1c

File tree

9 files changed

+75
-58
lines changed

9 files changed

+75
-58
lines changed

.idea/.gitignore

Lines changed: 3 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

.idea/compiler.xml

Lines changed: 18 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

.idea/encodings.xml

Lines changed: 6 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

.idea/jarRepositories.xml

Lines changed: 20 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

.idea/misc.xml

Lines changed: 17 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

.idea/vcs.xml

Lines changed: 6 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

pom.xml

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -84,13 +84,6 @@
8484
<artifactId>spring-boot-starter-test</artifactId>
8585
<scope>test</scope>
8686
</dependency>
87-
88-
<!-- Apache HttpClient for better SSL handling -->
89-
<dependency>
90-
<groupId>org.apache.httpcomponents</groupId>
91-
<artifactId>httpclient</artifactId>
92-
<version>4.5.13</version>
93-
</dependency>
9487
</dependencies>
9588

9689
<build>
Lines changed: 4 additions & 51 deletions
Original file line numberDiff line numberDiff line change
@@ -1,65 +1,18 @@
11
package com.tennis.config;
22

3-
import org.apache.http.conn.ssl.NoopHostnameVerifier;
4-
import org.apache.http.conn.ssl.SSLConnectionSocketFactory;
5-
import org.apache.http.impl.client.CloseableHttpClient;
6-
import org.apache.http.impl.client.HttpClients;
7-
import org.apache.http.impl.conn.PoolingHttpClientConnectionManager;
8-
import org.apache.http.client.config.RequestConfig;
9-
import org.apache.http.ssl.TrustStrategy;
103
import org.springframework.context.annotation.Bean;
114
import org.springframework.context.annotation.Configuration;
12-
import org.springframework.http.client.HttpComponentsClientHttpRequestFactory;
135
import org.springframework.web.client.RestTemplate;
146

15-
import javax.net.ssl.SSLContext;
16-
import java.security.cert.X509Certificate;
17-
187
/**
19-
* Configuration for RestTemplate to handle HTTP requests with SSL certificate handling
8+
* Configuration for RestTemplate to handle HTTP requests
209
*/
2110
@Configuration
2211
public class RestTemplateConfig {
2312

2413
@Bean
25-
public RestTemplate restTemplate() throws Exception {
26-
// Create trust strategy that trusts all certificates
27-
TrustStrategy acceptingTrustStrategy = (X509Certificate[] chain, String authType) -> true;
28-
29-
// Create SSL context with trust all strategy
30-
SSLContext sslContext = org.apache.http.ssl.SSLContexts.custom()
31-
.loadTrustMaterial(null, acceptingTrustStrategy)
32-
.build();
33-
34-
// Create SSL connection socket factory
35-
SSLConnectionSocketFactory csf = new SSLConnectionSocketFactory(
36-
sslContext,
37-
new String[] { "TLSv1.2" },
38-
null,
39-
NoopHostnameVerifier.INSTANCE);
40-
41-
// Create connection manager with pooling
42-
PoolingHttpClientConnectionManager connectionManager = new PoolingHttpClientConnectionManager();
43-
connectionManager.setMaxTotal(100);
44-
connectionManager.setDefaultMaxPerRoute(20);
45-
46-
// Create request config with timeouts
47-
RequestConfig requestConfig = RequestConfig.custom()
48-
.setConnectTimeout(10000) // 10 seconds
49-
.setSocketTimeout(30000) // 30 seconds
50-
.build();
51-
52-
// Create HTTP client with SSL configuration and timeouts
53-
CloseableHttpClient httpClient = HttpClients.custom()
54-
.setSSLSocketFactory(csf)
55-
.setConnectionManager(connectionManager)
56-
.setDefaultRequestConfig(requestConfig)
57-
.build();
58-
59-
// Create request factory with custom HTTP client
60-
HttpComponentsClientHttpRequestFactory requestFactory =
61-
new HttpComponentsClientHttpRequestFactory(httpClient);
62-
63-
return new RestTemplate(requestFactory);
14+
public RestTemplate restTemplate() {
15+
// Use default RestTemplate configuration
16+
return new RestTemplate();
6417
}
6518
}

target/maven-status/maven-compiler-plugin/compile/default-compile/createdFiles.lst

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
com/tennis/config/RestTemplateConfig.class
12
com/tennis/entity/MatchPrediction.class
23
com/tennis/controller/TennisPredictionController.class
34
com/tennis/TennisMatchPredictionApplication.class

0 commit comments

Comments
 (0)