• BlackBerry Dynamics
  • Runtime library for Android applications
  • 11.0.1.140
BBCustomInterceptor Class Reference

Support for OkHttp. More...

Inherits Interceptor.

Description

This class provides support for the OkHttp HTTP framework, by means of an Interceptor that can be added when creating an OkHttpClient object. The Interceptor directs HTTP requests through the BlackBerry Dynamics secure communications system.

BBCustomInterceptor bbCustomInterceptor = new BBCustomInterceptor();
OkHttpClient httpClient = new OkHttpClient().newBuilder()
.addInterceptor(bbCustomInterceptor)
.authenticator(myAuthenticator) // optional Authenticator
.build();
// if Authenticator support is required
bbCustomInterceptor.initAuthenticatorSupport(httpClient);
val request = Request.Builder().url(urlStr).build()
try (Response response = httpClient.newCall(request).execute()) {
return response.body().string();
}

In order to use OkHttp, it is necessary to include it as a dependency, thus:

dependencies {
implementation "com.squareup.okhttp3:okhttp:4.9.1"
implementation 'com.squareup.okio:okio:2.9.0'
}

Please note the following:

  1. Cryptographic operations in third party Authenticator implementations will not be subject to BlackBerry Dynamics FIPS policy.
  2. BBCustomInterceptor is not suitable for use as a Network Interceptor. That is, it should only be added to the OkHttpClient object via the addInterceptor() call.
  3. Proxy authentication via Authenticator is not currently supported.

Public Member Functions

void initAuthenticatorSupport (OkHttpClient client)
 Method to enable Authenticator support.
 
void disablePeerVerification ()
 Method to disable Peer verification for your server.
 
void disableHostVerification ()
 Method to disable Host verification for your server.
 
void setAllowRedirects (boolean allowRedirect)
 API method to enable/disable redirects. More...
 
void setCookieJar (CookieJar cookieJar)
 API method to set CookieJar to BBCustomInterceptor More...
 

Member Function Documentation

◆ setAllowRedirects()

void setAllowRedirects ( boolean  allowRedirect)

All redirects are allowed by default.

Parameters
allowRedirect- false to disable redirects, true to enable redirects.

◆ setCookieJar()

void setCookieJar ( CookieJar  cookieJar)
Parameters
cookieJar- BBCookieJar to be set.