Skip to content
Open
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
52 changes: 52 additions & 0 deletions iabgpp-encoder/src/main/java/com/iab/gpp/encoder/GppModel.java
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,18 @@ public void setFieldValue(String sectionName, String fieldName, Object value) {
} else if (sectionName.equals(UsMn.NAME)) {
section = new UsMn();
this.sections.put(UsMn.NAME, section);
} else if (sectionName.equals(UsMd.NAME)) {
section = new UsMd();
this.sections.put(UsMd.NAME, section);
} else if (sectionName.equals(UsIn.NAME)) {
section = new UsIn();
this.sections.put(UsIn.NAME, section);
} else if (sectionName.equals(UsKy.NAME)) {
section = new UsKy();
this.sections.put(UsKy.NAME, section);
} else if (sectionName.equals(UsRi.NAME)) {
section = new UsRi();
this.sections.put(UsRi.NAME, section);
}
} else {
section = this.sections.get(sectionName);
Expand Down Expand Up @@ -302,6 +314,22 @@ public UsMn getUsMnSection() {
return (UsMn) getSection(UsMn.NAME);
}

public UsMd getUsMdSection() {
return (UsMd) getSection(UsMd.NAME);
}

public UsIn getUsInSection() {
return (UsIn) getSection(UsIn.NAME);
}

public UsKy getUsKySection() {
return (UsKy) getSection(UsKy.NAME);
}

public UsRi getUsRiSection() {
return (UsRi) getSection(UsRi.NAME);
}

public List<Integer> getSectionIds() {
if (!this.decoded) {
this.sections = this.decodeModel(this.encodedString);
Expand Down Expand Up @@ -416,6 +444,18 @@ protected Map<String, EncodableSection> decodeModel(String str) {
} else if (sectionIds.get(i).equals(UsMn.ID)) {
UsMn section = new UsMn(encodedSections[i + 1]);
sections.put(UsMn.NAME, section);
} else if (sectionIds.get(i).equals(UsMd.ID)) {
UsMd section = new UsMd(encodedSections[i + 1]);
sections.put(UsMd.NAME, section);
} else if (sectionIds.get(i).equals(UsIn.ID)) {
UsIn section = new UsIn(encodedSections[i + 1]);
sections.put(UsIn.NAME, section);
} else if (sectionIds.get(i).equals(UsKy.ID)) {
UsKy section = new UsKy(encodedSections[i + 1]);
sections.put(UsKy.NAME, section);
} else if (sectionIds.get(i).equals(UsRi.ID)) {
UsRi section = new UsRi(encodedSections[i + 1]);
sections.put(UsRi.NAME, section);
}
}
}
Expand Down Expand Up @@ -529,6 +569,18 @@ public void decodeSection(String sectionName, String encodedString) {
}else if (sectionName.equals(UsMn.NAME)) {
section = new UsMn();
this.sections.put(UsMn.NAME, section);
}else if (sectionName.equals(UsMd.NAME)) {
section = new UsMd();
this.sections.put(UsMd.NAME, section);
}else if (sectionName.equals(UsIn.NAME)) {
section = new UsIn();
this.sections.put(UsIn.NAME, section);
}else if (sectionName.equals(UsKy.NAME)) {
section = new UsKy();
this.sections.put(UsKy.NAME, section);
}else if (sectionName.equals(UsRi.NAME)) {
section = new UsRi();
this.sections.put(UsRi.NAME, section);
}
} else {
section = this.sections.get(sectionName);
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
package com.iab.gpp.encoder.field;

import java.util.Arrays;
import java.util.List;

public class UsInField {

public static String MSPA_VERSION = "MspaVersion";
public static String MSPA_COVERED_TRANSACTION = "MspaCoveredTransaction";
public static String MSPA_MODE = "MspaMode";
public static String PROCESSING_NOTICE = "ProcessingNotice";
public static String SALE_OPT_OUT_NOTICE = "SaleOptOutNotice";
public static String TARGETED_ADVERTISING_OPT_OUT_NOTICE = "TargetedAdvertisingOptOutNotice";
public static String SALE_OPT_OUT = "SaleOptOut";
public static String TARGETED_ADVERTISING_OPT_OUT = "TargetedAdvertisingOptOut";
public static String KNOWN_CHILD_SENSITIVE_DATA_CONSENTS = "KnownChildSensitiveDataConsents";
public static String ADDITIONAL_DATA_PROCESSING_CONSENT = "AdditionalDataProcessingConsent";
public static String SENSITIVE_DATA_PROCESSING = "SensitiveDataProcessing";

public static String SENSITIVE_DATA_CONSENT_SEGMENT_INCLUDED = "SensitiveDataConsentSegmentIncluded";

//@formatter:off
public static List<String> USIN_CORE_SEGMENT_FIELD_NAMES = Arrays.asList(new String[] {
UsInField.MSPA_VERSION,
UsInField.MSPA_COVERED_TRANSACTION,
UsInField.MSPA_MODE,
UsInField.PROCESSING_NOTICE,
UsInField.SALE_OPT_OUT_NOTICE,
UsInField.TARGETED_ADVERTISING_OPT_OUT_NOTICE,
UsInField.SALE_OPT_OUT,
UsInField.TARGETED_ADVERTISING_OPT_OUT,
UsInField.KNOWN_CHILD_SENSITIVE_DATA_CONSENTS,
UsInField.ADDITIONAL_DATA_PROCESSING_CONSENT
});
//@formatter:on

//@formatter:off
public static List<String> USIN_SENSITIVE_DATA_CONSENT_SEGMENT_FIELD_NAMES = Arrays.asList(new String[] {
UsInField.SENSITIVE_DATA_PROCESSING
});
//@formatter:on
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
package com.iab.gpp.encoder.field;

import java.util.Arrays;
import java.util.List;

public class UsKyField {

public static String MSPA_VERSION = "MspaVersion";
public static String MSPA_COVERED_TRANSACTION = "MspaCoveredTransaction";
public static String MSPA_MODE = "MspaMode";
public static String PROCESSING_NOTICE = "ProcessingNotice";
public static String SALE_OPT_OUT_NOTICE = "SaleOptOutNotice";
public static String TARGETED_ADVERTISING_OPT_OUT_NOTICE = "TargetedAdvertisingOptOutNotice";
public static String SALE_OPT_OUT = "SaleOptOut";
public static String TARGETED_ADVERTISING_OPT_OUT = "TargetedAdvertisingOptOut";
public static String KNOWN_CHILD_SENSITIVE_DATA_CONSENTS = "KnownChildSensitiveDataConsents";
public static String ADDITIONAL_DATA_PROCESSING_CONSENT = "AdditionalDataProcessingConsent";
public static String SENSITIVE_DATA_PROCESSING = "SensitiveDataProcessing";

public static String SENSITIVE_DATA_CONSENT_SEGMENT_INCLUDED = "SensitiveDataConsentSegmentIncluded";

//@formatter:off
public static List<String> USKY_CORE_SEGMENT_FIELD_NAMES = Arrays.asList(new String[] {
UsKyField.MSPA_VERSION,
UsKyField.MSPA_COVERED_TRANSACTION,
UsKyField.MSPA_MODE,
UsKyField.PROCESSING_NOTICE,
UsKyField.SALE_OPT_OUT_NOTICE,
UsKyField.TARGETED_ADVERTISING_OPT_OUT_NOTICE,
UsKyField.SALE_OPT_OUT,
UsKyField.TARGETED_ADVERTISING_OPT_OUT,
UsKyField.KNOWN_CHILD_SENSITIVE_DATA_CONSENTS,
UsKyField.ADDITIONAL_DATA_PROCESSING_CONSENT
});
//@formatter:on

//@formatter:off
public static List<String> USKY_SENSITIVE_DATA_CONSENT_SEGMENT_FIELD_NAMES = Arrays.asList(new String[] {
UsKyField.SENSITIVE_DATA_PROCESSING
});
//@formatter:on
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
package com.iab.gpp.encoder.field;

import java.util.Arrays;
import java.util.List;

public class UsMdField {

public static String MSPA_VERSION = "MspaVersion";
public static String MSPA_COVERED_TRANSACTION = "MspaCoveredTransaction";
public static String MSPA_MODE = "MspaMode";
public static String PROCESSING_NOTICE = "ProcessingNotice";
public static String SALE_OPT_OUT_NOTICE = "SaleOptOutNotice";
public static String TARGETED_ADVERTISING_OPT_OUT_NOTICE = "TargetedAdvertisingOptOutNotice";
public static String SALE_OPT_OUT = "SaleOptOut";
public static String TARGETED_ADVERTISING_OPT_OUT = "TargetedAdvertisingOptOut";
public static String ADDITIONAL_DATA_PROCESSING_CONSENT = "AdditionalDataProcessingConsent";

public static String GPC_SEGMENT_TYPE = "GpcSegmentType";
public static String GPC_SEGMENT_INCLUDED = "GpcSegmentIncluded";
public static String GPC = "Gpc";

//@formatter:off
public static List<String> USMD_CORE_SEGMENT_FIELD_NAMES = Arrays.asList(new String[] {
UsMdField.MSPA_VERSION,
UsMdField.MSPA_COVERED_TRANSACTION,
UsMdField.MSPA_MODE,
UsMdField.PROCESSING_NOTICE,
UsMdField.SALE_OPT_OUT_NOTICE,
UsMdField.TARGETED_ADVERTISING_OPT_OUT_NOTICE,
UsMdField.SALE_OPT_OUT,
UsMdField.TARGETED_ADVERTISING_OPT_OUT,
UsMdField.ADDITIONAL_DATA_PROCESSING_CONSENT
});
//@formatter:on

//@formatter:off
public static List<String> USMD_GPC_SEGMENT_FIELD_NAMES = Arrays.asList(new String[] {
UsMdField.GPC_SEGMENT_TYPE,
UsMdField.GPC
});
//@formatter:on
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
package com.iab.gpp.encoder.field;

import java.util.Arrays;
import java.util.List;

public class UsRiField {

public static String MSPA_VERSION = "MspaVersion";
public static String MSPA_COVERED_TRANSACTION = "MspaCoveredTransaction";
public static String MSPA_MODE = "MspaMode";
public static String PROCESSING_NOTICE = "ProcessingNotice";
public static String SALE_OPT_OUT_NOTICE = "SaleOptOutNotice";
public static String TARGETED_ADVERTISING_OPT_OUT_NOTICE = "TargetedAdvertisingOptOutNotice";
public static String SALE_OPT_OUT = "SaleOptOut";
public static String TARGETED_ADVERTISING_OPT_OUT = "TargetedAdvertisingOptOut";
public static String KNOWN_CHILD_SENSITIVE_DATA_CONSENTS = "KnownChildSensitiveDataConsents";
public static String ADDITIONAL_DATA_PROCESSING_CONSENT = "AdditionalDataProcessingConsent";
public static String SENSITIVE_DATA_PROCESSING = "SensitiveDataProcessing";

public static String SENSITIVE_DATA_CONSENT_SEGMENT_INCLUDED = "SensitiveDataConsentSegmentIncluded";

//@formatter:off
public static List<String> USRI_CORE_SEGMENT_FIELD_NAMES = Arrays.asList(new String[] {
UsRiField.MSPA_VERSION,
UsRiField.MSPA_COVERED_TRANSACTION,
UsRiField.MSPA_MODE,
UsRiField.PROCESSING_NOTICE,
UsRiField.SALE_OPT_OUT_NOTICE,
UsRiField.TARGETED_ADVERTISING_OPT_OUT_NOTICE,
UsRiField.SALE_OPT_OUT,
UsRiField.TARGETED_ADVERTISING_OPT_OUT,
UsRiField.KNOWN_CHILD_SENSITIVE_DATA_CONSENTS,
UsRiField.ADDITIONAL_DATA_PROCESSING_CONSENT
});
//@formatter:on

//@formatter:off
public static List<String> USRI_SENSITIVE_DATA_CONSENT_SEGMENT_FIELD_NAMES = Arrays.asList(new String[] {
UsRiField.SENSITIVE_DATA_PROCESSING
});
//@formatter:on
}
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,10 @@ public class Sections {
SECTION_ID_NAME_MAP.put(UsNj.ID, UsNj.NAME);
SECTION_ID_NAME_MAP.put(UsTn.ID, UsTn.NAME);
SECTION_ID_NAME_MAP.put(UsMn.ID, UsMn.NAME);
SECTION_ID_NAME_MAP.put(UsMd.ID, UsMd.NAME);
SECTION_ID_NAME_MAP.put(UsIn.ID, UsIn.NAME);
SECTION_ID_NAME_MAP.put(UsKy.ID, UsKy.NAME);
SECTION_ID_NAME_MAP.put(UsRi.ID, UsRi.NAME);

SECTION_ORDER = new ArrayList<Integer>(SECTION_ID_NAME_MAP.keySet()).stream().sorted()
.map(id -> SECTION_ID_NAME_MAP.get(id)).collect(Collectors.toList());
Expand Down
132 changes: 132 additions & 0 deletions iabgpp-encoder/src/main/java/com/iab/gpp/encoder/section/UsIn.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,132 @@
package com.iab.gpp.encoder.section;

import com.iab.gpp.encoder.field.UsInField;
import com.iab.gpp.encoder.segment.*;

import java.util.ArrayList;
import java.util.List;

public class UsIn extends AbstractLazilyEncodableSection {

public static int ID = 25;
public static int VERSION = 1;
public static String NAME = "usin";

public UsIn() {
super();
}

public UsIn(String encodedString) {
super();
decode(encodedString);
}

@Override
public int getId() {
return UsIn.ID;
}

@Override
public String getName() {
return UsIn.NAME;
}

@Override
public int getVersion() {
return UsIn.VERSION;
}

@Override
protected List<EncodableSegment> initializeSegments() {
List<EncodableSegment> segments = new ArrayList<>();
segments.add(new UsInCoreSegment());
segments.add(new UsInSensitiveDataConsentSegment());
return segments;
}

@Override
protected List<EncodableSegment> decodeSection(String encodedString) {
List<EncodableSegment> segments = initializeSegments();

if (encodedString != null && !encodedString.isEmpty()) {
String[] encodedSegments = encodedString.split("\\.");

if (encodedSegments.length > 0) {
segments.get(0).decode(encodedSegments[0]);
}

if (encodedSegments.length > 1) {
segments.get(1).setFieldValue(UsInField.SENSITIVE_DATA_CONSENT_SEGMENT_INCLUDED, true);
segments.get(1).decode(encodedSegments[1]);
} else {
segments.get(1).setFieldValue(UsInField.SENSITIVE_DATA_CONSENT_SEGMENT_INCLUDED, false);
}
}

return segments;
}

@Override
protected String encodeSection(List<EncodableSegment> segments) {
List<String> encodedSegments = new ArrayList<>();

if (!segments.isEmpty()) {
encodedSegments.add(segments.get(0).encode());
if (segments.size() >= 2 && segments.get(1).getFieldValue(UsInField.SENSITIVE_DATA_CONSENT_SEGMENT_INCLUDED).equals(true)) {
encodedSegments.add(segments.get(1).encode());
}
}

return String.join(".", encodedSegments);
}


public Integer getMspaVersion() {
return (Integer) this.getFieldValue(UsInField.MSPA_VERSION);
}

public Integer getMspaCoveredTransaction() {
return (Integer) this.getFieldValue(UsInField.MSPA_COVERED_TRANSACTION);
}

public Integer getMspaMode() {
return (Integer) this.getFieldValue(UsInField.MSPA_MODE);
}

public Integer getProcessingNotice() {
return (Integer) this.getFieldValue(UsInField.PROCESSING_NOTICE);
}

public Integer getSaleOptOutNotice() {
return (Integer) this.getFieldValue(UsInField.SALE_OPT_OUT_NOTICE);
}

public Integer getTargetedAdvertisingOptOutNotice() {
return (Integer) this.getFieldValue(UsInField.TARGETED_ADVERTISING_OPT_OUT_NOTICE);
}

public Integer getSaleOptOut() {
return (Integer) this.getFieldValue(UsInField.SALE_OPT_OUT);
}

public Integer getTargetedAdvertisingOptOut() {
return (Integer) this.getFieldValue(UsInField.TARGETED_ADVERTISING_OPT_OUT);
}

public Integer getKnownChildSensitiveDataConsents() {
return (Integer) this.getFieldValue(UsInField.KNOWN_CHILD_SENSITIVE_DATA_CONSENTS);
}

public Integer getAdditionalDataProcessingConsent() {
return (Integer) this.getFieldValue(UsInField.ADDITIONAL_DATA_PROCESSING_CONSENT);
}

public Boolean getSensitiveDataConsentSegmentIncluded() {
return (Boolean) this.getFieldValue(UsInField.SENSITIVE_DATA_CONSENT_SEGMENT_INCLUDED);
}

@SuppressWarnings("unchecked")
public List<Integer> getSensitiveDataProcessing() {
return (List<Integer>) this.getFieldValue(UsInField.SENSITIVE_DATA_PROCESSING);
}
}
Loading
Loading