Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

MOSIP-24027 resttemplate issue resolved version modified to p1 #492

Open
wants to merge 5 commits into
base: 1.1.5.4
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions partner/partner-management-service/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,10 @@
<parent>
<artifactId>pms-parent</artifactId>
<groupId>io.mosip.pms</groupId>
<version>1.1.5.4</version>
<version>1.1.5.4-p1-SNAPSHOT</version>
</parent>

<version>1.1.5.4</version>
<version>1.1.5.4-p1-SNAPSHOT</version>
<artifactId>partner-management-service</artifactId>
<name>partner-management-service</name>

Expand All @@ -31,7 +31,7 @@
<dependency>
<groupId>io.mosip.pms</groupId>
<artifactId>pms-common</artifactId>
<version>1.1.5.4</version>
<version>1.1.5.4-p1-SNAPSHOT</version>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
Expand Down Expand Up @@ -112,4 +112,4 @@
</plugin>
</plugins>
</build>
</project>
</project>
6 changes: 3 additions & 3 deletions partner/pms-common/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,10 @@
<parent>
<groupId>io.mosip.pms</groupId>
<artifactId>pms-parent</artifactId>
<version>1.1.5.4</version>
<version>1.1.5.4-p1-SNAPSHOT</version>
</parent>
<artifactId>pms-common</artifactId>
<version>1.1.5.4</version>
<version>1.1.5.4-p1-SNAPSHOT</version>
<name>pms-common</name>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
Expand Down Expand Up @@ -40,4 +40,4 @@
<version>${kernel-websubclient-api.version}</version>
</dependency>
</dependencies>
</project>
</project>
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
import org.apache.http.impl.client.HttpClients;
import org.apache.http.ssl.TrustStrategy;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.core.env.Environment;
import org.springframework.http.HttpEntity;
import org.springframework.http.HttpHeaders;
Expand Down Expand Up @@ -54,6 +55,14 @@ public class RestUtil {
private Environment environment;

private static final String AUTHORIZATION = "Authorization=";

private RestTemplate localRestTemplate;

@Value("${pms.default.httpclient.connections.max.per.host:20}")
private int maxConnectionPerRoute;

@Value("${pms.default.httpclient.connections.max:100}")
private int totalMaxConnection;

@SuppressWarnings("unchecked")
public <T> T postApi(String apiUrl, List<String> pathsegments, String queryParamName, String queryParamValue,
Expand Down Expand Up @@ -169,16 +178,15 @@ public <T> T getApi(String apiUrl, Map<String, String> pathsegments, Class<?> re
}

public RestTemplate getRestTemplate() throws KeyManagementException, NoSuchAlgorithmException, KeyStoreException {
TrustStrategy acceptingTrustStrategy = (X509Certificate[] chain, String authType) -> true;
SSLContext sslContext = org.apache.http.ssl.SSLContexts.custom().loadTrustMaterial(null, acceptingTrustStrategy)
.build();
SSLConnectionSocketFactory csf = new SSLConnectionSocketFactory(sslContext);
CloseableHttpClient httpClient = HttpClients.custom().setSSLSocketFactory(csf).build();
HttpComponentsClientHttpRequestFactory requestFactory = new HttpComponentsClientHttpRequestFactory();
requestFactory.setHttpClient(httpClient);

return new RestTemplate(requestFactory);

if(localRestTemplate==null) {
HttpClientBuilder httpClientBuilder = HttpClients.custom()
.setMaxConnPerRoute(maxConnectionPerRoute)
.setMaxConnTotal(totalMaxConnection).disableCookieManagement();
HttpComponentsClientHttpRequestFactory requestFactory = new HttpComponentsClientHttpRequestFactory();
requestFactory.setHttpClient(httpClientBuilder.build());
localRestTemplate= new RestTemplate(requestFactory);
}
return localRestTemplate;
}

@SuppressWarnings("unchecked")
Expand Down
8 changes: 4 additions & 4 deletions partner/policy-management-service/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,9 @@
<parent>
<artifactId>pms-parent</artifactId>
<groupId>io.mosip.pms</groupId>
<version>1.1.5.4</version>
<version>1.1.5.4-p1-SNAPSHOT</version>
</parent>
<version>1.1.5.4</version>
<version>1.1.5.4-p1-SNAPSHOT</version>
<artifactId>policy-management-service</artifactId>
<name>policy-management-service</name>
<dependencies>
Expand All @@ -19,7 +19,7 @@
<dependency>
<groupId>io.mosip.pms</groupId>
<artifactId>pms-common</artifactId>
<version>1.1.5.4</version>
<version>1.1.5.4-p1-SNAPSHOT</version>
</dependency>
<dependency>
<groupId>io.micrometer</groupId>
Expand Down Expand Up @@ -118,4 +118,4 @@
</plugin>
</plugins>
</build>
</project>
</project>
6 changes: 3 additions & 3 deletions partner/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
<groupId>io.mosip.pms</groupId>
<artifactId>pms-parent</artifactId>
<packaging>pom</packaging>
<version>1.1.5.4</version>
<version>1.1.5.4-p1-SNAPSHOT</version>

<name>partner-management-services</name>
<description>Parent project of MOSIP partner-management-services</description>
Expand Down Expand Up @@ -72,7 +72,7 @@
</properties>

<modules>
<module>policy-validator</module>
<!-- <module>policy-validator</module> -->
<module>pms-common</module>
<module>policy-management-service</module>
<module>partner-management-service</module>
Expand Down Expand Up @@ -273,4 +273,4 @@
</plugins>
</build>

</project>
</project>