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

Updated TCF restriction processing #1205

Merged
merged 2 commits into from
Apr 1, 2021
Merged
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
Original file line number Diff line number Diff line change
Expand Up @@ -94,8 +94,10 @@ private RestrictionType restrictionType(VendorPermissionWithGvl vendorPermission
/**
* Purpose is flexible when {@link VendorV2} flexiblePurposes contains it.
* When it is not flexible:
* We check purposeConsent and vendorConsent when it is contained in GVL purposes;
* We check purposesLITransparency and vendorLegitimateInterest when it is contained in GVL LegIntPurposes.
* <li>When it is contained in GVL purposes we reject REQUIRE_LEGITIMATE_INTEREST {@link RestrictionType}
* and check purposeConsent and vendorConsent;</li>
* <li>When it is contained in GVL LegIntPurposes we reject REQUIRE_CONSENT {@link RestrictionType}
* and check purposesLITransparency and vendorLegitimateInterest.</li>
* <p><br>
* If it is flexible we check by {@link RestrictionType}:
* <li>For REQUIRE_CONSENT we check by purposeConsent and vendorConsent</li>
Expand Down Expand Up @@ -123,25 +125,48 @@ private boolean isAllowedByPublisherRestrictionAndFlexible(Purpose purpose,
final EnumSet<Purpose> gvlPurposes = vendorGvl.getPurposes();
if (gvlPurposes != null && gvlPurposes.contains(purpose)) {
return isFlexible
? isAllowedByRestrictionTypePurpose(purpose, vendorId, isEnforceVendor, tcString, restrictionType)
: isAllowedBySimpleConsent(purpose, vendorId, isEnforceVendor, tcString);
? isAllowedByFlexible(purpose, vendorId, isEnforceVendor, tcString, restrictionType)
: isAllowedByNotFlexiblePurpose(purpose, vendorId, isEnforceVendor, tcString, restrictionType);
}

final EnumSet<Purpose> legIntGvlPurposes = vendorGvl.getLegIntPurposes();
if (legIntGvlPurposes != null && legIntGvlPurposes.contains(purpose)) {
return isFlexible
? isAllowedByRestrictionTypePurpose(purpose, vendorId, isEnforceVendor, tcString, restrictionType)
: isAllowedByLegitimateInterest(purpose, vendorId, isEnforceVendor, tcString);
? isAllowedByFlexible(purpose, vendorId, isEnforceVendor, tcString, restrictionType)
: isAllowedByNotFlexibleLegitimateInterest(purpose, vendorId, isEnforceVendor, tcString,
restrictionType);
}

return false;
}

private boolean isAllowedByRestrictionTypePurpose(Purpose purpose,
Integer vendorId,
boolean isEnforceVendor,
TCString tcString,
RestrictionType restrictionType) {
private boolean isAllowedByNotFlexiblePurpose(Purpose purpose,
Integer vendorId,
boolean isEnforceVendor,
TCString tcString,
RestrictionType restrictionType) {
final boolean isSupportedRestriction = restrictionType.equals(RestrictionType.REQUIRE_CONSENT)
|| restrictionType.equals(RestrictionType.UNDEFINED);

return isSupportedRestriction && isAllowedBySimpleConsent(purpose, vendorId, isEnforceVendor, tcString);
}

private boolean isAllowedByNotFlexibleLegitimateInterest(Purpose purpose,
Integer vendorId,
boolean isEnforceVendor,
TCString tcString,
RestrictionType restrictionType) {
final boolean isSupportedRestriction = restrictionType.equals(RestrictionType.REQUIRE_LEGITIMATE_INTEREST)
|| restrictionType.equals(RestrictionType.UNDEFINED);

return isSupportedRestriction && isAllowedByLegitimateInterest(purpose, vendorId, isEnforceVendor, tcString);
}

private boolean isAllowedByFlexible(Purpose purpose,
Integer vendorId,
boolean isEnforceVendor,
TCString tcString,
RestrictionType restrictionType) {

switch (restrictionType) {
case REQUIRE_CONSENT:
Expand Down
Loading