Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Final Refactoring - Syw UID2-4158 token gen code refactoring user identity #1123

Open
wants to merge 69 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
69 commits
Select commit Hold shift + click to select a range
1693ea8
Renamed IdentityToken class and variables to Identity as it's a set o…
sunnywu Oct 10, 2024
14fd733
Renamed Identity.LogoutToken to InvalidIdentity and added some commen…
sunnywu Oct 10, 2024
7dd3a69
Renamed Identity.LogoutToken to InvalidIdentity and added some commen…
sunnywu Oct 10, 2024
f2e7a87
renamed getAdvertisingId to MappedIdentity
sunnywu Oct 11, 2024
c0cb6df
Split UserIdentity into 3 distinct classes - HashedDiiIdentity, First…
sunnywu Oct 11, 2024
0fccf8c
Added brief comment to Identity/MappedIdentity
sunnywu Oct 11, 2024
113e8ca
Renamed MappedIdentity to MappedIdentityResult
sunnywu Oct 11, 2024
ae03ff5
1. Rename AdvertisingToken class to AdvertisingTokenInput
sunnywu Oct 11, 2024
5595a15
Renamed ITokenEncoder.encode to ITokenEncoder.encodeIntoIdentityResponse
sunnywu Oct 11, 2024
c6bc08f
Renamed Identity.isEmptyToken method to Identity.isNotValid
sunnywu Oct 11, 2024
639b799
Renamed PublisherIdentity to SourcePublisher
sunnywu Oct 11, 2024
d9c730e
Refactored UserIdentity as a base class which is inherited by HashedD…
sunnywu Oct 11, 2024
42c5890
Renamed Identity to IdentityResponse
sunnywu Oct 11, 2024
b62aa54
Fixed using raw identity in testGenerateTokenForOptOutUser
sunnywu Oct 14, 2024
b272d40
Renamed RefreshResponse#getIdentity to RefreshResponse#getIdentityRes…
sunnywu Oct 14, 2024
7e5ad5d
1. Refactor EncryptedTokenEncoder#encodeIntoIdentityResponse
sunnywu Oct 14, 2024
131d203
Use EncryptedTokenEncoder directly inside UIDOperatorService class in…
sunnywu Oct 14, 2024
8dc0a41
Renamed MappedIdentity to RawUid2Result and UIDOperatorService.getAd…
sunnywu Oct 14, 2024
91ffa12
1. Fixed RawUid2Result to RawUidResult
sunnywu Oct 14, 2024
d9845b7
Merge branch 'syw-UID2-4159-token-gen-code-renaming' into syw-UID2-41…
sunnywu Oct 14, 2024
4bb4ccb
Renamed IdentityResponse.optOutIdentityResponse to OptOutIdentityResp…
sunnywu Oct 14, 2024
8ae5e08
Renamed IdentityResponse.optoutIdentityResponse to OptOutIdentityResp…
sunnywu Oct 14, 2024
5a0bb89
Merge branch 'syw-UID2-4159-token-gen-code-renaming' into syw-UID2-41…
sunnywu Oct 14, 2024
b507d8e
Fixed UserIdentity member variables as final and added constructor
sunnywu Oct 15, 2024
f5877b7
1. Addressed code review feedbacks
sunnywu Oct 15, 2024
ccc639f
Made UserIdentity abstract first
sunnywu Oct 15, 2024
dabff48
Fixed a few id variable to rawUid/firstLevelHash to make it clear. Fi…
sunnywu Oct 15, 2024
d8eda03
Fixed UserIdentity member variables as final and added constructor
sunnywu Oct 15, 2024
e74e8da
1. Addressed code review feedbacks
sunnywu Oct 15, 2024
7f4ebf5
Made UserIdentity abstract first
sunnywu Oct 15, 2024
72f7be4
Fixed a few id variable to rawUid/firstLevelHash to make it clear. Fi…
sunnywu Oct 15, 2024
44ed5d3
Merge remote-tracking branch 'origin/syw-UID2-4159-token-gen-code-ren…
sunnywu Oct 15, 2024
21f0c60
1. Refactored EncryptedTokenEncoder to rename encode/encodev2/encodev3
sunnywu Oct 16, 2024
6031d14
Merge remote-tracking branch 'origin/syw-UID2-4159-token-gen-code-ren…
sunnywu Oct 16, 2024
3b1718c
1. Removed the UserIdentity's refreshedAt field as that's redundant and
sunnywu Oct 16, 2024
0ab0a79
1. Removed privacyBits and establishedAt from UserIdentity/HashedDiiI…
sunnywu Oct 16, 2024
7538bfb
added comments
sunnywu Oct 16, 2024
249c25d
fixed variable name
sunnywu Oct 16, 2024
53f4de1
fixed variable name
sunnywu Oct 16, 2024
3624f15
Merge remote-tracking branch 'origin/syw-UID2-4159-token-gen-code-ren…
sunnywu Oct 16, 2024
a38af09
Merge remote-tracking branch 'origin/syw-UID2-4159-token-gen-code-ref…
sunnywu Oct 16, 2024
4c1de75
Moved privacyBits out of FirstLevelHashIdentity and treat it as a sep…
sunnywu Oct 21, 2024
062f908
Added a new IdentityRequest constructor to set default values for pri…
sunnywu Oct 21, 2024
76a1345
Update src/main/java/com/uid2/operator/model/IdentityRequest.java
sunnywu Oct 28, 2024
5db6e4f
Replace privacy bits type to PrivacyBits class instance
sunnywu Oct 28, 2024
741237d
Replace privacy bits type to PrivacyBits class instance
sunnywu Oct 28, 2024
3900017
Replace privacy bits type to PrivacyBits class instance
sunnywu Oct 28, 2024
e5b104d
missing a newline
sunnywu Oct 28, 2024
e25cd19
1. Added PrivacyBitsTest/IdentityResponseTest/RawUidResponseTest classes
sunnywu Oct 28, 2024
986cf2e
Created verifyFirstLevelHashIdentityAndEstablishedAt method for verif…
sunnywu Oct 28, 2024
f445180
Created verifyFirstLevelHashIdentityAndEstablishedAt method for verif…
sunnywu Oct 28, 2024
e4e7d2d
Merge remote-tracking branch 'origin/main' into syw-UID2-4159-token-g…
sunnywu Oct 28, 2024
fa1c0f1
Checking privacy bits in more tests in UIDOperatorVerticleTest
sunnywu Oct 28, 2024
20d695c
[CI Pipeline] Released Snapshot version: 5.41.1-alpha-116-SNAPSHOT
Oct 29, 2024
c950c6d
revered version in pom.xml
sunnywu Oct 30, 2024
a908e1f
added some comments and renamed refreshIdentity method param to input…
sunnywu Oct 30, 2024
04dfc14
fixed unit tests checking establishedAt between advertisingTokenInput…
sunnywu Oct 30, 2024
2edcb05
Refactored unit test codes to standardise the advertisingTokenInput/r…
sunnywu Oct 30, 2024
ca44945
Refactored unit test codes to standardise the advertisingTokenInput/r…
sunnywu Oct 30, 2024
da549b0
Code review feedback
sunnywu Nov 4, 2024
c6586a5
renamed IUIDOperatorService#mapIdentity to mapHashedDiiIdentity
sunnywu Nov 4, 2024
d76bceb
renamed to
sunnywu Nov 4, 2024
23a6f50
Code review feedback and renamed AdvertisingTOkenInput/RefreshTokenIn…
sunnywu Nov 4, 2024
a002ad1
Code review feedback,
sunnywu Dec 5, 2024
ea0b247
Renamed IdentityRequest/IdentityResponse to TokenGenerateRequest/Resp…
sunnywu Dec 9, 2024
4476ee1
- Renamed RawUidResponse to IdentityMapResponseItem, MapRequest to Id…
sunnywu Dec 9, 2024
6bb1fb9
1. Renamed FirstLevelHashIdentity/HashedDiiIdentity/RawUidIdentity to…
sunnywu Dec 9, 2024
a8f0915
1. Renamed IdentityType to DiiType
sunnywu Dec 9, 2024
7875d98
Merge remote-tracking branch 'origin/main' into syw-UID2-4159-token-g…
sunnywu Dec 10, 2024
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
19 changes: 0 additions & 19 deletions src/main/java/com/uid2/operator/model/AdvertisingToken.java

