正在查看: Oolka v2.4.42 应用的 ApiClient.java JAVA 源代码文件
本页面展示 JAVA 反编译生成的源代码文件,支持语法高亮显示。 仅供安全研究与技术分析使用,严禁用于任何非法用途。请遵守相关法律法规。
正在查看: Oolka v2.4.42 应用的 ApiClient.java JAVA 源代码文件
本页面展示 JAVA 反编译生成的源代码文件,支持语法高亮显示。 仅供安全研究与技术分析使用,严禁用于任何非法用途。请遵守相关法律法规。
package co.hyperverge.hypersnapsdk.data.remote;
import co.hyperverge.hypersnapsdk.HyperSnapSDK;
import co.hyperverge.hypersnapsdk.analytics.mixpanel.network.MixPanelApiInterface;
import co.hyperverge.hypersnapsdk.helpers.SDKInternalConfig;
import co.hyperverge.hypersnapsdk.objects.HyperSnapSDKConfig;
import co.hyperverge.hypersnapsdk.utils.HVLogUtils;
import java.util.concurrent.TimeUnit;
import okhttp3.Cache;
import okhttp3.CertificatePinner;
import okhttp3.OkHttpClient;
import retrofit2.Retrofit;
public class ApiClient {
private static final String IND_DOCS_PATTERN = "ind.docs.hyperverge.co";
private static final String IND_FACE_ID_PATTERN = "ind.faceid.hyperverge.co";
private static final String SHA_1 = "sha256/hHWXbXBGT2chaVwYyxEyGqtPJX9H/dh5HbOAz5CmclM=";
private static final String SHA_2 = "sha256/8Rw90Ej3Ttt8RRkrg+WYDS9n7IS03bk5bjP/UXPtaY8=";
private static final String SHA_3 = "sha256/Ko8tivDrEjiY90yGasP6ZpBU4jwXvHqVvQI0GS3GNdA=";
private static final String SHA_4 = "sha256/C3U1B8/WXNaje+K8wU4TRgV0htiLVH9gikN4+kwR+P4=";
private static final String STAGING_API_PATTERN = "staging.api.hyperverge.co";
private static final String TAG = "co.hyperverge.hypersnapsdk.data.remote.ApiClient";
private static final String WILD_CARD_PATTERN = "*.hyperverge.co";
private static ApiInterface apiService;
private static DocsApiInterface docsService;
private static MixPanelApiInterface mixPanelApiService;
private static RemoteConfigApiInterface remoteConfigApiInterfaceService;
private static SensorDataInterface sensorDataInterface;
private final long CACHE_SIZE = 5242880;
private ApiClient() {
}
private static void configureTimeouts(OkHttpClient.Builder builder) {
HVLogUtils.d(TAG, "configureTimeouts() called with: client = [" + builder + "]");
long readTimeOut = (long) HyperSnapSDK.getInstance().getHyperSnapSDKConfig().getReadTimeOut();
TimeUnit timeUnit = TimeUnit.SECONDS;
builder.readTimeout(readTimeOut, timeUnit);
builder.writeTimeout((long) HyperSnapSDK.getInstance().getHyperSnapSDKConfig().getWriteTimeOut(), timeUnit);
builder.connectTimeout(HyperSnapSDK.getInstance().getHyperSnapSDKConfig().getConnectTimeOut(), timeUnit);
}
public static DocsApiInterface getDocsService() {
HVLogUtils.d(TAG, "getDocsService() called");
if (docsService == null) {
OkHttpClient.Builder builder = new OkHttpClient.Builder();
configureTimeouts(builder);
docsService = (DocsApiInterface) new Retrofit.Builder().b(SDKInternalConfig.getInstance().getDocsBaseUrl()).f(builder.build()).a(retrofit2.converter.gson.a.f()).d().b(DocsApiInterface.class);
}
return docsService;
}
public static MixPanelApiInterface getMixPanelService() {
HVLogUtils.d(TAG, "getMixPanelService() called");
if (mixPanelApiService == null) {
HyperSnapSDKConfig hyperSnapSDKConfig = HyperSnapSDK.getInstance().getHyperSnapSDKConfig();
OkHttpClient.Builder builder = new OkHttpClient.Builder();
long connectTimeOut = hyperSnapSDKConfig.getConnectTimeOut();
TimeUnit timeUnit = TimeUnit.SECONDS;
builder.connectTimeout(connectTimeOut, timeUnit);
builder.writeTimeout(hyperSnapSDKConfig.getWriteTimeOut(), timeUnit);
builder.readTimeout(hyperSnapSDKConfig.getReadTimeOut(), timeUnit);
mixPanelApiService = (MixPanelApiInterface) new Retrofit.Builder().b(SDKInternalConfig.getInstance().getMixPanelBaseUrl()).a(retrofit2.converter.gson.a.f()).f(builder.build()).d().b(MixPanelApiInterface.class);
}
return mixPanelApiService;
}
public static RemoteConfigApiInterface getRemoteConfigService(Cache cache) {
HVLogUtils.d(TAG, "getRemoteConfigService() called with: cacheDir = [" + cache + "]");
if (remoteConfigApiInterfaceService == null) {
OkHttpClient.Builder builder = new OkHttpClient.Builder();
configureTimeouts(builder);
remoteConfigApiInterfaceService = (RemoteConfigApiInterface) new Retrofit.Builder().b(SDKInternalConfig.getInstance().getS3RemoteConfigBaseUrl()).f(builder.cache(cache).build()).a(retrofit2.converter.gson.a.f()).d().b(RemoteConfigApiInterface.class);
}
return remoteConfigApiInterfaceService;
}
public static SensorDataInterface getSensorDataInterface() {
if (sensorDataInterface == null) {
configureTimeouts(new OkHttpClient.Builder());
sensorDataInterface = (SensorDataInterface) new Retrofit.Builder().b("https://armxjib6ub.execute-api.ap-southeast-1.amazonaws.com").a(retrofit2.converter.gson.a.f()).d().b(SensorDataInterface.class);
}
return sensorDataInterface;
}
public static ApiInterface getService() {
HVLogUtils.d(TAG, "getService() called");
if (apiService == null) {
OkHttpClient.Builder builder = new OkHttpClient.Builder();
configureTimeouts(builder);
if (HyperSnapSDK.getInstance().getHyperSnapSDKConfig().isShouldEnableSSLPinning()) {
builder.certificatePinner(new CertificatePinner.Builder().add(IND_FACE_ID_PATTERN, new String[]{SHA_1}).add(IND_FACE_ID_PATTERN, new String[]{SHA_2}).add(IND_FACE_ID_PATTERN, new String[]{SHA_3}).add(IND_DOCS_PATTERN, new String[]{SHA_1}).add(IND_DOCS_PATTERN, new String[]{SHA_2}).add(IND_DOCS_PATTERN, new String[]{SHA_3}).add(STAGING_API_PATTERN, new String[]{SHA_1}).add(STAGING_API_PATTERN, new String[]{SHA_2}).add(STAGING_API_PATTERN, new String[]{SHA_3}).add(WILD_CARD_PATTERN, new String[]{SHA_4}).add(WILD_CARD_PATTERN, new String[]{SHA_2}).add(WILD_CARD_PATTERN, new String[]{SHA_3}).build());
}
apiService = (ApiInterface) new Retrofit.Builder().b(SDKInternalConfig.getInstance().getFaceBaseUrl()).f(builder.build()).a(retrofit2.converter.gson.a.f()).d().b(ApiInterface.class);
}
return apiService;
}
}