Skip to content

Commit 5f5abf0

Browse files
authored
Merge pull request #96 from Julius278/dependency-updates
Dependency updates, remove some vulnerabilities
2 parents 76d3da7 + 64115e7 commit 5f5abf0

File tree

3 files changed

+39
-38
lines changed

3 files changed

+39
-38
lines changed

pom.xml

Lines changed: 15 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@
3030
<springdoc-openapi-ui.version>2.2.0</springdoc-openapi-ui.version>
3131
<jackson-databind-nullable.version>0.2.6</jackson-databind-nullable.version>
3232
<commons-cli.version>1.5.0</commons-cli.version>
33-
<spring-boot-dependencies.version>3.0.5</spring-boot-dependencies.version>
33+
<spring-boot-dependencies.version>3.2.10</spring-boot-dependencies.version>
3434
<finmath-lib.version>6.0.12</finmath-lib.version>
3535
<finmath-lib-plot-extensions.version>0.4.8</finmath-lib-plot-extensions.version>
3636
<spring-statemachine.version>3.2.0</spring-statemachine.version>
@@ -56,6 +56,7 @@
5656
<doxia-skin-model.version>2.0.0-M6</doxia-skin-model.version>
5757
<doxia-module-markdown.version>2.0.0-M6</doxia-module-markdown.version>
5858
<git-commit-id-maven-plugin.version>5.0.0</git-commit-id-maven-plugin.version>
59+
<httpcore.version>5.3</httpcore.version>
5960
</properties>
6061

6162
<developers>
@@ -167,17 +168,23 @@
167168
<groupId>net.finmath</groupId>
168169
<artifactId>finmath-lib</artifactId>
169170
</exclusion>
171+
<exclusion>
172+
<groupId>com.itextpdf</groupId>
173+
<artifactId>itextpdf</artifactId>
174+
</exclusion>
170175
</exclusions>
171176
</dependency>
172177

173178
<dependency>
174-
<groupId>org.apache.httpcomponents</groupId>
175-
<artifactId>httpclient</artifactId>
179+
<groupId>org.apache.httpcomponents.client5</groupId>
180+
<artifactId>httpclient5</artifactId>
181+
<version>${httpcore.version}</version>
176182
</dependency>
177183

178184
<dependency>
179-
<groupId>org.apache.httpcomponents</groupId>
180-
<artifactId>httpcore</artifactId>
185+
<groupId>org.apache.httpcomponents.core5</groupId>
186+
<artifactId>httpcore5</artifactId>
187+
<version>${httpcore.version}</version>
181188
</dependency>
182189

183190
<dependency>
@@ -310,12 +317,11 @@
310317
<version>${commons-cli.version}</version>
311318
</dependency>
312319

313-
<!-- https://mvnrepository.com/artifact/org.postgresql/postgresql -->
314-
<dependency>
320+
<!-- currently no need for postgres db connection -->
321+
<!--dependency>
315322
<groupId>org.postgresql</groupId>
316323
<artifactId>postgresql</artifactId>
317-
</dependency>
318-
324+
</dependency-->
319325

320326
<dependency>
321327
<groupId>org.slf4j</groupId>

src/main/java/net/finmath/smartcontract/valuation/marketdata/generators/WebSocketConnector.java

Lines changed: 23 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -7,23 +7,22 @@
77

88
import com.neovisionaries.ws.client.*;
99

10-
import org.apache.http.Header;
11-
import org.apache.http.HttpResponse;
12-
import org.apache.http.HttpStatus;
13-
import org.apache.http.NameValuePair;
14-
import org.apache.http.client.HttpClient;
15-
import org.apache.http.client.entity.UrlEncodedFormEntity;
16-
import org.apache.http.client.methods.HttpPost;
17-
import org.apache.http.conn.ssl.SSLConnectionSocketFactory;
18-
import org.apache.http.impl.client.HttpClients;
19-
import org.apache.http.message.BasicNameValuePair;
20-
import org.apache.http.ssl.SSLContextBuilder;
21-
import org.apache.http.util.EntityUtils;
10+
import org.apache.hc.client5.http.classic.HttpClient;
11+
import org.apache.hc.client5.http.classic.methods.HttpPost;
12+
import org.apache.hc.client5.http.entity.UrlEncodedFormEntity;
13+
import org.apache.hc.client5.http.impl.classic.HttpClientBuilder;
14+
import org.apache.hc.client5.http.impl.io.PoolingHttpClientConnectionManager;
15+
import org.apache.hc.client5.http.impl.io.PoolingHttpClientConnectionManagerBuilder;
16+
import org.apache.hc.client5.http.ssl.SSLConnectionSocketFactoryBuilder;
17+
import org.apache.hc.core5.http.*;
18+
import org.apache.hc.core5.http.io.entity.EntityUtils;
19+
import org.apache.hc.core5.http.message.BasicNameValuePair;
2220
import org.json.JSONObject;
2321