This file was deleted.

28 changes: 28 additions & 0 deletions src/main/java/com/uid2/operator/model/AdvertisingTokenRequest.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
package com.uid2.operator.model;

import java.time.Instant;

import com.uid2.operator.model.identities.RawUid;
import com.uid2.operator.util.PrivacyBits;
import com.uid2.shared.model.TokenVersion;

// class containing enough information to create a new uid token (aka advertising token)
public class AdvertisingTokenRequest extends VersionedTokenRequest {
public final OperatorIdentity operatorIdentity;
public final SourcePublisher sourcePublisher;
public final RawUid rawUid;
public final PrivacyBits privacyBits;
public final Instant establishedAt;

public AdvertisingTokenRequest(TokenVersion version, Instant createdAt, Instant expiresAt, OperatorIdentity operatorIdentity,
SourcePublisher sourcePublisher, RawUid rawUid, PrivacyBits privacyBits,
Instant establishedAt) {
super(version, createdAt, expiresAt);
this.operatorIdentity = operatorIdentity;
this.sourcePublisher = sourcePublisher;
this.rawUid = rawUid;
this.privacyBits = privacyBits;
this.establishedAt = establishedAt;
}
}

Original file line number Diff line number Diff line change
@@ -1,18 +1,19 @@
package com.uid2.operator.model;

import com.uid2.operator.model.identities.HashedDii;

import java.time.Instant;

