Skip to content

Commit 4ada1ae

Browse files
authored
UsGen: Add option to disable PersonalConsents check (#3798)
1 parent 65fd3e1 commit 4ada1ae

18 files changed

Lines changed: 779 additions & 136 deletions

File tree

src/main/java/org/prebid/server/activity/infrastructure/creator/privacy/usnat/USNatModuleCreator.java

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,11 @@ public PrivacyModule from(PrivacyModuleCreationContext creationContext) {
4343

4444
final List<PrivacyModule> innerPrivacyModules = SetUtils.emptyIfNull(scope.getSectionsIds()).stream()
4545
.filter(sectionId -> !shouldSkip(sectionId, moduleConfig))
46-
.map(sectionId -> forSection(creationContext.getActivity(), sectionId, scope.getGppModel()))
46+
.map(sectionId -> forSection(
47+
creationContext.getActivity(),
48+
sectionId,
49+
scope.getGppModel(),
50+
moduleConfig.getConfig()))
4751
.toList();
4852

4953
return new AndPrivacyModules(innerPrivacyModules);
@@ -61,7 +65,11 @@ private static boolean shouldSkip(Integer sectionId, AccountUSNatModuleConfig mo
6165
|| (skipSectionIds != null && skipSectionIds.contains(sectionId));
6266
}
6367

64-
private PrivacyModule forSection(Activity activity, Integer sectionId, GppModel gppModel) {
65-
return new USNatModule(activity, gppReaderFactory.forSection(sectionId, gppModel));
68+
private PrivacyModule forSection(Activity activity,
69+
Integer sectionId,
70+
GppModel gppModel,
71+
AccountUSNatModuleConfig.Config config) {
72+
73+
return new USNatModule(activity, gppReaderFactory.forSection(sectionId, gppModel), config);
6674
}
6775
}

src/main/java/org/prebid/server/activity/infrastructure/privacy/usnat/USNatModule.java

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -11,25 +11,29 @@
1111
import org.prebid.server.activity.infrastructure.privacy.usnat.inner.USNatSyncUser;
1212
import org.prebid.server.activity.infrastructure.privacy.usnat.inner.USNatTransmitGeo;
1313
import org.prebid.server.activity.infrastructure.privacy.usnat.inner.USNatTransmitUfpd;
14+
import org.prebid.server.settings.model.activity.privacy.AccountUSNatModuleConfig;
1415

1516
import java.util.Objects;
1617

1718
public class USNatModule implements PrivacyModule, Loggable {
1819

1920
private final PrivacyModule innerModule;
2021

21-
public USNatModule(Activity activity, USNatGppReader gppReader) {
22+
public USNatModule(Activity activity, USNatGppReader gppReader, AccountUSNatModuleConfig.Config config) {
2223
Objects.requireNonNull(activity);
2324
Objects.requireNonNull(gppReader);
2425

25-
innerModule = innerModule(activity, gppReader);
26+
innerModule = innerModule(activity, gppReader, config);
2627
}
2728

28-
private static PrivacyModule innerModule(Activity activity, USNatGppReader gppReader) {
29+
private static PrivacyModule innerModule(Activity activity,
30+
USNatGppReader gppReader,
31+
AccountUSNatModuleConfig.Config config) {
32+
2933
return switch (activity) {
30-
case SYNC_USER, MODIFY_UFDP -> new USNatSyncUser(gppReader);
31-
case TRANSMIT_UFPD, TRANSMIT_EIDS -> new USNatTransmitUfpd(gppReader);
32-
case TRANSMIT_GEO -> new USNatTransmitGeo(gppReader);
34+
case SYNC_USER, MODIFY_UFDP -> new USNatSyncUser(gppReader, config);
35+
case TRANSMIT_UFPD, TRANSMIT_EIDS -> new USNatTransmitUfpd(gppReader, config);
36+
case TRANSMIT_GEO -> new USNatTransmitGeo(gppReader, config);
3337
case CALL_BIDDER, TRANSMIT_TID, REPORT_ANALYTICS -> USNatDefault.instance();
3438
};
3539
}

src/main/java/org/prebid/server/activity/infrastructure/privacy/usnat/inner/USNatSyncUser.java

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@
1919
import org.prebid.server.activity.infrastructure.privacy.usnat.inner.model.TargetedAdvertisingOptOut;
2020
import org.prebid.server.activity.infrastructure.privacy.usnat.inner.model.TargetedAdvertisingOptOutNotice;
2121
import org.prebid.server.activity.infrastructure.privacy.usnat.inner.model.USNatField;
22+
import org.prebid.server.settings.model.activity.privacy.AccountUSNatModuleConfig;
2223

2324
import java.util.List;
2425
import java.util.Objects;
@@ -28,25 +29,25 @@ public class USNatSyncUser implements PrivacyModule, Loggable {
2829
private final USNatGppReader gppReader;
2930
private final Result result;
3031

31-
public USNatSyncUser(USNatGppReader gppReader) {
32+
public USNatSyncUser(USNatGppReader gppReader, AccountUSNatModuleConfig.Config config) {
3233
this.gppReader = gppReader;
3334

34-
result = disallow(gppReader) ? Result.DISALLOW : Result.ALLOW;
35+
result = disallow(gppReader, config) ? Result.DISALLOW : Result.ALLOW;
3536
}
3637

3738
@Override
3839
public Result proceed(ActivityInvocationPayload activityInvocationPayload) {
3940
return result;
4041
}
4142

42-
public static boolean disallow(USNatGppReader gppReader) {
43+
public static boolean disallow(USNatGppReader gppReader, AccountUSNatModuleConfig.Config config) {
4344
return equals(gppReader.getMspaServiceProviderMode(), MspaServiceProviderMode.YES)
4445
|| equals(gppReader.getGpc(), Gpc.TRUE)
4546
|| checkSale(gppReader)
4647
|| checkSharing(gppReader)
4748
|| checkTargetedAdvertising(gppReader)
4849
|| checkKnownChildSensitiveDataConsents(gppReader)
49-
|| equals(gppReader.getPersonalDataConsents(), PersonalDataConsents.CONSENT);
50+
|| checkPersonalDataConsents(gppReader, config);
5051
}
5152

5253
private static boolean checkSale(USNatGppReader gppReader) {
@@ -91,6 +92,11 @@ private static boolean checkKnownChildSensitiveDataConsents(USNatGppReader gppRe
9192
|| equalsAtIndex(KnownChildSensitiveDataConsent.CONSENT, knownChildSensitiveDataConsents, 1);
9293
}
9394

95+
private static boolean checkPersonalDataConsents(USNatGppReader gppReader, AccountUSNatModuleConfig.Config config) {
96+
return (config == null || !config.isAllowPersonalDataConsent2())
97+
&& equals(gppReader.getPersonalDataConsents(), PersonalDataConsents.CONSENT);
98+
}
99+
94100
private static <T> boolean equalsAtIndex(USNatField<T> expectedValue, List<T> list, int index) {
95101
return list != null && list.size() > index && equals(list.get(index), expectedValue);
96102
}

src/main/java/org/prebid/server/activity/infrastructure/privacy/usnat/inner/USNatTransmitGeo.java

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
import org.prebid.server.activity.infrastructure.privacy.usnat.inner.model.SensitiveDataProcessing;
1616
import org.prebid.server.activity.infrastructure.privacy.usnat.inner.model.SensitiveDataProcessingOptOutNotice;
1717
import org.prebid.server.activity.infrastructure.privacy.usnat.inner.model.USNatField;
18+
import org.prebid.server.settings.model.activity.privacy.AccountUSNatModuleConfig;
1819

1920
import java.util.List;
2021
import java.util.Objects;
@@ -24,23 +25,23 @@ public class USNatTransmitGeo implements PrivacyModule, Loggable {
2425
private final USNatGppReader gppReader;
2526
private final Result result;
2627

27-
public USNatTransmitGeo(USNatGppReader gppReader) {
28+
public USNatTransmitGeo(USNatGppReader gppReader, AccountUSNatModuleConfig.Config config) {
2829
this.gppReader = gppReader;
2930

30-
result = disallow(gppReader) ? Result.DISALLOW : Result.ALLOW;
31+
result = disallow(gppReader, config) ? Result.DISALLOW : Result.ALLOW;
3132
}
3233

3334
@Override
3435
public Result proceed(ActivityInvocationPayload activityInvocationPayload) {
3536
return result;
3637
}
3738

38-
public static boolean disallow(USNatGppReader gppReader) {
39+
public static boolean disallow(USNatGppReader gppReader, AccountUSNatModuleConfig.Config config) {
3940
return equals(gppReader.getMspaServiceProviderMode(), MspaServiceProviderMode.YES)
4041
|| equals(gppReader.getGpc(), Gpc.TRUE)
4142
|| checkSensitiveData(gppReader)
4243
|| checkKnownChildSensitiveDataConsents(gppReader)
43-
|| equals(gppReader.getPersonalDataConsents(), PersonalDataConsents.CONSENT);
44+
|| checkPersonalDataConsents(gppReader, config);
4445
}
4546

4647
private static boolean checkSensitiveData(USNatGppReader gppReader) {
@@ -64,6 +65,11 @@ private static boolean checkKnownChildSensitiveDataConsents(USNatGppReader gppRe
6465
|| equalsAtIndex(KnownChildSensitiveDataConsent.CONSENT, knownChildSensitiveDataConsents, 1);
6566
}
6667

68+
private static boolean checkPersonalDataConsents(USNatGppReader gppReader, AccountUSNatModuleConfig.Config config) {
69+
return (config == null || !config.isAllowPersonalDataConsent2())
70+
&& equals(gppReader.getPersonalDataConsents(), PersonalDataConsents.CONSENT);
71+
}
72+
6773
private static <T> boolean equalsAtIndex(USNatField<T> expectedValue, List<T> list, int index) {
6874
return list != null && list.size() > index && equals(list.get(index), expectedValue);
6975
}

src/main/java/org/prebid/server/activity/infrastructure/privacy/usnat/inner/USNatTransmitUfpd.java

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@
2222
import org.prebid.server.activity.infrastructure.privacy.usnat.inner.model.TargetedAdvertisingOptOut;
2323
import org.prebid.server.activity.infrastructure.privacy.usnat.inner.model.TargetedAdvertisingOptOutNotice;
2424
import org.prebid.server.activity.infrastructure.privacy.usnat.inner.model.USNatField;
25+
import org.prebid.server.settings.model.activity.privacy.AccountUSNatModuleConfig;
2526

2627
import java.util.List;
2728
import java.util.Objects;
@@ -36,26 +37,26 @@ public class USNatTransmitUfpd implements PrivacyModule, Loggable {
3637
private final USNatGppReader gppReader;
3738
private final Result result;
3839

39-
public USNatTransmitUfpd(USNatGppReader gppReader) {
40+
public USNatTransmitUfpd(USNatGppReader gppReader, AccountUSNatModuleConfig.Config config) {
4041
this.gppReader = gppReader;
4142

42-
result = disallow(gppReader) ? Result.DISALLOW : Result.ALLOW;
43+
result = disallow(gppReader, config) ? Result.DISALLOW : Result.ALLOW;
4344
}
4445

4546
@Override
4647
public Result proceed(ActivityInvocationPayload activityInvocationPayload) {
4748
return result;
4849
}
4950

50-
public static boolean disallow(USNatGppReader gppReader) {
51+
public static boolean disallow(USNatGppReader gppReader, AccountUSNatModuleConfig.Config config) {
5152
return equals(gppReader.getMspaServiceProviderMode(), MspaServiceProviderMode.YES)
5253
|| equals(gppReader.getGpc(), Gpc.TRUE)
5354
|| checkSale(gppReader)
5455
|| checkSharing(gppReader)
5556
|| checkTargetedAdvertising(gppReader)
5657
|| checkSensitiveData(gppReader)
5758
|| checkKnownChildSensitiveDataConsents(gppReader)
58-
|| equals(gppReader.getPersonalDataConsents(), PersonalDataConsents.CONSENT);
59+
|| checkPersonalDataConsents(gppReader, config);
5960
}
6061

6162
private static boolean checkSale(USNatGppReader gppReader) {
@@ -127,6 +128,11 @@ private static boolean checkKnownChildSensitiveDataConsents(USNatGppReader gppRe
127128
|| equalsAtIndex(KnownChildSensitiveDataConsent.CONSENT, knownChildSensitiveDataConsents, 1);
128129
}
129130

131+
private static boolean checkPersonalDataConsents(USNatGppReader gppReader, AccountUSNatModuleConfig.Config config) {
132+
return (config == null || !config.isAllowPersonalDataConsent2())
133+
&& equals(gppReader.getPersonalDataConsents(), PersonalDataConsents.CONSENT);
134+
}
135+
130136
private static <T> boolean anyEqualsAtIndices(USNatField<T> expectedValue, List<T> list, Set<Integer> indices) {
131137
return indices.stream().anyMatch(index -> equalsAtIndex(expectedValue, list, index));
132138
}

src/main/java/org/prebid/server/settings/model/activity/privacy/AccountUSNatModuleConfig.java

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,5 +29,9 @@ public static class Config {
2929
@JsonProperty("skip_sids")
3030
@JsonAlias({"skipSids", "skip-sids"})
3131
List<Integer> skipSids;
32+
33+
@JsonProperty("allow_personal_data_consent_2")
34+
@JsonAlias({"allowPersonalDataConsent2", "allow-personal-data-consent-2"})
35+
boolean allowPersonalDataConsent2;
3236
}
3337
}

src/test/groovy/org/prebid/server/functional/model/config/GppModuleConfig.groovy

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,11 @@ class GppModuleConfig {
2323
List<GppSectionId> skipSidsSnakeCase
2424
@JsonProperty("skip-sids")
2525
List<GppSectionId> skipSidsKebabCase
26+
Boolean allowPersonalDataConsent2
27+
@JsonProperty("allow_personal_data_consent_2")
28+
Boolean allowPersonalDataConsent2SnakeCase
29+
@JsonProperty("allow-personal-data-consent-2")
30+
Boolean allowPersonalDataConsent2KebabCase
2631

2732
static GppModuleConfig getDefaultModuleConfig(ActivityConfig activityConfig = ActivityConfig.configWithDefaultRestrictRules,
2833
List<GppSectionId> sids = [GppSectionId.US_NAT_V1],
@@ -35,8 +40,8 @@ class GppModuleConfig {
3540
}
3641

3742
static GppModuleConfig getDefaultModuleConfigSnakeCase(ActivityConfig activityConfig = ActivityConfig.configWithDefaultRestrictRules,
38-
List<GppSectionId> sids = [GppSectionId.US_NAT_V1],
39-
Boolean normalizeFlags = true) {
43+
List<GppSectionId> sids = [GppSectionId.US_NAT_V1],
44+
Boolean normalizeFlags = true) {
4045
new GppModuleConfig().tap {
4146
it.activityConfigSnakeCase = [activityConfig]
4247
it.sids = sids

src/test/groovy/org/prebid/server/functional/tests/privacy/GppFetchBidActivitiesSpec.groovy

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -604,10 +604,7 @@ class GppFetchBidActivitiesSpec extends PrivacyBaseSpec {
604604
}
605605

606606
and: "Activities set for fetchBid with rejecting privacy regulation"
607-
def rule = new ActivityRule().tap {
608-
it.privacyRegulation = [privacyAllowRegulations]
609-
}
610-
607+
def rule = new ActivityRule(privacyRegulation: [privacyAllowRegulations])
611608
def activities = AllowActivities.getDefaultAllowActivities(FETCH_BIDS, Activity.getDefaultActivity([rule]))
612609

613610
and: "Account gpp configuration"
@@ -1312,9 +1309,7 @@ class GppFetchBidActivitiesSpec extends PrivacyBaseSpec {
13121309
}
13131310

13141311
and: "Activities set for fetchBid with allowing privacy regulation"
1315-
def rule = new ActivityRule().tap {
1316-
it.privacyRegulation = [privacyAllowRegulations]
1317-
}
1312+
def rule = new ActivityRule(privacyRegulation: [privacyAllowRegulations])
13181313

13191314
def activities = AllowActivities.getDefaultAllowActivities(FETCH_BIDS, Activity.getDefaultActivity([rule]))
13201315

0 commit comments

Comments
 (0)