Skip to content

Commit 3bcf542

Browse files
authored
Merge pull request #89 from CleverTap/update/jdk8u252-fix
Support for JDK8u252+ and E2E tests for it
2 parents 4b96d76 + c222663 commit 3bcf542

File tree

8 files changed

+595
-89
lines changed

8 files changed

+595
-89
lines changed

pom.xml

Lines changed: 35 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@
1919
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
2020
<maven.compiler.source>1.8</maven.compiler.source>
2121
<maven.compiler.target>${maven.compiler.source}</maven.compiler.target>
22+
<okhttp.version>4.8.1</okhttp.version>
2223
</properties>
2324

2425
<dependencyManagement>
@@ -55,8 +56,23 @@
5556
<dependency>
5657
<groupId>com.squareup.okhttp3</groupId>
5758
<artifactId>okhttp</artifactId>
58-
<version>3.2.0</version>
59+
<version>${okhttp.version}</version>
5960
</dependency>
61+
62+
<dependency>
63+
<groupId>com.squareup.okhttp3</groupId>
64+
<artifactId>mockwebserver</artifactId>
65+
<version>${okhttp.version}</version>
66+
<scope>test</scope>
67+
</dependency>
68+
69+
<dependency>
70+
<groupId>com.squareup.okhttp3</groupId>
71+
<artifactId>okhttp-tls</artifactId>
72+
<version>${okhttp.version}</version>
73+
<scope>test</scope>
74+
</dependency>
75+
6076
<dependency>
6177
<groupId>org.junit.jupiter</groupId>
6278
<artifactId>junit-jupiter</artifactId>
@@ -109,27 +125,27 @@
109125
<version>2.1.2</version>
110126
<executions>
111127
<execution>
112-
<id>attach-sources</id>
113-
<goals>
114-
<goal>jar-no-fork</goal>
115-
</goals>
128+
<id>attach-sources</id>
129+
<goals>
130+
<goal>jar-no-fork</goal>
131+
</goals>
116132
</execution>
117-
</executions>
133+
</executions>
118134
</plugin>
119135
<plugin>
120-
<groupId>org.apache.maven.plugins</groupId>
121-
<artifactId>maven-javadoc-plugin</artifactId>
122-
<version>2.7</version>
123-
<executions>
124-
<execution>
125-
<id>attach-javadocs</id>
126-
<goals>
127-
<goal>jar</goal>
128-
</goals>
129-
</execution>
130-
</executions>
136+
<groupId>org.apache.maven.plugins</groupId>
137+
<artifactId>maven-javadoc-plugin</artifactId>
138+
<version>2.7</version>
139+
<executions>
140+
<execution>
141+
<id>attach-javadocs</id>
142+
<goals>
143+
<goal>jar</goal>
144+
</goals>
145+
</execution>
146+
</executions>
131147
</plugin>
132-
<!-- this plugin is for creating fat jar (jar with embedded dependencies). -->
148+
<!-- this plugin is for creating fat jar (jar with embedded dependencies). -->
133149
<plugin>
134150
<groupId>org.apache.maven.plugins</groupId>
135151
<artifactId>maven-assembly-plugin</artifactId>
@@ -181,4 +197,4 @@
181197
<url>https://opensource.org/licenses/BSD-3-Clause</url>
182198
</license>
183199
</licenses>
184-
</project>
200+
</project>

src/main/java/com/clevertap/apns/clients/ApnsClientBuilder.java

Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@
3131
package com.clevertap.apns.clients;
3232

