Skip to content

Commit 3b31dc5

Browse files
committed
Merge branch 'main' into ian-UID2-6345-enable-upload-only-optout-producer
2 parents 5be2020 + d2fe0f1 commit 3b31dc5

File tree

6 files changed

+117
-13
lines changed

6 files changed

+117
-13
lines changed

.trivyignore

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,5 +2,4 @@
22
# See https://aquasecurity.github.io/trivy/v0.35/docs/vulnerability/examples/filter/
33
# for more details
44

5-
# UID2-6128
6-
CVE-2025-55163 exp:2025-10-30
5+

pom.xml

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55

66
<groupId>com.uid2</groupId>
77
<artifactId>uid2-shared</artifactId>
8-
<version>11.1.91</version>
8+
<version>11.1.124</version>
99
<name>${project.groupId}:${project.artifactId}</name>
1010
<description>Library for all the shared uid2 operations</description>
1111
<url>https://github.com/IABTechLab/uid2docs</url>
@@ -181,7 +181,7 @@
181181
<dependency>
182182
<groupId>com.google.auth</groupId>
183183
<artifactId>google-auth-library-oauth2-http</artifactId>
184-
<version>1.30.0</version>
184+
<version>1.41.0</version>
185185
</dependency>
186186
<dependency>
187187
<groupId>com.azure</groupId>
@@ -213,6 +213,11 @@
213213
<artifactId>commons-collections4</artifactId>
214214
<version>4.4</version>
215215
</dependency>
216+
<dependency>
217+
<groupId>commons-logging</groupId>
218+
<artifactId>commons-logging</artifactId>
219+
<version>1.3.4</version>
220+
</dependency>
216221
<dependency>
217222
<groupId>software.amazon.awssdk</groupId>
218223
<artifactId>secretsmanager</artifactId>

src/main/java/com/uid2/shared/attest/UidCoreClient.java

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -89,8 +89,12 @@ private InputStream internalDownload(String path) throws CloudStorageException {
8989
inputStream = getWithAttest(path);
9090
}
9191
return inputStream;
92+
} catch (CloudStorageException e) {
93+
throw e;
9294
} catch (Exception e) {
93-
throw new CloudStorageException("download error: " + e.getMessage(), e);
95+
throw new CloudStorageException(
96+
"E12: Data Download Failure - exception: " + e.getClass().getSimpleName() +
97+
". For troubleshooting information, refer to the applicable Private Operator guide: see https://unifiedid.com/docs/guides/integration-options-private-operator.", e);
9498
}
9599
}
96100

@@ -108,7 +112,9 @@ private InputStream getWithAttest(String path) throws IOException, AttestationRe
108112
HttpResponse<String> httpResponse;
109113
httpResponse = sendHttpRequest(path, attestationToken);
110114
if (httpResponse.statusCode() != 200) {
111-
throw new CloudStorageException(String.format("Non-success response from core on request to %s. Status code: %d", path, httpResponse.statusCode()));
115+
throw new CloudStorageException(String.format(
116+
"E12: Data Download Failure - HTTP response code %d. For troubleshooting information, refer to the applicable Private Operator guide: see https://unifiedid.com/docs/guides/integration-options-private-operator.",
117+
httpResponse.statusCode()));
112118
}
113119
return Utils.convertHttpResponseToInputStream(httpResponse);
114120
}

