Skip to content

Commit 8da3fe6

Browse files
chuffChad Huff
andauthored
DE IA NE NH NJ TN MSPA USNAT (#65)
* DE IA NE NH NJ TN * remove validation * usnat backwards compatibility --------- Co-authored-by: Chad Huff <chad@totalium.com>
1 parent d3d5017 commit 8da3fe6

35 files changed

+3324
-47
lines changed

iabgpp-encoder/src/main/java/com/iab/gpp/encoder/GppModel.java

Lines changed: 111 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -18,10 +18,16 @@
1818
import com.iab.gpp.encoder.section.UsCa;
1919
import com.iab.gpp.encoder.section.UsCo;
2020
import com.iab.gpp.encoder.section.UsCt;
21+
import com.iab.gpp.encoder.section.UsDe;
2122
import com.iab.gpp.encoder.section.UsFl;
23+
import com.iab.gpp.encoder.section.UsIa;
2224
import com.iab.gpp.encoder.section.UsMt;
2325
import com.iab.gpp.encoder.section.UsNat;
26+
import com.iab.gpp.encoder.section.UsNe;
27+
import com.iab.gpp.encoder.section.UsNh;
28+
import com.iab.gpp.encoder.section.UsNj;
2429
import com.iab.gpp.encoder.section.UsOr;
30+
import com.iab.gpp.encoder.section.UsTn;
2531
import com.iab.gpp.encoder.section.UsTx;
2632
import com.iab.gpp.encoder.section.UsUt;
2733
import com.iab.gpp.encoder.section.UsVa;
@@ -31,10 +37,10 @@ public class GppModel {
3137
private Map<String, EncodableSection> sections = new HashMap<>();
3238

3339
private String encodedString;
34-
40+
3541
private boolean dirty = false;
3642
private boolean decoded = true;
37-
43+
3844
public GppModel() {
3945

4046
}
@@ -53,7 +59,7 @@ public void setFieldValue(String sectionName, String fieldName, Object value) {
5359
this.dirty = false;
5460
this.decoded = true;
5561
}
56-
62+
5763
EncodableSection section = null;
5864
if (!this.sections.containsKey(sectionName)) {
5965
if (sectionName.equals(TcfCaV1.NAME)) {
@@ -95,6 +101,24 @@ public void setFieldValue(String sectionName, String fieldName, Object value) {
95101
} else if (sectionName.equals(UsTx.NAME)) {
96102
section = new UsTx();
97103
this.sections.put(UsTx.NAME, section);
104+
} else if (sectionName.equals(UsDe.NAME)) {
105+
section = new UsDe();
106+
this.sections.put(UsDe.NAME, section);
107+
} else if (sectionName.equals(UsIa.NAME)) {
108+
section = new UsIa();
109+
this.sections.put(UsIa.NAME, section);
110+
} else if (sectionName.equals(UsNe.NAME)) {
111+
section = new UsNe();
112+
this.sections.put(UsNe.NAME, section);
113+
} else if (sectionName.equals(UsNh.NAME)) {
114+
section = new UsNh();
115+
this.sections.put(UsNh.NAME, section);
116+
} else if (sectionName.equals(UsNj.NAME)) {
117+
section = new UsNj();
118+
this.sections.put(UsNj.NAME, section);
119+
} else if (sectionName.equals(UsTn.NAME)) {
120+
section = new UsTn();
121+
this.sections.put(UsTn.NAME, section);
98122
}
99123
} else {
100124
section = this.sections.get(sectionName);
@@ -118,7 +142,7 @@ public Object getFieldValue(String sectionName, String fieldName) {
118142
this.dirty = false;
119143
this.decoded = true;
120144
}
121-
145+
122146
if (this.sections.containsKey(sectionName)) {
123147
return this.sections.get(sectionName).getFieldValue(fieldName);
124148
} else {
@@ -136,7 +160,7 @@ public boolean hasField(String sectionName, String fieldName) {
136160
this.dirty = false;
137161
this.decoded = true;
138162
}
139-
163+
140164
if (this.sections.containsKey(sectionName)) {
141165
return this.sections.get(sectionName).hasField(fieldName);
142166
} else {
@@ -154,7 +178,7 @@ public boolean hasSection(String sectionName) {
154178
this.dirty = false;
155179
this.decoded = true;
156180
}
157-
181+
158182
return this.sections.containsKey(sectionName);
159183
}
160184

@@ -164,7 +188,7 @@ public HeaderV1 getHeader() {
164188
this.dirty = false;
165189
this.decoded = true;
166190
}
167-
191+
168192
HeaderV1 header = new HeaderV1();
169193
try {
170194
header.setFieldValue("SectionIds", this.getSectionIds());
@@ -184,7 +208,7 @@ public EncodableSection getSection(String sectionName) {
184208
this.dirty = false;
185209
this.decoded = true;
186210
}
187-
211+
188212
if (this.sections.containsKey(sectionName)) {
189213
return this.sections.get(sectionName);
190214
} else {
@@ -202,7 +226,7 @@ public void deleteSection(String sectionName) {
202226
this.dirty = false;
203227
this.decoded = true;
204228
}
205-
229+
206230
if (this.sections.containsKey(sectionName)) {
207231
this.sections.remove(sectionName);
208232
this.dirty = true;
@@ -251,30 +275,54 @@ public UsUt getUsUtSection() {
251275
public UsCt getUsCtSection() {
252276
return (UsCt) getSection(UsCt.NAME);
253277
}
254-
278+
255279
public UsFl getUsFlSection() {
256280
return (UsFl) getSection(UsFl.NAME);
257281
}
258-
282+
259283
public UsMt getUsMtSection() {
260284
return (UsMt) getSection(UsMt.NAME);
261285
}
262-
286+
263287
public UsOr getUsOrSection() {
264288
return (UsOr) getSection(UsOr.NAME);
265289
}
266-
290+
267291
public UsTx getUsTxSection() {
268292
return (UsTx) getSection(UsTx.NAME);
269293
}
270-
294+
295+
public UsDe getUsDeSection() {
296+
return (UsDe) getSection(UsDe.NAME);
297+
}
298+
299+
public UsIa getUsIaSection() {
300+
return (UsIa) getSection(UsIa.NAME);
301+
}
302+
303+
public UsNe getUsNeSection() {
304+
return (UsNe) getSection(UsNe.NAME);
305+
}
306+
307+
public UsNh getUsNhSection() {
308+
return (UsNh) getSection(UsNh.NAME);
309+
}
310+
311+
public UsNj getUsNjSection() {
312+
return (UsNj) getSection(UsNj.NAME);
313+
}
314+
315+
public UsTn getUsTnSection() {
316+
return (UsTn) getSection(UsTn.NAME);
317+
}
318+
271319
public List<Integer> getSectionIds() {
272320
if (!this.decoded) {
273321
this.sections = this.decodeModel(this.encodedString);
274322
this.dirty = false;
275323
this.decoded = true;
276324
}
277-
325+
278326
List<Integer> sectionIds = new ArrayList<>();
279327
for (int i = 0; i < Sections.SECTION_ORDER.size(); i++) {
280328
String sectionName = Sections.SECTION_ORDER.get(i);
@@ -311,14 +359,14 @@ protected String encodeModel(Map<String, EncodableSection> sections) {
311359
}
312360

313361
protected Map<String, EncodableSection> decodeModel(String str) {
314-
if(str == null || str.isEmpty() || str.startsWith("D")) {
362+
if (str == null || str.isEmpty() || str.startsWith("D")) {
315363
Map<String, EncodableSection> sections = new HashMap<>();
316-
317-
if(str != null && !str.isEmpty()) {
364+
365+
if (str != null && !str.isEmpty()) {
318366
String[] encodedSections = str.split("~");
319367
HeaderV1 header = new HeaderV1(encodedSections[0]);
320368
sections.put(HeaderV1.NAME, header);
321-
369+
322370
@SuppressWarnings("unchecked")
323371
List<Integer> sectionIds = (List<Integer>) header.getFieldValue("SectionIds");
324372
for (int i = 0; i < sectionIds.size(); i++) {
@@ -361,12 +409,30 @@ protected Map<String, EncodableSection> decodeModel(String str) {
361409
} else if (sectionIds.get(i).equals(UsTx.ID)) {
362410
UsTx section = new UsTx(encodedSections[i + 1]);
363411
sections.put(UsTx.NAME, section);
412+
} else if (sectionIds.get(i).equals(UsDe.ID)) {
413+
UsDe section = new UsDe(encodedSections[i + 1]);
414+
sections.put(UsDe.NAME, section);
415+
} else if (sectionIds.get(i).equals(UsIa.ID)) {
416+
UsIa section = new UsIa(encodedSections[i + 1]);
417+
sections.put(UsIa.NAME, section);
418+
} else if (sectionIds.get(i).equals(UsNe.ID)) {
419+
UsNe section = new UsNe(encodedSections[i + 1]);
420+
sections.put(UsNe.NAME, section);
421+
} else if (sectionIds.get(i).equals(UsNh.ID)) {
422+
UsNh section = new UsNh(encodedSections[i + 1]);
423+
sections.put(UsNh.NAME, section);
424+
} else if (sectionIds.get(i).equals(UsNj.ID)) {
425+
UsNj section = new UsNj(encodedSections[i + 1]);
426+
sections.put(UsNj.NAME, section);
427+
} else if (sectionIds.get(i).equals(UsTn.ID)) {
428+
UsTn section = new UsTn(encodedSections[i + 1]);
429+
sections.put(UsTn.NAME, section);
364430
}
365431
}
366432
}
367-
433+
368434
return sections;
369-
} else if(str.startsWith("C")) {
435+
} else if (str.startsWith("C")) {
370436
// old tcfeu only string
371437
Map<String, EncodableSection> sections = new HashMap<>();
372438

@@ -393,7 +459,7 @@ public String encodeSection(String sectionName) {
393459
this.dirty = false;
394460
this.decoded = true;
395461
}
396-
462+
397463
if (this.sections.containsKey(sectionName)) {
398464
return this.sections.get(sectionName).encode();
399465
} else {
@@ -447,6 +513,24 @@ public void decodeSection(String sectionName, String encodedString) {
447513
} else if (sectionName.equals(UsTx.NAME)) {
448514
section = new UsTx();
449515
this.sections.put(UsTx.NAME, section);
516+
}else if (sectionName.equals(UsDe.NAME)) {
517+
section = new UsDe();
518+
this.sections.put(UsDe.NAME, section);
519+
}else if (sectionName.equals(UsIa.NAME)) {
520+
section = new UsIa();
521+
this.sections.put(UsIa.NAME, section);
522+
}else if (sectionName.equals(UsNe.NAME)) {
523+
section = new UsNe();
524+
this.sections.put(UsNe.NAME, section);
525+
}else if (sectionName.equals(UsNh.NAME)) {
526+
section = new UsNh();
527+
this.sections.put(UsNh.NAME, section);
528+
}else if (sectionName.equals(UsNj.NAME)) {
529+
section = new UsNj();
530+
this.sections.put(UsNj.NAME, section);
531+
}else if (sectionName.equals(UsTn.NAME)) {
532+
section = new UsTn();
533+
this.sections.put(UsTn.NAME, section);
450534
}
451535
} else {
452536
section = this.sections.get(sectionName);
@@ -456,7 +540,7 @@ public void decodeSection(String sectionName, String encodedString) {
456540
section.decode(encodedString);
457541
}
458542
}
459-
543+
460544
public String encode() {
461545
if (this.encodedString == null || this.encodedString.isEmpty() || this.dirty) {
462546
this.encodedString = encodeModel(this.sections);
@@ -466,12 +550,12 @@ public String encode() {
466550

467551
return this.encodedString;
468552
}
469-
553+
470554
public void decode(String encodedString) {
471555
this.encodedString = encodedString;
472556
this.dirty = false;
473557
this.decoded = false;
474558
}
475-
476-
477-
}
559+
560+
561+
}
Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
package com.iab.gpp.encoder.field;
2+
3+
import java.util.Arrays;
4+
import java.util.List;
5+
6+
public class UsDeField {
7+
8+
public static String VERSION = "Version";
9+
public static String PROCESSING_NOTICE = "ProcessingNotice";
10+
public static String SALE_OPT_OUT_NOTICE = "SaleOptOutNotice";
11+
public static String TARGETED_ADVERTISING_OPT_OUT_NOTICE = "TargetedAdvertisingOptOutNotice";
12+
public static String SALE_OPT_OUT = "SaleOptOut";
13+
public static String TARGETED_ADVERTISING_OPT_OUT = "TargetedAdvertisingOptOut";
14+
public static String SENSITIVE_DATA_PROCESSING = "SensitiveDataProcessing";
15+
public static String KNOWN_CHILD_SENSITIVE_DATA_CONSENTS = "KnownChildSensitiveDataConsents";
16+
public static String ADDITIONAL_DATA_PROCESSING_CONSENT = "AdditionalDataProcessingConsent";
17+
public static String MSPA_COVERED_TRANSACTION = "MspaCoveredTransaction";
18+
public static String MSPA_OPT_OUT_OPTION_MODE = "MspaOptOutOptionMode";
19+
public static String MSPA_SERVICE_PROVIDER_MODE = "MspaServiceProviderMode";
20+
21+
public static String GPC_SEGMENT_TYPE = "GpcSegmentType";
22+
public static String GPC_SEGMENT_INCLUDED = "GpcSegmentIncluded";
23+
public static String GPC = "Gpc";
24+
25+
//@formatter:off
26+
public static List<String> USDE_CORE_SEGMENT_FIELD_NAMES = Arrays.asList(new String[] {
27+
UsDeField.VERSION,
28+
UsDeField.PROCESSING_NOTICE,
29+
UsDeField.SALE_OPT_OUT_NOTICE,
30+
UsDeField.TARGETED_ADVERTISING_OPT_OUT_NOTICE,
31+
UsDeField.SALE_OPT_OUT,
32+
UsDeField.TARGETED_ADVERTISING_OPT_OUT,
33+
UsDeField.SENSITIVE_DATA_PROCESSING,
34+
UsDeField.KNOWN_CHILD_SENSITIVE_DATA_CONSENTS,
35+
UsDeField.ADDITIONAL_DATA_PROCESSING_CONSENT,
36+
UsDeField.MSPA_COVERED_TRANSACTION,
37+
UsDeField.MSPA_OPT_OUT_OPTION_MODE,
38+
UsDeField.MSPA_SERVICE_PROVIDER_MODE
39+
});
40+
//@formatter:on
41+
42+
//@formatter:off
43+
public static List<String> USDE_GPC_SEGMENT_FIELD_NAMES = Arrays.asList(new String[] {
44+
UsDeField.GPC_SEGMENT_TYPE,
45+
UsDeField.GPC
46+
});
47+
//@formatter:on
48+
}
Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
package com.iab.gpp.encoder.field;
2+
3+
import java.util.Arrays;
4+
import java.util.List;
5+
6+
public class UsIaField {
7+
8+
public static String VERSION = "Version";
9+
public static String PROCESSING_NOTICE = "ProcessingNotice";
10+
public static String SALE_OPT_OUT_NOTICE = "SaleOptOutNotice";
11+
public static String TARGETED_ADVERTISING_OPT_OUT_NOTICE = "TargetedAdvertisingOptOutNotice";
12+
public static String SENSITIVE_DATA_OPT_OUT_NOTICE = "SensitiveDataOptOutNotice";
13+
public static String SALE_OPT_OUT = "SaleOptOut";
14+
public static String TARGETED_ADVERTISING_OPT_OUT = "TargetedAdvertisingOptOut";
15+
public static String SENSITIVE_DATA_PROCESSING = "SensitiveDataProcessing";
16+
public static String KNOWN_CHILD_SENSITIVE_DATA_CONSENTS = "KnownChildSensitiveDataConsents";
17+
public static String MSPA_COVERED_TRANSACTION = "MspaCoveredTransaction";
18+
public static String MSPA_OPT_OUT_OPTION_MODE = "MspaOptOutOptionMode";
19+
public static String MSPA_SERVICE_PROVIDER_MODE = "MspaServiceProviderMode";
20+
21+
public static String GPC_SEGMENT_TYPE = "GpcSegmentType";
22+
public static String GPC_SEGMENT_INCLUDED = "GpcSegmentIncluded";
23+
public static String GPC = "Gpc";
24+
25+
//@formatter:off
26+
public static List<String> USIA_CORE_SEGMENT_FIELD_NAMES = Arrays.asList(new String[] {
27+
UsIaField.VERSION,
28+
UsIaField.PROCESSING_NOTICE,
29+
UsIaField.SALE_OPT_OUT_NOTICE,
30+
UsIaField.TARGETED_ADVERTISING_OPT_OUT_NOTICE,
31+
UsIaField.SENSITIVE_DATA_OPT_OUT_NOTICE,
32+
UsIaField.SALE_OPT_OUT,
33+
UsIaField.TARGETED_ADVERTISING_OPT_OUT,
34+
UsIaField.SENSITIVE_DATA_PROCESSING,
35+
UsIaField.KNOWN_CHILD_SENSITIVE_DATA_CONSENTS,
36+
UsIaField.MSPA_COVERED_TRANSACTION,
37+
UsIaField.MSPA_OPT_OUT_OPTION_MODE,
38+
UsIaField.MSPA_SERVICE_PROVIDER_MODE
39+
});
40+
//@formatter:on
41+
42+
//@formatter:off
43+
public static List<String> USIA_GPC_SEGMENT_FIELD_NAMES = Arrays.asList(new String[] {
44+
UsIaField.GPC_SEGMENT_TYPE,
45+
UsIaField.GPC
46+
});
47+
//@formatter:on
48+
}

0 commit comments

Comments
 (0)