2422
import javax.net.ssl.SSLParameters;
2523
import java.io.IOException;
2624
import java.net.Inet4Address;
25+
import java.nio.charset.StandardCharsets;
2726
import java.security.NoSuchAlgorithmException;
2827
import java.util.ArrayList;
2928
import java.util.List;
@@ -48,12 +47,9 @@
4847
* providing the updated token to the Real-Time endpoint before token expiration.
4948
*/
5049
public class WebSocketConnector {
51-
52-
5350
Properties connectionProperties;
5451
public JSONObject authJson;
5552

56-
5753
public String position;
5854
public String scope = "";
5955
public String server = "";
@@ -63,8 +59,6 @@ public class WebSocketConnector {
6359
public WebSocketConnector(Properties connectionProperties) throws Exception {
6460
this.connectionProperties = connectionProperties;
6561
this.position = Inet4Address.getLocalHost().getHostAddress();
66-
67-
6862
}
6963

7064
public WebSocket getWebSocket() throws Exception{
@@ -84,10 +78,8 @@ public String getPosition(){
8478

8579
public WebSocketConnector initAuthJson() {
8680
try {
87-
8881
// Connect to Live Market Data Platform and authenticate (using our username and password)
8982
this.authJson = getAuthenticationInfo(null, connectionProperties.get("AUTHURL").toString());
90-
9183
} catch (Exception e) {
9284
e.printStackTrace();
9385
}
@@ -134,17 +126,20 @@ public WebSocket initWebSocketConnection() throws IOException, WebSocketExceptio
134126
public JSONObject getAuthenticationInfo(JSONObject previousAuthResponseJson, String url) {
135127
try
136128
{
137-
SSLConnectionSocketFactory sslsf = new SSLConnectionSocketFactory(new SSLContextBuilder().build());
129+
PoolingHttpClientConnectionManager connectionManager = PoolingHttpClientConnectionManagerBuilder.create()
130+
.setSSLSocketFactory(SSLConnectionSocketFactoryBuilder.create().build())
131+
.build();
138132

139-
HttpClient httpclient = HttpClients.custom().setSSLSocketFactory(sslsf).build();
133+
HttpClient httpclient = HttpClientBuilder.create()
134+
.setConnectionManager(connectionManager).build();
140135
HttpPost httppost = new HttpPost(url);
141136
/* HttpParams httpParams = new BasicHttpParams();
142137
143138
// Disable redirect
144139
httpParams.setParameter(ClientPNames.HANDLE_REDIRECTS, false);*/
145140

146141
// Set request parameters.
147-
List<NameValuePair> params = new ArrayList<NameValuePair>(2);
142+
List<NameValuePair> params = new ArrayList<>(2);
148143
params.add(new BasicNameValuePair("client_id", connectionProperties.get("CLIENTID").toString()));
149144
params.add(new BasicNameValuePair("username", connectionProperties.get("USER").toString()));
150145

@@ -164,12 +159,12 @@ public JSONObject getAuthenticationInfo(JSONObject previousAuthResponseJson, Str
164159
}
165160

166161
//httppost.setParams(httpParams);
167-
httppost.setEntity(new UrlEncodedFormEntity(params, "UTF-8"));
162+
httppost.setEntity(new UrlEncodedFormEntity(params, StandardCharsets.UTF_8));
168163

169164
//Execute and get the response.
170-
HttpResponse response = httpclient.execute(httppost);
165+
ClassicHttpResponse response = httpclient.executeOpen(null, httppost, null);
171166

172-
int statusCode = response.getStatusLine().getStatusCode();
167+
int statusCode = response.getCode();
173168

174169
switch ( statusCode ) {
175170
case HttpStatus.SC_OK: // 200
@@ -198,7 +193,7 @@ public JSONObject getAuthenticationInfo(JSONObject previousAuthResponseJson, Str
198193
case HttpStatus.SC_BAD_REQUEST: // 400
199194
case HttpStatus.SC_UNAUTHORIZED: // 401
200195
// Retry with username and password
201-
System.out.println("Refinitiv Data Platform authentication HTTP code: " + response.getStatusLine().getStatusCode() + " " + response.getStatusLine().getReasonPhrase());
196+
System.out.println("Refinitiv Data Platform authentication HTTP code: " + response.getCode() + " " + response.getReasonPhrase());
202197
if (previousAuthResponseJson != null) {
203198
System.out.println("Retry with username and password");
204199
return getAuthenticationInfo(null, connectionProperties.get("AUTHURL").toString());
@@ -209,12 +204,12 @@ public JSONObject getAuthenticationInfo(JSONObject previousAuthResponseJson, Str
209204
case HttpStatus.SC_GONE: // 410
210205
case 451: // 451 Unavailable For Legal Reasons
211206
// Stop retrying with the request
212-
System.out.println("Refinitiv Data Platform authentication HTTP code: " + response.getStatusLine().getStatusCode() + " " + response.getStatusLine().getReasonPhrase());
207+
System.out.println("Refinitiv Data Platform authentication HTTP code: " + response.getCode() + " " + response.getReasonPhrase());
213208
System.out.println("Stop retrying with the request");
214209
return null;
215210
default:
216211
// Retry the request to Refinitiv Data Platform
217-
System.out.println("Refinitiv Data Platform authentication HTTP code: " + response.getStatusLine().getStatusCode() + " " + response.getStatusLine().getReasonPhrase());
212+
System.out.println("Refinitiv Data Platform authentication HTTP code: " + response.getCode() + " " + response.getReasonPhrase());
218213
Thread.sleep(5000);
219214
// CAUTION: This is sample code with infinite retries.
220215
System.out.println("Retry the request to Refinitiv Data Platform");

src/main/java/net/finmath/smartcontract/valuation/service/config/BasicAuthWebSecurityConfiguration.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@
2424

2525
@Configuration
2626
@EnableWebSecurity
27-
@EnableConfigurationProperties(value = ApplicationProperties.class)
27+
//@EnableConfigurationProperties(value = ApplicationProperties.class)
2828
public class BasicAuthWebSecurityConfiguration {
2929

3030
Logger logger = LoggerFactory.getLogger(BasicAuthWebSecurityConfiguration.class);

0 commit comments

Comments
 (0)