Skip to content

Commit 72e5e88

Browse files
authored
Merge pull request #32 from InteractiveAdvertisingBureau/maven_deployment
Setting up gradle for maven deployment. Updating documentation
2 parents 6b60636 + abf408e commit 72e5e88

File tree

9 files changed

+187
-34
lines changed

9 files changed

+187
-34
lines changed

.travis.yml

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,20 @@
11
language: java
2+
23
jdk:
34
- oraclejdk8
5+
- oraclejdk9
6+
- openjdk8
47

58
sudo: false
69

10+
before_cache:
11+
- rm -f $HOME/.gradle/caches/modules-2/modules-2.lock
12+
- rm -fr $HOME/.gradle/caches/*/plugin-resolution/
13+
714
cache:
815
directories:
9-
- $HOME/.gradle
16+
- $HOME/.gradle/caches/
17+
- $HOME/.gradle/wrapper/
1018

1119
script:
1220
- ./gradlew test
13-
14-
# https://github.com/travis-ci/travis-ci/issues/3259
15-
addons:
16-
apt:
17-
packages:
18-
- oracle-java8-installer

README.md

Lines changed: 79 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,4 @@
11

2-
A java implementation of the IAB consent string 1.1 spec.
3-
4-
to test run the following command
5-
6-
```sh
7-
# on *nix, Mac OS
8-
./gradlew test
9-
# or, on Windows
10-
.\gradlew.bat test
11-
```
12-
=======
132
# Transparency and Consent Framework: Consent-String-SDK-Java
143

154
Encode and decode web-safe base64 consent information with the IAB EU's GDPR Transparency and Consent Framework.
@@ -21,29 +10,103 @@ The IAB specification for the consent string format is available on the [IAB Git
2110

2211
**This library supports the version v1.1 of the specification. It can encode and decode consent strings with version bit 1.**
2312

24-
#### IAB Europe Transparency and Consent Framework
13+
## IAB Europe Transparency and Consent Framework
2514

2615
In November 2017, IAB Europe and a cross-section of the publishing and advertising industry, announced a new Transparency & Consent Framework to help publishers, advertisers and technology companies comply with key elements of GDPR. The Framework will give the publishing and advertising industries a common language with which to communicate consumer consent for the delivery of relevant online advertising and content.
2716

2817
Framework Technical specifications available at: https://raw.githubusercontent.com/InteractiveAdvertisingBureau/GDPR-Transparency-and-Consent-Framework.
2918

3019

31-
## Consent String SDK (Java)
20+
# Consent String SDK (Java)
3221
- [Installation](#installation)
3322
- [Usage](#usage)
34-
- [Use cases](#use-cases)
35-
- [Additional Documentation](#documentation)
23+
- [Building](#building)
24+
- [Contributing](#contributing)
25+
- [Versioning](#versioning)
26+
27+
28+
## Installation
29+
30+
Add dependency to you pom.xml
31+
32+
```
33+
<dependency>
34+
<groupId>com.conversantmedia.gdpr</groupId>
35+
<artifactId>consent-string-sdk-java</artifactId>
36+
<version>2.0.0</version>
37+
</dependency>
38+
```
3639

40+
## Usage
3741

42+
### Decoding consent string
43+
44+
```
45+
final VendorConsent vendorConsent = VendorConsentDecoder.fromBase64String(consentString);
46+
47+
if (vendorConsent.isVendorAllowed(vendorId) && vendorConsent.isPurposeAllowed(STORAGE_AND_ACCESS) {
48+
...
49+
} else {
50+
...
51+
}
52+
53+
```
3854

55+
### Creating vendor consent
56+
```
57+
final VendorConsent vendorConsent = new VendorConsentBuilder()
58+
.withConsentRecordCreatedOn(now)
59+
.withConsentRecordLastUpdatedOn(now)
60+
.withCmpID(cmpId)
61+
.withCmpVersion(cmpVersion)
62+
.withConsentScreenID(consentScreenID)
63+
.withConsentLanguage(consentLanguage)
64+
.withVendorListVersion(vendorListVersion)
65+
.withAllowedPurposes(allowedPurposes)
66+
.withMaxVendorId(maxVendorId)
67+
.withVendorEncodingType(vendorEncodingType)
68+
.withDefaultConsent(false)
69+
.withRangeEntries(rangeEntries)
70+
.build();
71+
```
72+
73+
### Encoding vendor consent to string
74+
```
75+
final String base64String = VendorConsentEncoder.toBase64String(vendorConsent);
76+
```
77+
78+
## Building
79+
80+
Use Gradle command to build the project
81+
```
82+
git clone https://github.com/InteractiveAdvertisingBureau/Consent-String-SDK-Java.git
83+
cd Consent-String-SDK-Java
84+
./gradlew build
85+
```
86+
87+
## Contributing
88+
89+
### Branching
90+
We use following branching setup
91+
1. **master** branch is the current branch where active development is taking place and is associated with the latest release
92+
1. Previous releases are under branches release/x, where x is the major release version, for example release/1. Those branches are used for bug bixes in previous releases
93+
1. Each release version is associated with a git tag, for example tag v2.0.0
94+
95+
### Pull request procedures
96+
1. Make sure there is a unit test for each added feature. If pull request is for bug fix, create a unit test that would trigger a bug
97+
1. Make sure **all** tests pass
98+
1. Update this document if usage is changing
99+
39100

101+
## Versioning
40102

103+
We use [SemVer](http://semver.org/) for versioning. For the versions available, see the [tags on this repository](https://github.com/InteractiveAdvertisingBureau/GDPR-Transparency-and-Consent-Framework/tags).
41104

42105
## About
43106

44107
#### About IAB Tech Lab
45108

46-
The IAB Technology Laboratory (?Tech Lab?) is a non-profit research and development consortium that produces and provides standards, software, and services to drive growth of an effective and sustainable global digital media ecosystem. Comprised of digital publishers and ad technology firms, as well as marketers, agencies, and other companies with interests in the interactive marketing arena, IAB Tech Lab aims to enable brand and media growth via a transparent, safe, effective supply chain, simpler and more consistent measurement, and better advertising experiences for consumers, with a focus on mobile and ?TV?/digital video channel enablement. The IAB Tech Lab portfolio includes the DigiTrust real-time standardized identity service designed to improve the digital experience for consumers, publishers, advertisers, and third-party platforms. Board members include AppNexus, ExtremeReach, Google, GroupM, Hearst Digital Media, Integral Ad Science, Index Exchange, LinkedIn, MediaMath, Microsoft, Moat, Pandora, PubMatic, Quantcast, Telaria, The Trade Desk, and Yahoo! Japan. Established in 2014, the IAB Tech Lab is headquartered in New York City with an office in San Francisco and representation in Seattle and London.
109+
The IAB Technology Laboratory (Tech Lab) is a non-profit research and development consortium that produces and provides standards, software, and services to drive growth of an effective and sustainable global digital media ecosystem. Comprised of digital publishers and ad technology firms, as well as marketers, agencies, and other companies with interests in the interactive marketing arena, IAB Tech Lab aims to enable brand and media growth via a transparent, safe, effective supply chain, simpler and more consistent measurement, and better advertising experiences for consumers, with a focus on mobile and ?TV?/digital video channel enablement. The IAB Tech Lab portfolio includes the DigiTrust real-time standardized identity service designed to improve the digital experience for consumers, publishers, advertisers, and third-party platforms. Board members include AppNexus, ExtremeReach, Google, GroupM, Hearst Digital Media, Integral Ad Science, Index Exchange, LinkedIn, MediaMath, Microsoft, Moat, Pandora, PubMatic, Quantcast, Telaria, The Trade Desk, and Yahoo! Japan. Established in 2014, the IAB Tech Lab is headquartered in New York City with an office in San Francisco and representation in Seattle and London.
47110

48111
Learn more about IAB Tech Lab here: [https://www.iabtechlab.com/](https://www.iabtechlab.com/)
49112

build.gradle

Lines changed: 77 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,18 @@
11
apply plugin: 'java'
22
apply plugin: 'eclipse'
33
apply plugin: 'idea'
4+
apply plugin: 'maven-publish'
5+
apply plugin: 'signing'
46

57
repositories {
68
mavenCentral()
79
mavenLocal()
810
}
911

10-
group = 'com.iab.gdpr'
11-
version = '2.0.0-SNAPSHOT'
12+
group = 'com.conversantmedia.gdpr'
13+
version = '2.0.0'
1214

13-
description = """A Java implementation of the IAB Consent String spec."""
15+
description = 'A Java implementation of the IAB Consent String spec.'
1416

1517
sourceCompatibility = 1.8
1618
targetCompatibility = 1.8
@@ -21,3 +23,75 @@ dependencies {
2123
"org.hamcrest:java-hamcrest:2.0.0.0"
2224
)
2325
}
26+
27+
task sourceJar(type: Jar) {
28+
classifier = 'sources'
29+
from sourceSets.main.allJava
30+
}
31+
32+
task packageJavadoc(type: Jar) {
33+
classifier = 'javadoc'
34+
from javadoc
35+
}
36+
37+
javadoc {
38+
source = sourceSets.main.allJava
39+
classpath = configurations.compileClasspath
40+
41+
options
42+
{
43+
setMemberLevel JavadocMemberLevel.PUBLIC
44+
setAuthor true
45+
46+
links "https://docs.oracle.com/javase/8/docs/api/"
47+
}
48+
}
49+
50+
publishing {
51+
52+
repositories {
53+
maven {
54+
name = 'OSS Nexus Staging'
55+
url = "https://oss.sonatype.org/service/local/staging/deploy/maven2"
56+
credentials {
57+
username = mavenUsername
58+
password = mavenPassword
59+
}
60+
}
61+
}
62+
63+
publications {
64+
mavenJava(MavenPublication) {
65+
from components.java
66+
67+
artifact sourceJar
68+
artifact packageJavadoc
69+
70+
pom {
71+
name = 'Consent-String-SDK-Java'
72+
description = 'A Java implementation of the IAB Consent String spec'
73+
url = 'https://github.com/InteractiveAdvertisingBureau/Consent-String-SDK-Java'
74+
licenses {
75+
license {
76+
name = 'MIT'
77+
url = 'https://opensource.org/licenses/MIT'
78+
}
79+
}
80+
developers {
81+
developer {
82+
id = 'IAB'
83+
name = 'IAB'
84+
85+
}
86+
}
87+
scm {
88+
url = 'https://github.com/InteractiveAdvertisingBureau/Consent-String-SDK-Java'
89+
}
90+
}
91+
}
92+
}
93+
}
94+
95+
signing {
96+
sign publishing.publications.mavenJava
97+
}
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
distributionBase=GRADLE_USER_HOME
22
distributionPath=wrapper/dists
3-
distributionUrl=https\://services.gradle.org/distributions/gradle-4.7-bin.zip
3+
distributionUrl=https\://services.gradle.org/distributions/gradle-4.8-bin.zip
44
zipStoreBase=GRADLE_USER_HOME
55
zipStorePath=wrapper/dists

settings.gradle

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1 +1,6 @@
11
rootProject.name = 'consent-string-sdk-java'
2+
3+
// Maven deployment properties. Set actual values in $HOME/.gradle/settings.gradle
4+
5+
mavenUsername = ''
6+
mavenPassword = ''

src/main/java/com/iab/gdpr/VendorConsent.java

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,11 @@
2424
* Draft_for_Public_Comment_Transparency%20%26%20Consent%20Framework%20-%20cookie%20and%20vendor%20list%20format%
2525
* 20specification%20v1.0a.pdf
2626
*
27+
* @deprecated This is deprecated and will be removed in future versions
28+
* Use {@link com.iab.gdpr.consent.VendorConsentDecoder} to decode vendor consent string
29+
* Use {@link com.iab.gdpr.consent.implementation.v1.VendorConsentBuilder} to build version 1 consent string
30+
* Use {@link com.iab.gdpr.consent.VendorConsentEncoder} to encode vendor consent to string
31+
*
2732
*/
2833
@Deprecated
2934
public class VendorConsent {

src/main/java/com/iab/gdpr/consent/implementation/v1/VendorConsentBuilder.java

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
import com.iab.gdpr.Purpose;
66
import com.iab.gdpr.consent.range.RangeEntry;
77
import com.iab.gdpr.consent.VendorConsent;
8+
import com.iab.gdpr.exception.VendorConsentCreateException;
89

910
import java.time.Instant;
1011
import java.util.*;
@@ -195,16 +196,16 @@ public VendorConsent build() {
195196
Objects.requireNonNull(consentLanguage, "consentLanguage must be set");
196197

197198
if (vendorListVersion <=0 )
198-
throw new IllegalStateException("Invalid value for vendorListVersion:" + vendorListVersion);
199+
throw new VendorConsentCreateException("Invalid value for vendorListVersion:" + vendorListVersion);
199200

200201
if (maxVendorId <=0 )
201-
throw new IllegalStateException("Invalid value for maxVendorId:" + maxVendorId);
202+
throw new VendorConsentCreateException("Invalid value for maxVendorId:" + maxVendorId);
202203

203204
// For range encoding, check if each range entry is valid
204205
if (vendorEncodingType == VENDOR_ENCODING_RANGE) {
205206
Objects.requireNonNull(rangeEntries, "Range entries must be set");
206207
final boolean invalidRangeEntriesFound = rangeEntries.stream().anyMatch(rangeEntry -> !rangeEntry.valid(maxVendorId));
207-
if (invalidRangeEntriesFound) throw new IllegalStateException("Invalid range entries found");
208+
if (invalidRangeEntriesFound) throw new VendorConsentCreateException("Invalid range entries found");
208209
}
209210

210211
// Calculate size of bit buffer in bits

src/main/java/com/iab/gdpr/util/ConsentStringParser.java

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,8 @@
4242
* https://github.com/InteractiveAdvertisingBureau/GDPR-Transparency-and-Consent-Framework/blob/master/
4343
* Draft_for_Public_Comment_Transparency%20%26%20Consent%20Framework%20-%20cookie%20and%20vendor%20list%20format%
4444
* 20specification%20v1.0a.pdf
45+
*
46+
* @deprecated Please use {@link com.iab.gdpr.consent.VendorConsentDecoder} instead
4547
*/
4648
@Deprecated
4749
public class ConsentStringParser {

src/test/java/com/iab/gdpr/consent/implementation/v1/VendorConsentBuilderTest.java

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
import com.iab.gdpr.consent.range.SingleRangeEntry;
66
import com.iab.gdpr.consent.range.StartEndRangeEntry;
77
import com.iab.gdpr.consent.VendorConsent;
8+
import com.iab.gdpr.exception.VendorConsentCreateException;
89
import org.junit.Before;
910
import org.junit.Test;
1011

@@ -53,7 +54,7 @@ public void testInvalidVendorEncodingType() {
5354
// Then: exception is thrown
5455
}
5556

56-
@Test(expected = IllegalStateException.class)
57+
@Test(expected = VendorConsentCreateException.class)
5758
public void testInvalidVendorListVersion() {
5859
// Given: invalid vendor list version - 50
5960
int vendorListVersion = -50;
@@ -69,7 +70,7 @@ public void testInvalidVendorListVersion() {
6970
// Then: exception is thrown
7071
}
7172

72-
@Test(expected = IllegalStateException.class)
73+
@Test(expected = VendorConsentCreateException.class)
7374
public void testInvalidMaxVendorId() {
7475
// Given: invalid max vendor ID = -1
7576
int maxVendorId = -1;
@@ -86,7 +87,7 @@ public void testInvalidMaxVendorId() {
8687
// Then: exception is thrown
8788
}
8889

89-
@Test(expected = IllegalStateException.class)
90+
@Test(expected = VendorConsentCreateException.class)
9091
public void testInvalidRangeEntry() {
9192
// Given: max vendor ID of 300;
9293
int maxVendorId = 300;
@@ -178,7 +179,7 @@ public void testValidRangedEncoding() {
178179
final String consentLanguage = "FR";
179180
final int vendorListVersion = 231;
180181
final int maxVendorId = 400;
181-
final int vendorEncodingType = 1; // Bit field
182+
final int vendorEncodingType = 1;
182183
final List<RangeEntry> rangeEntries = Arrays.asList(
183184
new SingleRangeEntry(10),
184185
new StartEndRangeEntry(100,200),

0 commit comments

Comments
 (0)