src/main/java/com/uid2/shared/cloud/URLStorageWithMetadata.java

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -48,8 +48,8 @@ public InputStream download(String cloudPath) throws CloudStorageException {
4848
if (responseCode >= 200 && responseCode < 300) {
4949
return httpConn.getInputStream();
5050
} else {
51-
throw new CloudStorageException("Cannot download required files, HTTP response code " + responseCode
52-
+ ", please visit UID2 guides for more details");
51+
throw new CloudStorageException("E12: Data Download Failure - HTTP response code " + responseCode
52+
+ ". For troubleshooting information, refer to the applicable Private Operator guide: see https://unifiedid.com/docs/guides/integration-options-private-operator.");
5353
}
5454
}
5555
catch (CloudStorageException e) {
@@ -58,8 +58,8 @@ public InputStream download(String cloudPath) throws CloudStorageException {
5858
}
5959
catch (Throwable t) {
6060
// Do not log the original exception as it may contain sensitive information such as the pre-signed URL
61-
throw new CloudStorageException("Cannot download required files, exception: " + t.getClass().getSimpleName() +
62-
", please visit UID2 guides for more details");
61+
throw new CloudStorageException("E12: Data Download Failure - exception: " + t.getClass().getSimpleName() +
62+
". For troubleshooting information, refer to the applicable Private Operator guide: see https://unifiedid.com/docs/guides/integration-options-private-operator.");
6363
}
6464
}
6565

src/main/java/com/uid2/shared/vertx/CloudSyncVerticle.java

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -414,8 +414,13 @@ private void cloudDownloadBlocking(String s3Path) throws Exception {
414414

415415
downloadFailureTimer.record(java.time.Duration.ofMillis(cloudDownloadTimeMs));
416416
// Be careful as the s3Path may contain the pre-signed S3 token, so do not log the whole path
417-
LOGGER.error("download error: " + ex.getClass().getSimpleName());
418-
throw new CloudStorageException("Download failed");
417+
LOGGER.error("Cloud storage download error, exception type: " + ex.getClass().getSimpleName());
418+
419+
if (ex instanceof CloudStorageException) {
420+
throw (CloudStorageException) ex;
421+
}
422+
throw new CloudStorageException("E12: Data Download Failure - Failed to download file from cloud storage, exception: "
423+
+ ex.getClass().getSimpleName() + ". Check network connectivity and service availability.");
419424
}
420425
}
421426

src/test/java/com/uid2/shared/attest/UidCoreClientTest.java

Lines changed: 90 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,7 @@ public void Download_AttestInternalFail_ExceptionThrown() throws IOException, At
7272
CloudStorageException result = assertThrows(CloudStorageException.class, () -> {
7373
uidCoreClient.download("https://download");
7474
});
75-
String expectedExceptionMessage = "download error: AttestationResponseCode: AttestationFailure, test failure";
75+
String expectedExceptionMessage = "E12: Data Download Failure - exception: AttestationResponseHandlerException. For troubleshooting information, refer to the applicable Private Operator guide: see https://unifiedid.com/docs/guides/integration-options-private-operator.";
7676
assertEquals(expectedExceptionMessage, result.getMessage());
7777
}
7878

