Skip to content

Commit a908e1f

Browse files
committed
added some comments and renamed refreshIdentity method param to input instead of oken
1 parent c950c6d commit a908e1f

File tree

5 files changed

+16
-11
lines changed

5 files changed

+16
-11
lines changed

src/main/java/com/uid2/operator/model/IdentityResponse.java

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,9 +9,12 @@
99
// jsonified
1010
public class IdentityResponse {
1111
public static IdentityResponse OptOutIdentityResponse = new IdentityResponse("", null, "", Instant.EPOCH, Instant.EPOCH, Instant.EPOCH);
12+
13+
//aka UID token
1214
private final String advertisingToken;
1315
private final TokenVersion advertisingTokenVersion;
1416
private final String refreshToken;
17+
// when the advertising token/uid token expires
1518
private final Instant identityExpires;
1619
private final Instant refreshExpires;
1720
private final Instant refreshFrom;

src/main/java/com/uid2/operator/model/userIdentity/FirstLevelHashIdentity.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ public FirstLevelHashIdentity(IdentityScope identityScope, IdentityType identity
2121
this.establishedAt = establishedAt;
2222
}
2323

24+
// explicitly not checking establishedAt - this is only for making sure the first level hash matches a new input
2425
public boolean matches(FirstLevelHashIdentity that) {
2526
return this.identityScope.equals(that.identityScope) &&
2627
this.identityType.equals(that.identityType) &&

src/main/java/com/uid2/operator/service/EncryptedTokenEncoder.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,7 @@ private byte[] encodeIntoAdvertisingTokenV3(AdvertisingTokenInput t, KeysetKey m
5757
sitePayload.appendInt(t.privacyBits.getAsInt());
5858
sitePayload.appendLong(t.establishedAt.toEpochMilli());
5959
// this is the refreshedAt field in the spec - but effectively it is the time this advertising token is generated
60+
// this is a redundant field as it is stored in master payload again, can consider dropping this field in future token version
6061
sitePayload.appendLong(t.createdAt.toEpochMilli());
6162
sitePayload.appendBytes(t.rawUidIdentity.rawUid); // 32 or 33 bytes
6263

src/main/java/com/uid2/operator/service/IUIDOperatorService.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ public interface IUIDOperatorService {
1414

1515
IdentityResponse generateIdentity(IdentityRequest request);
1616

17-
RefreshResponse refreshIdentity(RefreshTokenInput refreshTokenInput);
17+
RefreshResponse refreshIdentity(RefreshTokenInput input);
1818

1919
RawUidResponse mapIdentity(MapRequest request);
2020

src/main/java/com/uid2/operator/service/UIDOperatorService.java

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -120,34 +120,34 @@ public IdentityResponse generateIdentity(IdentityRequest request) {
120120
}
121121

122122
@Override
123-
public RefreshResponse refreshIdentity(RefreshTokenInput token) {
123+
public RefreshResponse refreshIdentity(RefreshTokenInput input) {
124124
// should not be possible as different scopes should be using different keys, but just in case
125-
if (token.firstLevelHashIdentity.identityScope != this.identityScope) {
125+
if (input.firstLevelHashIdentity.identityScope != this.identityScope) {
126126
return RefreshResponse.Invalid;
127127
}
128128

129-
if (token.firstLevelHashIdentity.establishedAt.isBefore(RefreshCutoff)) {
129+
if (input.firstLevelHashIdentity.establishedAt.isBefore(RefreshCutoff)) {
130130
return RefreshResponse.Deprecated;
131131
}
132132

133133
final Instant now = clock.instant();
134134

135-
if (token.expiresAt.isBefore(now)) {
135+
if (input.expiresAt.isBefore(now)) {
136136
return RefreshResponse.Expired;
137137
}
138138

139-
final boolean isCstg = token.privacyBits.isClientSideTokenGenerated();
139+
final boolean isCstg = input.privacyBits.isClientSideTokenGenerated();
140140

141141
try {
142-
final GlobalOptoutResult logoutEntry = getGlobalOptOutResult(token.firstLevelHashIdentity, true);
142+
final GlobalOptoutResult logoutEntry = getGlobalOptOutResult(input.firstLevelHashIdentity, true);
143143
final boolean optedOut = logoutEntry.isOptedOut();
144144

145-
final Duration durationSinceLastRefresh = Duration.between(token.createdAt, now);
145+
final Duration durationSinceLastRefresh = Duration.between(input.createdAt, now);
146146

147147
if (!optedOut) {
148-
IdentityResponse identityResponse = this.generateIdentity(token.sourcePublisher,
149-
token.firstLevelHashIdentity,
150-
token.privacyBits);
148+
IdentityResponse identityResponse = this.generateIdentity(input.sourcePublisher,
149+
input.firstLevelHashIdentity,
150+
input.privacyBits);
151151

152152
return RefreshResponse.createRefreshedResponse(identityResponse, durationSinceLastRefresh, isCstg);
153153
} else {

0 commit comments

Comments
 (0)