Skip to content

Commit d8835a5

Browse files
committed
revert: remove bounded response reader, strip internal codes, fix version
- Remove BoundedResponseReader and ResponseTooLargeException (not needed; Safeguard appliances are closed hardened systems) - Revert Utils.getResponse and PkceAuthenticator to use EntityUtils - Remove mockwebserver test dependency and response size cap test - Remove handleDisconnect Phase-2 reconnect comment - Strip internal finding IDs from test Javadoc - Version 8.2.1-SNAPSHOT (patch bump, not minor)
1 parent b33fa67 commit d8835a5

10 files changed

Lines changed: 14 additions & 362 deletions

File tree

pipeline-templates/global-variables.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
variables:
22
- name: semanticVersion
3-
value: '8.3.0'
3+
value: '8.2.1'
44
- name: isTagBuild
55
value: ${{ startsWith(variables['Build.SourceBranch'], 'refs/tags/') }}
66
- name: isPrerelease

pom.xml

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313

1414
<properties>
1515
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
16-
<revision>8.3.0-SNAPSHOT</revision>
16+
<revision>8.2.1-SNAPSHOT</revision>
1717
<gpgkeyname>keyname</gpgkeyname>
1818
</properties>
1919

@@ -74,12 +74,6 @@
7474
<version>4.13.2</version>
7575
<scope>test</scope>
7676
</dependency>
77-
<dependency>
78-
<groupId>com.squareup.okhttp3</groupId>
79-
<artifactId>mockwebserver</artifactId>
80-
<version>4.12.0</version>
81-
<scope>test</scope>
82-
</dependency>
8377
</dependencies>
8478

8579

src/main/java/com/oneidentity/safeguard/safeguardjava/Utils.java

Lines changed: 6 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,6 @@
22

33
import com.fasterxml.jackson.core.type.TypeReference;
44
import com.fasterxml.jackson.databind.ObjectMapper;
5-
import com.oneidentity.safeguard.safeguardjava.exceptions.ResponseTooLargeException;
6-
import com.oneidentity.safeguard.safeguardjava.exceptions.SafeguardForJavaException;
7-
import com.oneidentity.safeguard.safeguardjava.restclient.BoundedResponseReader;
85
import java.io.IOException;
96
import java.security.Provider;
107
import java.security.Security;
@@ -13,7 +10,9 @@
1310
import org.slf4j.Logger;
1411
import org.slf4j.LoggerFactory;
1512
import org.apache.hc.core5.http.HttpEntity;
13+
import org.apache.hc.core5.http.ParseException;
1614
import org.apache.hc.client5.http.impl.classic.CloseableHttpResponse;
15+
import org.apache.hc.core5.http.io.entity.EntityUtils;
1716

