2222import java .util .*;
2323
2424import static com .uid2 .operator .IdentityConst .*;
25- import static com .uid2 .operator .service .TokenUtils .getSiteIdsUsingV4Tokens ;
2625
2726public class UIDOperatorService implements IUIDOperatorService {
2827 public static final String IDENTITY_TOKEN_EXPIRES_AFTER_SECONDS = "identity_token_expires_after_seconds" ;
@@ -49,7 +48,6 @@ public class UIDOperatorService implements IUIDOperatorService {
4948 private final OperatorIdentity operatorIdentity ;
5049 protected final TokenVersion tokenVersionToUseIfNotV4 ;
5150 protected final int advertisingTokenV4Percentage ;
52- protected final Set <Integer > siteIdsUsingV4Tokens ;
5351 private final TokenVersion refreshTokenVersion ;
5452 private final boolean identityV3Enabled ;
5553
@@ -94,7 +92,6 @@ public UIDOperatorService(JsonObject config, IOptOutStore optOutStore, ISaltProv
9492 }
9593
9694 this .advertisingTokenV4Percentage = config .getInteger ("advertising_token_v4_percentage" , 0 ); //0 indicates token v4 will not be used
97- this .siteIdsUsingV4Tokens = getSiteIdsUsingV4Tokens (config .getString ("site_ids_using_v4_tokens" , "" ));
9895 this .tokenVersionToUseIfNotV4 = config .getBoolean ("advertising_token_v3" , false ) ? TokenVersion .V3 : TokenVersion .V2 ;
9996
10097 this .refreshTokenVersion = TokenVersion .V3 ;
@@ -271,18 +268,14 @@ private RefreshToken createRefreshToken(PublisherIdentity publisherIdentity, Use
271268
272269 private AdvertisingToken createAdvertisingToken (PublisherIdentity publisherIdentity , UserIdentity userIdentity , Instant now ) {
273270 TokenVersion tokenVersion ;
274- if (siteIdsUsingV4Tokens .contains (publisherIdentity .siteId )) {
275- tokenVersion = TokenVersion .V4 ;
276- } else {
277- int pseudoRandomNumber = 1 ;
278- final var rawUid = userIdentity .id ;
279- if (rawUid .length > 2 )
280- {
281- int hash = ((rawUid [0 ] & 0xFF ) << 12 ) | ((rawUid [1 ] & 0xFF ) << 4 ) | ((rawUid [2 ] & 0xFF ) & 0xF ); //using same logic as ModBasedSaltEntryIndexer.getIndex() in uid2-shared
282- pseudoRandomNumber = (hash % 100 ) + 1 ; //1 to 100
283- }
284- tokenVersion = (pseudoRandomNumber <= this .advertisingTokenV4Percentage ) ? TokenVersion .V4 : this .tokenVersionToUseIfNotV4 ;
271+ int pseudoRandomNumber = 1 ;
272+ final var rawUid = userIdentity .id ;
273+ if (rawUid .length > 2 )
274+ {
275+ int hash = ((rawUid [0 ] & 0xFF ) << 12 ) | ((rawUid [1 ] & 0xFF ) << 4 ) | ((rawUid [2 ] & 0xFF ) & 0xF ); //using same logic as ModBasedSaltEntryIndexer.getIndex() in uid2-shared
276+ pseudoRandomNumber = (hash % 100 ) + 1 ; //1 to 100
285277 }
278+ tokenVersion = (pseudoRandomNumber <= this .advertisingTokenV4Percentage ) ? TokenVersion .V4 : this .tokenVersionToUseIfNotV4 ;
286279 return new AdvertisingToken (tokenVersion , now , now .plusMillis (identityExpiresAfter .toMillis ()), this .operatorIdentity , publisherIdentity , userIdentity );
287280 }
288281
0 commit comments