public final class MapRequest {
public final UserIdentity userIdentity;
public final class IdentityMapRequestItem {
public final HashedDii hashedDii;
public final OptoutCheckPolicy optoutCheckPolicy;
public final Instant asOf;

public MapRequest(
UserIdentity userIdentity,
public IdentityMapRequestItem(
HashedDii hashedDii,
OptoutCheckPolicy optoutCheckPolicy,
Instant asOf)
{
this.userIdentity = userIdentity;
Instant asOf) {
this.hashedDii = hashedDii;
this.optoutCheckPolicy = optoutCheckPolicy;
this.asOf = asOf;
}
Expand Down
19 changes: 19 additions & 0 deletions src/main/java/com/uid2/operator/model/IdentityMapResponseItem.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
package com.uid2.operator.model;

// Contains the computed raw UID and its bucket ID from identity/map request
public class IdentityMapResponseItem {
public static final IdentityMapResponseItem OptoutIdentity = new IdentityMapResponseItem(new byte[33], "");
// The raw UID is also known as Advertising Id (historically)
public final byte[] rawUid;
public final String bucketId;

public IdentityMapResponseItem(byte[] rawUid, String bucketId) {
this.rawUid = rawUid;
this.bucketId = bucketId;
}

// historically Optout is known as Logout
public boolean isOptedOut() {
return this.equals(OptoutIdentity) || this.bucketId == null || this.bucketId.isEmpty();
}
}
21 changes: 0 additions & 21 deletions src/main/java/com/uid2/operator/model/IdentityRequest.java

This file was deleted.

53 changes: 0 additions & 53 deletions src/main/java/com/uid2/operator/model/IdentityTokens.java

This file was deleted.

16 changes: 0 additions & 16 deletions src/main/java/com/uid2/operator/model/MappedIdentity.java

This file was deleted.

13 changes: 0 additions & 13 deletions src/main/java/com/uid2/operator/model/PublisherIdentity.java

This file was deleted.

79 changes: 0 additions & 79 deletions src/main/java/com/uid2/operator/model/RefreshResponse.java

This file was deleted.

18 changes: 0 additions & 18 deletions src/main/java/com/uid2/operator/model/RefreshToken.java

This file was deleted.

24 changes: 24 additions & 0 deletions src/main/java/com/uid2/operator/model/SourcePublisher.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
package com.uid2.operator.model;

// The original publisher that requests to generate a UID token
public class SourcePublisher {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I am wondering why some file renames don't show up as such in the changes ? such as RefreshToken to RefreshTokenInput.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

no idea :)

public final int siteId;

// these 2 values are added into adverting/UID token and refresh token payload but
// are not really used for any real purposes currently so sometimes are set to 0
// see the constructor below
public final int clientKeyId;
public final long publisherId;

public SourcePublisher(int siteId, int clientKeyId, long publisherId) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

is always constructed as SourcePublisher(siteId, 0, 0) perhaps make another constructor with default arguments ?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

great suggestion - done

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That's because it is a half- (well, 5%) baked feature. There is nothing special about values 0. Maybe worth putting some comment about this.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

i have added this comment in the class:

// these 2 values are added into adverting/UID token and refresh token payload but
// are not really used for any real purposes currently so sometimes are set to 0
// see the constructor below

this.siteId = siteId;
this.clientKeyId = clientKeyId;
this.publisherId = publisherId;
}

public SourcePublisher(int siteId) {
this.siteId = siteId;
this.clientKeyId = 0;
this.publisherId = 0;
}
}
40 changes: 40 additions & 0 deletions src/main/java/com/uid2/operator/model/TokenGenerateRequest.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
package com.uid2.operator.model;

import com.uid2.operator.model.identities.HashedDii;
import com.uid2.operator.util.PrivacyBits;

import java.time.Instant;

public final class TokenGenerateRequest {
public final SourcePublisher sourcePublisher;
public final HashedDii hashedDii;
public final OptoutCheckPolicy optoutCheckPolicy;

public final PrivacyBits privacyBits;
public final Instant establishedAt;

public TokenGenerateRequest(
SourcePublisher sourcePublisher,
HashedDii hashedDii,
OptoutCheckPolicy tokenGeneratePolicy,
PrivacyBits privacyBits,
Instant establishedAt) {
this.sourcePublisher = sourcePublisher;
this.hashedDii = hashedDii;
this.optoutCheckPolicy = tokenGeneratePolicy;
this.privacyBits = privacyBits;
this.establishedAt = establishedAt;
}

public TokenGenerateRequest(
SourcePublisher sourcePublisher,
HashedDii hashedDii,
OptoutCheckPolicy tokenGeneratePolicy) {
this(sourcePublisher, hashedDii, tokenGeneratePolicy, PrivacyBits.DEFAULT, Instant.now());

}

public boolean shouldCheckOptOut() {
return optoutCheckPolicy.equals(OptoutCheckPolicy.RespectOptOut);
}
}
Loading
Loading