@@ -100,4 +100,93 @@ void getJwtReturnsCoreToken() {
100100
when(mockAttestationResponseHandler.getCoreJWT()).thenReturn("coreJWT");
101101
Assertions.assertEquals("coreJWT", this.uidCoreClient.getJWT());
102102
}
103+
104+
@Test
105+
public void Download_Http403Error_LogsStatusCodeAndEndpoint() throws IOException, AttestationResponseHandlerException {
106+
HttpResponse<String> mockHttpResponse = mock(HttpResponse.class);
107+
when(mockHttpResponse.statusCode()).thenReturn(403);
108+
when(mockHttpClient.get(eq("https://core-prod.uidapi.com/sites/refresh"), any(HashMap.class))).thenReturn(mockHttpResponse);
109+
110+
CloudStorageException result = assertThrows(CloudStorageException.class, () -> {
111+
uidCoreClient.download("https://core-prod.uidapi.com/sites/refresh");
112+
});
113+
114+
assertAll(
115+
() -> assertTrue(result.getMessage().contains("E12: Data Download Failure"),
116+
"Expected E12 error code in message"),
117+
() -> assertTrue(result.getMessage().contains("HTTP response code 403"),
118+
"Expected HTTP status code 403 in message"),
119+
() -> assertTrue(result.getMessage().contains("For troubleshooting information, refer to the applicable Private Operator guide"),
120+
"Expected documentation reference in message")
121+
);
122+
}
123+
124+
@Test
125+
public void Download_Http404Error_LogsStatusCode() throws IOException, AttestationResponseHandlerException {
126+
HttpResponse<String> mockHttpResponse = mock(HttpResponse.class);
127+
when(mockHttpResponse.statusCode()).thenReturn(404);
128+
when(mockHttpClient.get(eq("https://core-prod.uidapi.com/keys/refresh"), any(HashMap.class))).thenReturn(mockHttpResponse);
129+
130+
CloudStorageException result = assertThrows(CloudStorageException.class, () -> {
131+
uidCoreClient.download("https://core-prod.uidapi.com/keys/refresh");
132+
});
133+
134+
assertAll(
135+
() -> assertTrue(result.getMessage().contains("HTTP response code 404"),
136+
"Expected HTTP status code 404 in message"),
137+
() -> assertTrue(result.getMessage().contains("E12: Data Download Failure"),
138+
"Expected E12 error code in message")
139+
);
140+
}
141+
142+
@Test
143+
public void Download_Http500Error_LogsStatusCode() throws IOException, AttestationResponseHandlerException {
144+
HttpResponse<String> mockHttpResponse = mock(HttpResponse.class);
145+
when(mockHttpResponse.statusCode()).thenReturn(500);
146+
when(mockHttpClient.get(eq("https://core-prod.uidapi.com/salts/refresh"), any(HashMap.class))).thenReturn(mockHttpResponse);
147+
148+
CloudStorageException result = assertThrows(CloudStorageException.class, () -> {
149+
uidCoreClient.download("https://core-prod.uidapi.com/salts/refresh");
150+
});
151+
152+
assertAll(
153+
() -> assertTrue(result.getMessage().contains("E12: Data Download Failure"),
154+
"Expected E12 error code in message"),
155+
() -> assertTrue(result.getMessage().contains("HTTP response code 500"),
156+
"Expected HTTP status code 500 in message")
157+
);
158+
}
159+
160+
@Test
161+
public void Download_Http503Error_LogsStatusCode() throws IOException, AttestationResponseHandlerException {
162+
HttpResponse<String> mockHttpResponse = mock(HttpResponse.class);
163+
when(mockHttpResponse.statusCode()).thenReturn(503);
164+
when(mockHttpClient.get(eq("https://core-integ.uidapi.com/clients/refresh"), any(HashMap.class))).thenReturn(mockHttpResponse);
165+
166+
CloudStorageException result = assertThrows(CloudStorageException.class, () -> {
167+
uidCoreClient.download("https://core-integ.uidapi.com/clients/refresh");
168+
});
169+
170+
assertTrue(result.getMessage().contains("HTTP response code 503"),
171+
"Expected HTTP status code 503 in message");
172+
}
173+
174+
@Test
175+
public void Download_NetworkError_LogsExceptionType() throws IOException, AttestationResponseHandlerException {
176+
IOException networkException = new IOException("Connection timeout");
177+
when(mockHttpClient.get(anyString(), any(HashMap.class))).thenThrow(networkException);
178+
179+
CloudStorageException result = assertThrows(CloudStorageException.class, () -> {
180+
uidCoreClient.download("https://core-prod.uidapi.com/sites/refresh");
181+
});
182+
183+
assertAll(
184+
() -> assertTrue(result.getMessage().contains("E12: Data Download Failure"),
185+
"Expected E12 error code in message"),
186+
() -> assertTrue(result.getMessage().contains("exception: IOException"),
187+
"Expected exception type in message"),
188+
() -> assertTrue(result.getMessage().contains("For troubleshooting information, refer to the applicable Private Operator guide"),
189+
"Expected documentation reference in message")
190+
);
191+
}
103192
}

0 commit comments

Comments
 (0)