Skip to content

Commit 9c2ad5f

Browse files
Modify UidCoreClient to request for encryptedFiles (#406)
* Add option to pass in encryption
1 parent a78e91e commit 9c2ad5f

File tree

3 files changed

+17
-6
lines changed

3 files changed

+17
-6
lines changed

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

Lines changed: 14 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -21,23 +21,32 @@ public class UidCoreClient implements IUidCoreClient, DownloadCloudStorage {
2121
private String userToken;
2222
private final String appVersionHeader;
2323
private boolean allowContentFromLocalFileSystem = false;
24+
private boolean encryptionEnabled;
2425
private final AttestationResponseHandler attestationResponseHandler;
2526

2627

2728
public static UidCoreClient createNoAttest(String userToken, AttestationResponseHandler attestationResponseHandler) {
28-
return new UidCoreClient(userToken, CloudUtils.defaultProxy, attestationResponseHandler, null);
29+
return new UidCoreClient(userToken, CloudUtils.defaultProxy, attestationResponseHandler, null, false);
2930
}
3031

3132
public UidCoreClient(String userToken,
3233
Proxy proxy,
3334
AttestationResponseHandler attestationResponseHandler) {
34-
this(userToken, proxy, attestationResponseHandler, null);
35+
this(userToken, proxy, attestationResponseHandler, null, false);
36+
}
37+
38+
public UidCoreClient(String userToken,
39+
Proxy proxy,
40+
AttestationResponseHandler attestationResponseHandler, boolean encryptionEnabled) {
41+
this(userToken, proxy, attestationResponseHandler, null, encryptionEnabled);
3542
}
3643

3744
public UidCoreClient(String userToken,
3845
Proxy proxy,
3946
AttestationResponseHandler attestationResponseHandler,
40-
URLConnectionHttpClient httpClient) {
47+
URLConnectionHttpClient httpClient,
48+
boolean encryptionEnabled) {
49+
this.encryptionEnabled = encryptionEnabled;
4150
this.proxy = proxy;
4251
this.userToken = userToken;
4352
this.contentStorage = new PreSignedURLStorage(proxy);
@@ -106,6 +115,8 @@ private HttpResponse<String> sendHttpRequest(String path, String attestationToke
106115

107116
HashMap<String, String> headers = new HashMap<>();
108117
headers.put(Const.Http.AppVersionHeader, this.appVersionHeader);
118+
if (this.encryptionEnabled)
119+
headers.put("Encrypted", String.valueOf(this.encryptionEnabled));
109120
if (this.userToken != null && !this.userToken.isBlank()) {
110121
headers.put("Authorization", "Bearer " + this.userToken);
111122
}

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,15 +17,15 @@ public class UidOptOutClient extends UidCoreClient {
1717
public UidOptOutClient(String userToken,
1818
Proxy proxy,
1919
AttestationResponseHandler attestationResponseHandler) {
20-
super(userToken, proxy, attestationResponseHandler, null);
20+
super(userToken, proxy, attestationResponseHandler, null, false);
2121
this.attestationResponseHandler = attestationResponseHandler;
2222
}
2323

2424
public UidOptOutClient(String userToken,
2525
Proxy proxy,
2626
AttestationResponseHandler attestationResponseHandler,
2727
URLConnectionHttpClient httpClient) {
28-
super(userToken, proxy, attestationResponseHandler, httpClient);
28+
super(userToken, proxy, attestationResponseHandler, httpClient, false);
2929
this.attestationResponseHandler = attestationResponseHandler;
3030
}
3131

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ void setUp() {
3333
when(mockAttestationResponseHandler.getAppVersionHeader()).thenReturn("testAppVersionHeader");
3434
uidCoreClient = new UidCoreClient(
3535
"userToken", proxy,
36-
mockAttestationResponseHandler, mockHttpClient);
36+
mockAttestationResponseHandler, mockHttpClient, false);
3737
}
3838

3939
@Test

0 commit comments

Comments
 (0)