Skip to content

Commit c1482e1

Browse files
chuffiabmayankchadguofangliGuofang Li
authored
Fail if gpp string doesnt start with DB (#76)
* initial multi state implementation * multi state * unit tests * exposing id based methods in GppModel * personal data consents fix, reduce multi state subsection id (#10) Co-authored-by: chad <[email protected]> * 3.0.0 (#11) * personal data consents fix, reduce multi state subsection id * scm * [maven-release-plugin] prepare release iabgpp-core-3.0.0 * scm * scm * scm * scm * 3.0.0 * 3.0.1-SNAPSHOT Co-authored-by: chad <[email protected]> * fix multi state name, add unit tests (#13) * personal data consents fix, reduce multi state subsection id * scm * [maven-release-plugin] prepare release iabgpp-core-3.0.0 * scm * scm * scm * scm * 3.0.0 * 3.0.1-SNAPSHOT * fix section names and add unit tests Co-authored-by: chad <[email protected]> * 3.0.1 (#14) * personal data consents fix, reduce multi state subsection id * scm * [maven-release-plugin] prepare release iabgpp-core-3.0.0 * scm * scm * scm * scm * 3.0.0 * 3.0.1-SNAPSHOT * fix section names and add unit tests * 3.0.1 * 3.1.0-SNAPSHOT * cleanup * fix groupId in README * fix groupId in README * fix groupId in README Co-authored-by: chad <[email protected]> * Convenience Methods (#15) * personal data consents fix, reduce multi state subsection id * scm * [maven-release-plugin] prepare release iabgpp-core-3.0.0 * scm * scm * scm * scm * 3.0.0 * 3.0.1-SNAPSHOT * fix section names and add unit tests * 3.0.1 * 3.1.0-SNAPSHOT * cleanup * fix groupId in README * fix groupId in README * fix groupId in README * convenience methods * 3.0.2 * 3.1.0-SNAPSHOT Co-authored-by: chad <[email protected]> * full list of fields to readme (#16) * personal data consents fix, reduce multi state subsection id * scm * [maven-release-plugin] prepare release iabgpp-core-3.0.0 * scm * scm * scm * scm * 3.0.0 * 3.0.1-SNAPSHOT * fix section names and add unit tests * 3.0.1 * 3.1.0-SNAPSHOT * cleanup * fix groupId in README * fix groupId in README * fix groupId in README * convenience methods * 3.0.2 * 3.1.0-SNAPSHOT * full list of fields to readme * rename array to list in readme Co-authored-by: chad <[email protected]> * tcfeuv2 backwards compatible (#19) * Exception handling * compressed base64urlencoder for all non-tcfeuv2 segments * Revert uspv1 to original encoding * Rename tcfcav2 to tcfcav1 * update readme for tcfcav2 -> tcfcav1 and uspv1 changes * optional gpc segments * update readme with GpcSegmentIncluded fields * fix vendor list encoding / decoding * formatting * 3.0.3 * version bump Co-authored-by: chad <[email protected]> * Update dependencies. Fix bitfield cast. (#20) * Exception handling * compressed base64urlencoder for all non-tcfeuv2 segments * Revert uspv1 to original encoding * Rename tcfcav2 to tcfcav1 * update readme for tcfcav2 -> tcfcav1 and uspv1 changes * optional gpc segments * update readme with GpcSegmentIncluded fields * fix vendor list encoding / decoding * formatting * 3.0.3 * version bump * fix bitfield data type * update jackson version * update junit * 3.0.4 * 3.0.5-SNAPSHOT * 3.0.5 * 3.0.6-SNAPSHOT * 3.0.6 * 3.0.7-SNAPSHOT * 3.0.7 * 3.0.8-SNAPSHOT Co-authored-by: chad <[email protected]> * Dedupe and sort lists. Added InvalidFieldError. (#24) * fix optimized fix range decoder * fix optimized fibonacci fix range decoder * 3.0.8 * 3.0.9-SNAPSHOT * 3.0.9 * 3.0.10-SNAPSHOT * dedup and sort lists * formatting * 3.0.10 * 3.0.11-SNAPSHOT * 3.0.12-SNAPSHOT * 3.0.11-SNAPSHOT * 3.0.10 * 3.0.11-SNAPSHOT * 3.0.10 * 3.0.11-SNAPSHOT * cleanup Co-authored-by: chad <[email protected]> * issue 26: wrong version number for TcfCaV1 (#27) Co-authored-by: Guofang Li <[email protected]> * Removes duplicate section in the GppModel.decodeSection if tree as UspV1 was in the list twice. (#30) * Updating GVL code as V3 and adding some comments (#32) * #29 #26 * Removes duplicate section in the GppModel.decodeSection * Rename multistate usp* to us* * fix tcfcav1 policy version * vendor list 2.2 * lazy decoding * cleanup lazy decoding * Updating GVL code as V3 and adding some comments; also removing GPPModel LazyDecoding feature; also keeping the TCF policy version as 2 for Canada. * 3.1.0 * 3.1.1-SNAPSHOT --------- Co-authored-by: chad <[email protected]> Co-authored-by: srini81 <[email protected]> * rename missed multistate usp* methods to us* (#35) Co-authored-by: chad <[email protected]> * Adding a new field in Vendor for "impConsPurposes" as the GVL for Canada has changed to include this field in the place of "legIntPurposes". (#37) Both these fields will be set to Optional in order to handle both Canada and EU use cases. Co-authored-by: srini81 <[email protected]> * 3.1.1 * 3.1.2-SNAPSHOT * Version Bump (#38) * 3.1.1 * 3.1.2-SNAPSHOT --------- Co-authored-by: chad <[email protected]> * lazy decoding (#34) * lazy decoding * java 8 compatible gppmodel tests * rename missed multistate usp* methods to us* * lazier decoding * lazier decoding * tests for null and empty string constructor arguments * deprecate multi-state usp* methods * remove deprecated usp methods * encodeSection lazy fix * optimize bitstring padding --------- Co-authored-by: chad <[email protected]> * Update README.md (#46) Fix incorrect client-side API prefixes. https://github.com/InteractiveAdvertisingBureau/Global-Privacy-Platform/blob/main/Sections/Section%20Information.md is the authority. * Validation (#36) * lazy decoding * java 8 compatible gppmodel tests * rename missed multistate usp* methods to us* * lazier decoding * lazier decoding * tests for null and empty string constructor arguments * validation * fix typo * remove redundant validate call * default validate * remove empty validate method from header core segment * fix usct validator * deprecate multi-state usp* methods * remove deprecated usp methods * cleanup validators * encodeSection lazy fix --------- Co-authored-by: chad <[email protected]> * tcfca pub restrictions and disclosed vendors (#39) * rename missed multistate usp* methods to us* * 3.1.1 * 3.1.2-SNAPSHOT * tcfca publisher restrictions and disclosed vendors * deprecate multi-state usp* methods * substring error handling * remove deprecated usp methods * Update README * tcfeu pub restrictions fix * pub restrictions getters * tcfeu pub restirctions fix * cleanup * pub restrictions fix --------- Co-authored-by: chad <[email protected]> * 3.2.0 * 3.2.1-SNAPSHOT * Versioning (#47) * 3.1.1 * 3.1.2-SNAPSHOT * 3.2.0 * 3.2.1-SNAPSHOT --------- Co-authored-by: chad <[email protected]> * Remove multistate version (#60) * lazy decoding * java 8 compatible gppmodel tests * rename missed multistate usp* methods to us* * lazier decoding * lazier decoding * tests for null and empty string constructor arguments * validation * fix typo * remove redundant validate call * default validate * remove empty validate method from header core segment * fix usct validator * 3.1.1 * 3.1.2-SNAPSHOT * tcfca publisher restrictions and disclosed vendors * deprecate multi-state usp* methods * substring error handling * remove deprecated usp methods * remove deprecated usp methods * remove deprecated usp methods * cleanup validators * Better decoding exception messaging * remove unused classes * Update README * add support for the old headerless tcfeuv2 strings * encodeSection fix * encodeSection lazy fix * tcfeu pub restrictions fix * pub restrictions getters * tcfeu pub restirctions fix * cleanup * pub restrictions fix * optimize bitstring padding * 3.2.0 * 3.2.1-SNAPSHOT * fl mt or tx * remove version from multistate resources --------- Co-authored-by: chad <[email protected]> * Post release version bump (#64) * 3.2.1 * 3.2.2-SNAPSHOT --------- Co-authored-by: Chad Huff <[email protected]> * 3.2.2 * 3.2.3-SNAPSHOT * Tx fl or mt (#57) * lazy decoding * java 8 compatible gppmodel tests * rename missed multistate usp* methods to us* * lazier decoding * lazier decoding * tests for null and empty string constructor arguments * validation * fix typo * remove redundant validate call * default validate * remove empty validate method from header core segment * fix usct validator * 3.1.1 * 3.1.2-SNAPSHOT * tcfca publisher restrictions and disclosed vendors * deprecate multi-state usp* methods * substring error handling * remove deprecated usp methods * remove deprecated usp methods * remove deprecated usp methods * cleanup validators * Better decoding exception messaging * remove unused classes * Update README * add support for the old headerless tcfeuv2 strings * encodeSection fix * encodeSection lazy fix * tcfeu pub restrictions fix * pub restrictions getters * tcfeu pub restirctions fix * cleanup * pub restrictions fix * optimize bitstring padding * 3.2.0 * 3.2.1-SNAPSHOT * fl mt or tx --------- Co-authored-by: chad <[email protected]> * Update AbstractLazilyEncodableSection.java (#61) * 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 <[email protected]> * remove validation (#66) * remove validation * fix lazy decoding in decodeSection --------- Co-authored-by: Chad Huff <[email protected]> * 3.2.3 * 3.2.4-SNAPSHOT * Added GitHub Actions workflow file for iabgpp-java version release * Fail if gpp string doesnt start with DB * fix merge conflict --------- Co-authored-by: Mayank Mishra <[email protected]> Co-authored-by: chad <[email protected]> Co-authored-by: Guofang Li <[email protected]> Co-authored-by: Guofang Li <[email protected]> Co-authored-by: Bryan DeLong <[email protected]> Co-authored-by: srini81 <[email protected]> Co-authored-by: Srinivas Bhagavatula <[email protected]> Co-authored-by: Daniël Hoeksema <[email protected]> Co-authored-by: iabsxhxl <[email protected]> Co-authored-by: naveenjr7 <[email protected]> Co-authored-by: aitsxhxl <[email protected]>
1 parent 8d79b10 commit c1482e1

File tree

4 files changed

+29
-18
lines changed

4 files changed

+29
-18
lines changed

.github/workflows/main.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@ jobs:
3333
rm -f secret_key.asc
3434
# gpg --list-secret-keys
3535

36+
3637
# Generate settings.xml with Maven repository credentials
3738
- name: Create settings.xml
3839
run: |

README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -263,3 +263,4 @@ CmpList cmpList = loader.cmpList(cmpListContent);
263263
## Contributing
264264

265265
Here you can find the [contributing guide](CONTRIBUTING.md) to help maintain and update the library. This library is managed by the Code Libraries Subgroup of the Global Privacy Working Group at the IAB Tech Lab. To join the group, please reach out to [email protected].
266+

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -359,7 +359,7 @@ protected String encodeModel(Map<String, EncodableSection> sections) {
359359
}
360360

361361
protected Map<String, EncodableSection> decodeModel(String str) {
362-
if (str == null || str.isEmpty() || str.startsWith("D")) {
362+
if (str == null || str.isEmpty() || str.startsWith("DB")) {
363363
Map<String, EncodableSection> sections = new HashMap<>();
364364

365365
if (str != null && !str.isEmpty()) {

iabgpp-encoder/src/test/java/com/iab/gpp/encoder/GppModelTest.java

Lines changed: 26 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -69,20 +69,6 @@ public void testEncodeDefault() {
6969

7070
}
7171

72-
@Test
73-
public void testDecodingException() {
74-
Assertions.assertThrows(DecodingException.class, () -> {
75-
new GppModel("invalid gpp string").getHeader();
76-
});
77-
}
78-
79-
@Test()
80-
public void testDecodeGarbage() {
81-
Assertions.assertThrows(DecodingException.class, () -> {
82-
new GppModel("z").getUsCtSection();
83-
});
84-
}
85-
8672
@Test
8773
public void testEncodeDefaultAll() {
8874
GppModel gppModel = new GppModel();
@@ -132,7 +118,6 @@ public void testEncodeDefaultAll() {
132118
gppModel.setFieldValue(UsTn.NAME, UsTxField.VERSION, UsTx.VERSION);
133119

134120

135-
136121
Assertions.assertEquals(true, gppModel.hasSection(TcfEuV2.NAME));
137122
Assertions.assertEquals(true, gppModel.hasSection(TcfCaV1.NAME));
138123
Assertions.assertEquals(true, gppModel.hasSection(UspV1.NAME));
@@ -155,9 +140,22 @@ public void testEncodeDefaultAll() {
155140

156141
String gppString = gppModel.encode();
157142
Assertions.assertEquals(
158-
"DBACOdM~CPSG_8APSG_8AAAAAAENAACAAAAAAAAAAAAAAAAAAAAA.QAAA.IAAA~BPSG_8APSG_8AAAAAAENAACAAAAAAAAAAAAAAAAAAA.YAAAAAAAAAA~1---~BAAAAAAAAABA.QA~BAAAAABA.QA~BAAAABA~BAAAAEA.QA~BAAAAAQA~BAAAAAEA.QA~BAAAAABA~BAAAAABA.QA~BAAAAAABAA.QA~BAAAAAQA.QA~BAAAAAABAA.QA~BAAAAAQA.QA~BAAAAAQA.QA~BAAAAABA.QA~BAAAAAAAQA.QA~BAAAAAQA.QA",
159-
gppString);
143+
"DBACOdM~CPSG_8APSG_8AAAAAAENAACAAAAAAAAAAAAAAAAAAAAA.QAAA.IAAA~BPSG_8APSG_8AAAAAAENAACAAAAAAAAAAAAAAAAAAA.YAAAAAAAAAA~1---~BAAAAAAAAABA.QA~BAAAAABA.QA~BAAAABA~BAAAAEA.QA~BAAAAAQA~BAAAAAEA.QA~BAAAAABA~BAAAAABA.QA~BAAAAAABAA.QA~BAAAAAQA.QA~BAAAAAABAA.QA~BAAAAAQA.QA~BAAAAAQA.QA~BAAAAABA.QA~BAAAAAAAQA.QA~BAAAAAQA.QA",
144+
gppString);
145+
}
160146

147+
@Test
148+
public void testDecodingException() {
149+
Assertions.assertThrows(DecodingException.class, () -> {
150+
new GppModel("invalid gpp string").getHeader();
151+
});
152+
}
153+
154+
@Test()
155+
public void testDecodeGarbage() {
156+
Assertions.assertThrows(DecodingException.class, () -> {
157+
new GppModel("z").getUsCtSection();
158+
});
161159
}
162160

163161
@Test
@@ -821,6 +819,17 @@ public void testDecodingEmptyString() {
821819
gppModel.setFieldValue("uspv1", UspV1Field.NOTICE, 'Y');
822820
Assertions.assertEquals("DBABTA~1Y--", gppModel.encode());
823821
}
822+
823+
@Test
824+
public void testDecodingExceptionValidStringButNotGPP() {
825+
try {
826+
GppModel gppModel = new GppModel("DP48G0AP48G0AEsACCPLAkEgAAAAAEPgAB5YAAAQaQD2F2K2kKFkPCmQWYAQBCijYEAhQAAAAkCBIAAgAUgQAgFIIAgAIFAAAAAAAAAQEgCQAAQABAAAIACgAAAAAAIAAAAAAAQQAAAAAIAAAAAAAAEAAAAAAAQAAAAIAABEhCAAQQAEAAAAAAAQAAAAAAAAAAABAAAAAAAAAAAAAAAAAAAAgAA");
827+
gppModel.getHeader().getName();
828+
Assertions.fail("Expected LazyDecodingException");
829+
} catch (DecodingException e) {
830+
831+
}
832+
}
824833

825834

826835
}

0 commit comments

Comments
 (0)