what-the-bank/sources/com/kofax/mobile/sdk/aa/g.java

106 lines
3.9 KiB
Java

package com.kofax.mobile.sdk.aa;
import com.google.common.net.HttpHeaders;
import com.google.firebase.crashlytics.internal.common.AbstractSpiCall;
import com.kofax.kmc.kut.utilities.CertificateValidatorListener;
import com.kofax.kmc.kut.utilities.LicensingVolume;
import com.kofax.kmc.kut.utilities.error.ErrorInfo;
import com.kofax.mobile.sdk._internal.k;
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.OutputStreamWriter;
import java.net.HttpURLConnection;
import java.net.URL;
import java.util.concurrent.Callable;
/* loaded from: classes3.dex */
class g implements Callable<LicensingVolume.LicenseResults> {
private static final String TAG = "g";
b Tw;
String Tx;
String url;
@Override // java.util.concurrent.Callable
/* renamed from: qP, reason: merged with bridge method [inline-methods] */
public LicensingVolume.LicenseResults call() throws Exception {
return a(this.url, this.Tw, this.Tx);
}
private static LicensingVolume.LicenseResults a(String str, b bVar, String str2) {
LicensingVolume.LicenseResults licenseResults = new LicensingVolume.LicenseResults(ErrorInfo.KMC_SUCCESS);
String str3 = null;
try {
HttpURLConnection a = a(str, bVar, str2, f.certificateValidatorListener);
a.connect();
BufferedReader bufferedReader = new BufferedReader(new InputStreamReader(a.getInputStream()));
StringBuilder sb = new StringBuilder();
while (true) {
String readLine = bufferedReader.readLine();
if (readLine == null) {
break;
}
sb.append(readLine);
sb.append(" ");
}
str3 = sb.toString();
bufferedReader.close();
} catch (IOException e) {
ErrorInfo errorInfo = ErrorInfo.KMC_UT_LICENSING_NETWORK_EXCEPTION;
errorInfo.setErrCause(e.getMessage());
licenseResults.errorInfo = errorInfo;
}
licenseResults.result = str3;
return licenseResults;
}
private static HttpURLConnection a(String str, b bVar, String str2, CertificateValidatorListener certificateValidatorListener) throws IOException {
OutputStreamWriter outputStreamWriter;
try {
HttpURLConnection a = com.kofax.mobile.sdk.ak.d.a(new URL(str), certificateValidatorListener);
a.setRequestMethod(str2);
a.setDoInput(true);
a.setRequestProperty(HttpHeaders.CONTENT_TYPE, AbstractSpiCall.ACCEPT_JSON_VALUE);
a.setConnectTimeout(30000);
a.setReadTimeout(30000);
outputStreamWriter = new OutputStreamWriter(a.getOutputStream());
try {
outputStreamWriter.write(String.format("{\"Key1\":\"%s\",\"Key2\":\"%s\", \"Licenses\": [%s]}", bVar.SU, bVar.SV, a(bVar)));
outputStreamWriter.flush();
try {
outputStreamWriter.close();
} catch (IOException e) {
k.d(e);
}
return a;
} catch (Throwable th) {
th = th;
if (outputStreamWriter != null) {
try {
outputStreamWriter.close();
} catch (IOException e2) {
k.d(e2);
}
}
throw th;
}
} catch (Throwable th2) {
th = th2;
outputStreamWriter = null;
}
}
private static String a(b bVar) {
StringBuilder sb = new StringBuilder();
int i = 0;
for (a aVar : bVar.ST) {
if (i > 0) {
sb.append(",");
}
sb.append(String.format("{\"Id\":\"%d\",\"Count\":\"%d\"}", Integer.valueOf(aVar.SR), Integer.valueOf(aVar.SS)));
i++;
}
return sb.toString();
}
}