Skip to content
Merged
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
14 changes: 11 additions & 3 deletions src/main/java/com/uid2/operator/store/CloudSyncOptOutStore.java
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@ public class CloudSyncOptOutStore implements IOptOutStore {
private final String remoteApiHost;
private final String remoteApiPath;
private final String remoteApiBearerToken;
private final boolean remoteApiSsl;

public CloudSyncOptOutStore(Vertx vertx, ICloudStorage fsLocal, JsonObject jsonConfig, String operatorKey, Clock clock) throws MalformedURLException {
this.fsLocal = fsLocal;
Expand All @@ -61,7 +62,9 @@ public CloudSyncOptOutStore(Vertx vertx, ICloudStorage fsLocal, JsonObject jsonC
String remoteApi = jsonConfig.getString(Const.Config.OptOutApiUriProp);
if (remoteApi != null) {
URL url = new URL(remoteApi);
this.remoteApiPort = -1 == url.getPort() ? 80 : url.getPort();
boolean isHttps = "https".equalsIgnoreCase(url.getProtocol());
this.remoteApiSsl = isHttps;
this.remoteApiPort = url.getPort() != -1 ? url.getPort() : url.getDefaultPort();
this.remoteApiHost = url.getHost();
this.remoteApiPath = url.getPath();
this.remoteApiBearerToken = "Bearer " + operatorKey;
Expand All @@ -70,6 +73,7 @@ public CloudSyncOptOutStore(Vertx vertx, ICloudStorage fsLocal, JsonObject jsonC
this.remoteApiHost = null;
this.remoteApiPath = null;
this.remoteApiBearerToken = null;
this.remoteApiSsl = false;
}

this.snapshot.set(new OptOutStoreSnapshot(fsLocal, jsonConfig, clock));
Expand Down Expand Up @@ -101,13 +105,17 @@ public void addEntry(UserIdentity firstLevelHashIdentity,
return;
}

HttpRequest<String> request = this.webClient.post(remoteApiPort, remoteApiHost, remoteApiPath).
addQueryParam("identity_hash", EncodingUtils.toBase64String(firstLevelHashIdentity.id))
HttpRequest<String> request = this.webClient.post(remoteApiPort, remoteApiHost, remoteApiPath)
.addQueryParam("identity_hash", EncodingUtils.toBase64String(firstLevelHashIdentity.id))
.addQueryParam("advertising_id", EncodingUtils.toBase64String(advertisingId))
.putHeader("Authorization", remoteApiBearerToken)
.putHeader(Audit.UID_INSTANCE_ID_HEADER, uidInstanceId)
.as(BodyCodec.string());

if (remoteApiSsl) {
request = request.ssl(true);
}

JsonObject payload = new JsonObject();
if (email != null) payload.put("email", email);
if (phone != null) payload.put("phone", phone);
Expand Down