1817
public class Utils {
1918

@@ -49,30 +48,13 @@ public static Map<String, String> parseResponse(String response) {
4948
return map;
5049
}
5150

52-
/**
53-
* Read the response body as a String, capped at
54-
* {@link BoundedResponseReader#DEFAULT_MAX_BYTES} (10 MB).
55-
*
56-
* <p>The cap defends against a misbehaving or malicious appliance
57-
* advertising a huge Content-Length or sending an unbounded chunked
58-
* stream that would otherwise OOM the client.
59-
*
60-
* @throws SafeguardForJavaException if the body exceeds the cap
61-
* (as {@link ResponseTooLargeException}). I/O errors during
62-
* body read are swallowed for backwards compatibility, matching
63-
* the prior behaviour of this helper.
64-
*/
65-
public static String getResponse(CloseableHttpResponse response) throws SafeguardForJavaException {
51+
public static String getResponse(CloseableHttpResponse response) {
6652
HttpEntity entity = response.getEntity();
6753
if (entity != null) {
6854
try {
69-
String body = BoundedResponseReader.readBodyAsString(entity);
70-
return body != null ? body : "";
71-
} catch (ResponseTooLargeException ex) {
72-
throw ex;
73-
} catch (IOException ex) {
74-
logger.warn("Failed to read response body", ex);
75-
}
55+
return EntityUtils.toString(response.getEntity());
56+
57+
} catch (IOException | ParseException ex) {}
7658
}
7759
return "";
7860
}

src/main/java/com/oneidentity/safeguard/safeguardjava/authentication/PkceAuthenticator.java

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,7 @@
66
import com.oneidentity.safeguard.safeguardjava.Utils;
77
import com.oneidentity.safeguard.safeguardjava.exceptions.ArgumentException;
88
import com.oneidentity.safeguard.safeguardjava.exceptions.ObjectDisposedException;
9-
import com.oneidentity.safeguard.safeguardjava.exceptions.ResponseTooLargeException;
109
import com.oneidentity.safeguard.safeguardjava.exceptions.SafeguardForJavaException;
11-
import com.oneidentity.safeguard.safeguardjava.restclient.BoundedResponseReader;
1210
import com.oneidentity.safeguard.safeguardjava.restclient.RestClient;
1311
import java.io.IOException;
1412
import java.net.URLEncoder;
@@ -32,8 +30,10 @@
3230
import org.apache.hc.client5.http.ssl.SSLConnectionSocketFactory;
3331
import org.apache.hc.core5.http.ContentType;
3432
import org.apache.hc.core5.http.HttpHeaders;
33+
import org.apache.hc.core5.http.ParseException;
3534
import org.apache.hc.core5.http.config.Registry;
3635
import org.apache.hc.core5.http.config.RegistryBuilder;
36+
import org.apache.hc.core5.http.io.entity.EntityUtils;
3737
import org.apache.hc.core5.http.io.entity.StringEntity;
3838

3939
/**
@@ -349,10 +349,7 @@ private String rstsFormPost(CloseableHttpClient httpClient, String url, String f
349349
CloseableHttpResponse response = httpClient.execute(post);
350350
String body = "";
351351
if (response.getEntity() != null) {
352-
body = BoundedResponseReader.readBodyAsString(response.getEntity());
353-
if (body == null) {
354-
body = "";
355-
}
352+
body = EntityUtils.toString(response.getEntity());
356353
}
357354

358355
int statusCode = response.getCode();
@@ -366,7 +363,7 @@ private String rstsFormPost(CloseableHttpClient httpClient, String url, String f
366363
return body;
367364
} catch (SafeguardForJavaException e) {
368365
throw e;
369-
} catch (IOException e) {
366+
} catch (ParseException | IOException e) {
370367
throw new SafeguardForJavaException("Failed to communicate with rSTS login controller", e);
371368
}
372369
}

src/main/java/com/oneidentity/safeguard/safeguardjava/event/SafeguardEventListener.java

Lines changed: 0 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -288,24 +288,6 @@ private void handleEvent(JsonElement eventObject) {
288288
eventHandlerRegistry.handleEvent(eventObject);
289289
}
290290

291-
/**
292-
* Handle a SignalR disconnect.
293-
*
294-
* <p><b>Reconnect design note (security review FP-SafeguardJava-005, audit):</b>
295-
* Unlike the sibling SafeguardDotNet event listener, this Java implementation
296-
* has no native reconnect loop. On disconnect we delegate to
297-
* {@code disconnectHandler.func()}; the {@link DefaultDisconnectHandler}
298-
* raises {@link SafeguardEventListenerDisconnectedException} so the caller
299-
* picks the reconnect strategy (immediate retry, exponential backoff, give
300-
* up, etc.). This is a deliberate, valid distinct design — there is no
301-
* uncapped tight-loop reconnect to harden — but it does mean the SDK does
302-
* not enforce a jittered exponential backoff on the caller's behalf.
303-
* When Phase 2 introduces a default backoff helper, mirror the algorithm
304-
* from the sibling SafeguardDotNet SDK at
305-
* {@code SafeguardDotNet/Event/ReconnectBackoff.cs}: exponential delay
306-
* {@code min(60s, 2^n × 1s)} with ±25% jitter, reset on successful
307-
* reconnect.
308-
*/
309291
private void handleDisconnect() throws SafeguardEventListenerDisconnectedException {
310292
if(!this.isStarted()) {
311293
return;

src/main/java/com/oneidentity/safeguard/safeguardjava/exceptions/ResponseTooLargeException.java

Lines changed: 0 additions & 26 deletions
This file was deleted.

src/main/java/com/oneidentity/safeguard/safeguardjava/restclient/BoundedResponseReader.java

Lines changed: 0 additions & 108 deletions
This file was deleted.

src/test/java/com/oneidentity/safeguard/safeguardjava/event/SafeguardEventListenerSSLContextTest.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
import org.junit.Test;
88

99
/**
10-
* Regression test for FP-SafeguardJava-001 (W2 — TLS version pinning).
10+
* Regression test: TLS version pinning.
1111
*
1212
* <p>Mirror of {@code RestClientSSLContextTest} for the SignalR event
1313
* listener path: ensures the listener's HTTP client builder is wired with

0 commit comments

Comments
 (0)