Skip to content

Commit 15f22e7

Browse files
author
Andrew Tivodar
authored
Hotfix: Added support for custom HostnameVerifier and SSLSocketFactory (#132)
* Added support for custom HostnameVerifier and SSLSocketFactory (#131) * Changed SDK version to 2.5.1 release
1 parent fbb1562 commit 15f22e7

File tree

2 files changed

+30
-1
lines changed

2 files changed

+30
-1
lines changed

build.gradle

+1-1
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ buildscript {
3636
subprojects {
3737
group = 'com.jaspersoft.android.sdk'
3838

39-
ext.clientModuleVersion = '2.5'
39+
ext.clientModuleVersion = '2.5.1'
4040
ext.jacocoVersion = '0.7.6.201602180812'
4141

4242
repositories {

core/src/main/java/com/jaspersoft/android/sdk/network/Server.java

+29
Original file line numberDiff line numberDiff line change
@@ -27,13 +27,17 @@
2727
import com.jaspersoft.android.sdk.network.entity.type.GsonFactory;
2828
import com.squareup.okhttp.Authenticator;
2929
import com.squareup.okhttp.OkHttpClient;
30+
3031
import org.jetbrains.annotations.NotNull;
3132
import org.jetbrains.annotations.Nullable;
3233

3334
import java.net.CookieHandler;
3435
import java.net.Proxy;
3536
import java.util.concurrent.TimeUnit;
3637

38+
import javax.net.ssl.HostnameVerifier;
39+
import javax.net.ssl.SSLSocketFactory;
40+
3741
/**
3842
* Represents particular Server configuration.
3943
* With corresponding API you can configure two types of clients.
@@ -144,6 +148,31 @@ public Builder withProxy(Proxy proxy) {
144148
return this;
145149
}
146150

151+
152+
/**
153+
* Sets the verifier used to confirm that response certificates apply to
154+
* requested hostnames for HTTPS connections.
155+
*
156+
* @param hostnameVerifier your hostname verifier
157+
* @return builder for convenient configuration
158+
*/
159+
public Builder withHostnameVerifier(HostnameVerifier hostnameVerifier) {
160+
mOkHttpClient.setHostnameVerifier(hostnameVerifier);
161+
return this;
162+
}
163+
164+
/**
165+
*Sets the socket factory used to secure HTTPS connections.
166+
*If unset, a lazily created SSL socket factory will be used.
167+
*
168+
* @param sslSocketFactory your ssl socket factory
169+
* @return builder for convenient configuration
170+
*/
171+
public Builder withSslSocketFactory(SSLSocketFactory sslSocketFactory) {
172+
mOkHttpClient.setSslSocketFactory(sslSocketFactory);
173+
return this;
174+
}
175+
147176
public Server build() {
148177
Utils.checkNotNull(mBaseUrl, "Server can not be created with null base url");
149178

0 commit comments

Comments
 (0)