Skip to content
Open
Show file tree
Hide file tree
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
2 changes: 1 addition & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

<groupId>com.uid2</groupId>
<artifactId>uid2-operator</artifactId>
<version>5.66.29</version>
<version>5.66.24-alpha-317-SNAPSHOT</version>

<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
Expand Down
10 changes: 10 additions & 0 deletions src/main/java/com/uid2/operator/model/MapRequest.java
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,23 @@ public final class MapRequest {
public final UserIdentity userIdentity;
public final Instant asOf;
public final IdentityEnvironment identityEnvironment;
public final boolean includePreviousAdvertisingId;

public MapRequest(
UserIdentity userIdentity,
Instant asOf,
IdentityEnvironment identityEnvironment) {
this(userIdentity, asOf, identityEnvironment, true);
}

public MapRequest(
UserIdentity userIdentity,
Instant asOf,
IdentityEnvironment identityEnvironment,
boolean includePreviousAdvertisingId) {
this.userIdentity = userIdentity;
this.asOf = asOf;
this.identityEnvironment = identityEnvironment;
this.includePreviousAdvertisingId = includePreviousAdvertisingId;
}
}
7 changes: 7 additions & 0 deletions src/main/java/com/uid2/operator/model/MappedIdentity.java
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,13 @@ public class MappedIdentity {
public static final MappedIdentity LogoutIdentity = new MappedIdentity(new byte[33], "", null, null);
public final byte[] advertisingId;
public final String bucketId;
/**
* The advertising ID computed using the previous rotating salt, or {@code null} if:
* <ul>
* <li>The caller did not request it (i.e. {@code MapRequest.includePreviousAdvertisingId} was {@code false}), or</li>
* <li>No previous salt is available, or the salt was last rotated more than 90 days ago.</li>
* </ul>
*/
public final byte[] previousAdvertisingId;
public final Long refreshFrom;

Expand Down
10 changes: 8 additions & 2 deletions src/main/java/com/uid2/operator/service/UIDOperatorService.java
Original file line number Diff line number Diff line change
Expand Up @@ -156,7 +156,7 @@ public MappedIdentity mapIdentity(MapRequest request) {
if (getGlobalOptOutResult(firstLevelHashIdentity, false).isOptedOut()) {
return MappedIdentity.LogoutIdentity;
} else {
return getMappedIdentity(firstLevelHashIdentity, request.asOf, request.identityEnvironment);
return getMappedIdentity(firstLevelHashIdentity, request.asOf, request.identityEnvironment, request.includePreviousAdvertisingId);
}
}

Expand Down Expand Up @@ -248,9 +248,15 @@ private byte[] getFirstLevelHash(byte[] identityHash, Instant asOf) {
}

private MappedIdentity getMappedIdentity(UserIdentity firstLevelHashIdentity, Instant asOf, IdentityEnvironment env) {
return getMappedIdentity(firstLevelHashIdentity, asOf, env, false);
}

private MappedIdentity getMappedIdentity(UserIdentity firstLevelHashIdentity, Instant asOf, IdentityEnvironment env, boolean includePreviousAdvertisingId) {
final SaltEntry rotatingSalt = getSaltProviderSnapshot(asOf).getRotatingSalt(firstLevelHashIdentity.id);
final byte[] advertisingId = getAdvertisingId(firstLevelHashIdentity, rotatingSalt.currentSalt(), rotatingSalt.currentKeySalt(), env);
final byte[] previousAdvertisingId = getPreviousAdvertisingId(firstLevelHashIdentity, rotatingSalt, asOf, env);
final byte[] previousAdvertisingId = includePreviousAdvertisingId
? getPreviousAdvertisingId(firstLevelHashIdentity, rotatingSalt, asOf, env)
: null;
final long refreshFrom = getRefreshFrom(rotatingSalt, asOf);

return new MappedIdentity(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1114,7 +1114,8 @@ private JsonObject handleIdentityMapCommon(RoutingContext rc, InputUtil.InputVal
new MapRequest(
input.toUserIdentity(this.identityScope, 0, now),
now,
env));
env,
false)); // v2 does not use previousAdvertisingId

if (mappedIdentity.isOptedOut()) {
final JsonObject resp = new JsonObject();
Expand Down
6 changes: 3 additions & 3 deletions src/test/java/com/uid2/operator/UIDOperatorServiceTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -835,7 +835,7 @@ void testMappedIdentityWithPreviousSaltReturnsPreviousUid() {

var email = "test@uid.com";
InputUtil.InputVal emailInput = generateInputVal(TestIdentityInputType.Email, email);
MapRequest mapRequest = new MapRequest(emailInput.toUserIdentity(IdentityScope.UID2, 0, this.now), now, IdentityEnvironment.TEST);
MapRequest mapRequest = new MapRequest(emailInput.toUserIdentity(IdentityScope.UID2, 0, this.now), now, IdentityEnvironment.TEST);

MappedIdentity mappedIdentity = uid2Service.mapIdentity(mapRequest);

Expand All @@ -858,7 +858,7 @@ void testMappedIdentityWithOutdatedPreviousSaltReturnsNoPreviousUid(long extraMs

var email = "test@uid.com";
InputUtil.InputVal emailInput = generateInputVal(TestIdentityInputType.Email, email);
MapRequest mapRequest = new MapRequest(emailInput.toUserIdentity(IdentityScope.UID2, 0, this.now), now, IdentityEnvironment.TEST);
MapRequest mapRequest = new MapRequest(emailInput.toUserIdentity(IdentityScope.UID2, 0, this.now), now, IdentityEnvironment.TEST);

MappedIdentity mappedIdentity = uid2Service.mapIdentity(mapRequest);
var expectedCurrentUID = UIDOperatorVerticleTest.getRawUid(IdentityScope.UID2, IdentityType.Email, email, FIRST_LEVEL_SALT, salt.currentSalt(), uid2Config.getBoolean(IdentityV3Prop));
Expand All @@ -878,7 +878,7 @@ void testMappedIdentityWithNoPreviousSaltReturnsNoPreviousUid() {

var email = "test@uid.com";
InputUtil.InputVal emailInput = generateInputVal(TestIdentityInputType.Email, email);
MapRequest mapRequest = new MapRequest(emailInput.toUserIdentity(IdentityScope.UID2, 0, this.now), now, IdentityEnvironment.TEST);
MapRequest mapRequest = new MapRequest(emailInput.toUserIdentity(IdentityScope.UID2, 0, this.now), now, IdentityEnvironment.TEST);

MappedIdentity mappedIdentity = uid2Service.mapIdentity(mapRequest);

Expand Down