3333
import com.clevertap.apns.ApnsClient;
34+
import com.clevertap.apns.exceptions.InvalidTrustManagerException;
3435
import okhttp3.ConnectionPool;
3536
import okhttp3.OkHttpClient;
3637
import okhttp3.OkHttpClient.Builder;
@@ -52,6 +53,7 @@ public class ApnsClientBuilder {
5253
private boolean production;
5354
private String password;
5455
private int connectionPort = 443;
56+
private String gatewayUrl;
5557

5658
private boolean asynchronous = false;
5759
private String defaultTopic = null;
@@ -169,9 +171,14 @@ public ApnsClientBuilder withDefaultTopic(String defaultTopic) {
169171
return this;
170172
}
171173

174+
public ApnsClientBuilder withGatewayUrl(String url) {
175+
this.gatewayUrl = url;
176+
return this;
177+
}
178+
172179
public ApnsClient build() throws CertificateException,
173180
NoSuchAlgorithmException, KeyStoreException, IOException,
174-
UnrecoverableKeyException, KeyManagementException {
181+
UnrecoverableKeyException, KeyManagementException, InvalidTrustManagerException {
175182

176183
if (builder == null) {
177184
builder = createDefaultOkHttpClientBuilder();
@@ -183,15 +190,15 @@ public ApnsClient build() throws CertificateException,
183190

184191
if (certificate != null) {
185192
if (asynchronous) {
186-
return new AsyncOkHttpApnsClient(certificate, password, production, defaultTopic, builder, connectionPort);
193+
return new AsyncOkHttpApnsClient(certificate, password, production, defaultTopic, builder, connectionPort, gatewayUrl);
187194
} else {
188-
return new SyncOkHttpApnsClient(certificate, password, production, defaultTopic, builder, connectionPort);
195+
return new SyncOkHttpApnsClient(certificate, password, production, defaultTopic, builder, connectionPort, gatewayUrl);
189196
}
190197
} else if (keyID != null && teamID != null && apnsAuthKey != null) {
191198
if (asynchronous) {
192-
return new AsyncOkHttpApnsClient(apnsAuthKey, teamID, keyID, production, defaultTopic, builder, connectionPort);
199+
return new AsyncOkHttpApnsClient(apnsAuthKey, teamID, keyID, production, defaultTopic, builder, connectionPort, gatewayUrl);
193200
} else {
194-
return new SyncOkHttpApnsClient(apnsAuthKey, teamID, keyID, production, defaultTopic, builder, connectionPort);
201+
return new SyncOkHttpApnsClient(apnsAuthKey, teamID, keyID, production, defaultTopic, builder, connectionPort, gatewayUrl);
195202
}
196203
} else {
197204
throw new IllegalArgumentException("Either the token credentials (team ID, key ID, and the private key) " +

src/main/java/com/clevertap/apns/clients/AsyncOkHttpApnsClient.java

Lines changed: 19 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@
3333
import com.clevertap.apns.Notification;
3434
import com.clevertap.apns.NotificationResponse;
3535
import com.clevertap.apns.NotificationResponseListener;
36+
import com.clevertap.apns.exceptions.InvalidTrustManagerException;
3637
import okhttp3.*;
3738

3839
import java.io.IOException;
@@ -56,7 +57,7 @@ public AsyncOkHttpApnsClient(String apnsAuthKey, String teamID, String keyID,
5657
public AsyncOkHttpApnsClient(InputStream certificate, String password, boolean production,
5758
String defaultTopic, ConnectionPool connectionPool)
5859
throws CertificateException, NoSuchAlgorithmException, KeyStoreException,
59-
IOException, UnrecoverableKeyException, KeyManagementException {
60+
IOException, UnrecoverableKeyException, KeyManagementException, InvalidTrustManagerException {
6061
super(certificate, password, production, defaultTopic, connectionPool);
6162
}
6263

@@ -65,23 +66,36 @@ public AsyncOkHttpApnsClient(String apnsAuthKey, String teamID, String keyID,
6566
this(apnsAuthKey, teamID, keyID, production, defaultTopic, builder, 443);
6667
}
6768

69+
public AsyncOkHttpApnsClient(String apnsAuthKey, String teamID, String keyID,
70+
boolean production, String defaultTopic, OkHttpClient.Builder builder, int connectionPort,
71+
String gatewayUrl) {
72+
super(apnsAuthKey, teamID, keyID, production, defaultTopic, builder, gatewayUrl);
73+
}
74+
6875
public AsyncOkHttpApnsClient(String apnsAuthKey, String teamID, String keyID,
6976
boolean production, String defaultTopic, OkHttpClient.Builder builder, int connectionPort) {
70-
super(apnsAuthKey, teamID, keyID, production, defaultTopic, builder);
77+
this(apnsAuthKey, teamID, keyID, production, defaultTopic, builder, 443, null);
7178
}
7279

7380
public AsyncOkHttpApnsClient(InputStream certificate, String password, boolean production,
7481
String defaultTopic, OkHttpClient.Builder builder)
7582
throws CertificateException, NoSuchAlgorithmException, KeyStoreException,
76-
IOException, UnrecoverableKeyException, KeyManagementException {
83+
IOException, UnrecoverableKeyException, KeyManagementException, InvalidTrustManagerException {
7784
this(certificate, password, production, defaultTopic, builder, 443);
7885
}
7986

87+
public AsyncOkHttpApnsClient(InputStream certificate, String password, boolean production,
88+
String defaultTopic, OkHttpClient.Builder builder, int connectionPort, String gatewayUrl)
89+
throws CertificateException, NoSuchAlgorithmException, KeyStoreException,
90+
IOException, UnrecoverableKeyException, KeyManagementException, InvalidTrustManagerException {
91+
super(certificate, password, production, defaultTopic, builder, gatewayUrl);
92+
}
93+
8094
public AsyncOkHttpApnsClient(InputStream certificate, String password, boolean production,
8195
String defaultTopic, OkHttpClient.Builder builder, int connectionPort)
8296
throws CertificateException, NoSuchAlgorithmException, KeyStoreException,
83-
IOException, UnrecoverableKeyException, KeyManagementException {
84-
super(certificate, password, production, defaultTopic, builder);
97+
IOException, UnrecoverableKeyException, KeyManagementException, InvalidTrustManagerException {
98+
this(certificate, password, production, defaultTopic, builder, 443, null);
8599
}
86100

87101
@Override

0 commit comments

Comments
 (0)