正在查看: Minits v4.9.3.32 应用的 SOAConnection.java JAVA 源代码文件
本页面展示 JAVA 反编译生成的源代码文件,支持语法高亮显示。 仅供安全研究与技术分析使用,严禁用于任何非法用途。请遵守相关法律法规。
正在查看: Minits v4.9.3.32 应用的 SOAConnection.java JAVA 源代码文件
本页面展示 JAVA 反编译生成的源代码文件,支持语法高亮显示。 仅供安全研究与技术分析使用,严禁用于任何非法用途。请遵守相关法律法规。
package com.xone.db.soa;
import Fb.d;
import Fb.j;
import Fb.l;
import android.annotation.SuppressLint;
import android.content.ContentValues;
import android.content.Context;
import android.text.TextUtils;
import android.util.Base64;
import android.util.Pair;
import androidx.annotation.Keep;
import ca.e;
import com.xone.android.utils.Utils;
import com.xone.db.commons.TokenData;
import com.xone.db.commons.a;
import com.xone.db.commons.b;
import com.xone.db.commons.g;
import com.xone.db.soa.SOAConnection;
import com.xone.interfaces.IXoneObject;
import da.AbstractC0593a;
import fa.ThreadFactoryC0686d;
import fb.q;
import fb.t;
import fb.v;
import ha.AbstractC0751f;
import j$.util.DesugarTimeZone;
import java.io.ByteArrayOutputStream;
import java.io.Closeable;
import java.io.File;
import java.io.InputStream;
import java.io.InterruptedIOException;
import java.io.OutputStream;
import java.io.OutputStreamWriter;
import java.lang.ref.WeakReference;
import java.net.HttpURLConnection;
import java.net.URL;
import java.security.MessageDigest;
import java.security.NoSuchAlgorithmException;
import java.security.SecureRandom;
import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.HashSet;
import java.util.List;
import java.util.Map;
import java.util.UUID;
import java.util.concurrent.Callable;
import java.util.concurrent.CancellationException;
import java.util.concurrent.CopyOnWriteArrayList;
import java.util.concurrent.ExecutionException;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;
import java.util.concurrent.Future;
import java.util.concurrent.TimeUnit;
import java.util.concurrent.TimeoutException;
import org.json.JSONObject;
import pa.C0968h;
import pa.C0969i;
import ua.C1019d;
@Keep
public final class SOAConnection implements b {
private static final char[] CHARACTERS = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/".toCharArray();
public static final int FLAG_XONEJSONCUSTOM = 4;
public static final int FLAG_XONEJSONODATA = 2;
public static final int FLAG_XONEJSONSQL = 1;
private boolean bStartTrans;
private final boolean bUseRemoteBroker;
private final Context context;
private ExecutorService executor;
private final File fLocalCertPath;
private int nFlags;
private final int nTimeout;
private final String sBasicHttpPassword;
private final String sBasicHttpUsername;
private final String sContentType;
private String sHttpMethod;
private final String sPassword;
private final String sRemoteDest;
private final String sRemoteMapped;
private String sSessionId;
private String sSoaAction;
private String sSoaNamespace;
private String sUrlAddress;
private final String sUserAgent;
private final String sUsername;
private String sXmlVersionTag;
private C0968h statementTrans;
private int nTransCounter = 0;
private final List<WeakReference<Future<Object>>> lstTasks = new CopyOnWriteArrayList();
@Keep
public SOAConnection(String str, Context context, String str2, String str3) {
this.nFlags = 1;
this.context = context.getApplicationContext();
Map s = a.s(str);
int i = this.nFlags & (Boolean.parseBoolean((String) s.get("odataformat")) ? 2 : 1);
this.nFlags = i;
this.nFlags = i & (Boolean.parseBoolean((String) s.get("customformat")) ? 4 : 1);
this.nTimeout = q.p(s.get("timeout"), 60);
String str4 = (String) s.get("data source");
this.sUrlAddress = str4;
if (str4 != null) {
String trim = str4.trim();
this.sUrlAddress = trim;
if (trim.endsWith("?")) {
String str5 = this.sUrlAddress;
this.sUrlAddress = str5.substring(0, str5.length() - 1);
}
}
this.sContentType = (String) s.get("content type");
String str6 = (String) s.get("method");
this.sHttpMethod = str6;
if (str6 == null) {
this.sHttpMethod = "POST";
}
this.sUsername = (String) s.get("username");
this.sPassword = (String) s.get("password");
this.sBasicHttpUsername = (String) s.get("basichttpusername");
this.sBasicHttpPassword = (String) s.get("basichttppassword");
String str7 = (String) s.get("namespace");
this.sSoaNamespace = str7;
if (str7 == null) {
this.sSoaNamespace = "";
}
String str8 = (String) s.get("soapaction");
this.sSoaAction = str8;
if (str8 == null) {
this.sSoaAction = "";
}
if (Boolean.parseBoolean((String) s.get("addversiontag"))) {
this.sXmlVersionTag = "<?xml version=\"1.0\" encoding=\"utf-8\"?>";
}
this.fLocalCertPath = Boolean.parseBoolean((String) s.get("enablecertificatepinning")) ? getCertificatePath(s, str3) : null;
this.bUseRemoteBroker = t.l((String) s.get("remote broker"), false);
this.sRemoteMapped = t.y(s.get("remote mapped"));
this.sRemoteDest = t.y(s.get("remote destination"));
this.sUserAgent = v.d(context);
}
private Object doBrokerRequest(String str, String str2, String str3, l lVar, String str4, List<Pair<String, String>> list) {
OutputStream outputStream;
InputStream inputStream;
InputStream inputStream2;
?? r3;
HttpURLConnection httpURLConnection;
l lVar2;
InputStream inputStream3;
InputStream inputStream4;
InputStream inputStream5;
HttpURLConnection httpURLConnection2 = null;
try {
URL url = new URL(str);
Utils.l("XOneAndroidFramework", "URL: " + url);
Utils.l("XOneAndroidFramework", "Soap Method: " + str4);
if (lVar == null) {
lVar2 = new l(str2, str4);
for (Pair<String, String> pair : list) {
lVar2.d((String) pair.first, (String) pair.second);
}
} else {
lVar2 = lVar;
}
j jVar = new j(org.mozilla.javascript.Context.VERSION_1_2, lVar2, null, "<?xml version=\"1.0\" encoding=\"utf-8\"?>");
String U = t.U(jVar.e());
if (TextUtils.isEmpty(this.sSessionId)) {
this.sSessionId = UUID.randomUUID().toString().replace("-", "_");
}
pa.j jVar2 = new pa.j(this.sSessionId, this.sRemoteMapped, this.sRemoteDest, U, str3, null);
if (!TextUtils.isEmpty(U)) {
Utils.l("XOneAndroidFramework", "Request body: " + U);
}
File file = this.fLocalCertPath;
httpURLConnection = file != null ? AbstractC0593a.b(this.context, file, url, null) : (HttpURLConnection) url.openConnection();
try {
if (!Thread.currentThread().isInterrupted() && httpURLConnection != null) {
if (this.sHttpMethod.equals("POST")) {
httpURLConnection.setDoOutput(true);
}
httpURLConnection.setRequestMethod(this.sHttpMethod);
v.b(this.context, httpURLConnection);
httpURLConnection.setRequestProperty("Content-Language", "es");
httpURLConnection.setRequestProperty("Cache-Control", "no-cache");
httpURLConnection.setDefaultUseCaches(false);
httpURLConnection.setConnectTimeout(60000);
String f = jVar2.f();
Utils.l("XOneAndroidFramework", "Message JSON Body: " + f);
if (this.sHttpMethod.equals("POST")) {
httpURLConnection.setRequestProperty("Content-Length", String.valueOf(f.getBytes().length));
httpURLConnection.setRequestProperty("Content-Type", TextUtils.isEmpty(this.sContentType) ? "application/x-www-form-urlencoded" : this.sContentType);
outputStream = httpURLConnection.getOutputStream();
try {
r3 = new OutputStreamWriter(outputStream);
try {
r3.write(f);
r3.flush();
r3 = r3;
} catch (InterruptedIOException unused) {
inputStream2 = null;
Utils.r0(httpURLConnection);
Utils.P(new Closeable[]{inputStream2, outputStream, r3});
return null;
} catch (Exception e) {
e = e;
inputStream2 = null;
inputStream5 = r3;
httpURLConnection2 = httpURLConnection;
inputStream = inputStream5;
try {
throw AbstractC0751f.e(e);
} catch (Throwable th) {
th = th;
Utils.r0(httpURLConnection2);
Utils.P(inputStream2, outputStream, inputStream);
throw th;
}
} catch (Throwable th2) {
th = th2;
inputStream2 = null;
inputStream = r3;
httpURLConnection2 = httpURLConnection;
Utils.r0(httpURLConnection2);
Utils.P(inputStream2, outputStream, inputStream);
throw th;
}
} catch (InterruptedIOException unused2) {
r3 = 0;
inputStream2 = r3;
Utils.r0(httpURLConnection);
Utils.P(new Closeable[]{inputStream2, outputStream, r3});
return null;
} catch (Exception e2) {
e = e2;
inputStream4 = null;
inputStream2 = inputStream4;
inputStream5 = inputStream4;
httpURLConnection2 = httpURLConnection;
inputStream = inputStream5;
throw AbstractC0751f.e(e);
} catch (Throwable th3) {
th = th3;
inputStream3 = null;
inputStream2 = inputStream3;
inputStream = inputStream3;
httpURLConnection2 = httpURLConnection;
Utils.r0(httpURLConnection2);
Utils.P(inputStream2, outputStream, inputStream);
throw th;
}
} else {
outputStream = null;
r3 = 0;
}
int responseCode = httpURLConnection.getResponseCode();
if (responseCode != 200) {
throw new C0969i(responseCode, httpURLConnection);
}
inputStream2 = httpURLConnection.getInputStream();
try {
byte[] bArr = new byte[8192];
ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream();
while (true) {
int read = inputStream2.read(bArr);
if (-1 == read) {
Object parseResult = parseResult(jVar, byteArrayOutputStream.toString().trim());
Utils.r0(httpURLConnection);
Utils.P(new Closeable[]{inputStream2, outputStream, r3});
return parseResult;
}
byteArrayOutputStream.write(bArr, 0, read);
}
} catch (InterruptedIOException unused3) {
Utils.r0(httpURLConnection);
Utils.P(new Closeable[]{inputStream2, outputStream, r3});
return null;
} catch (Exception e3) {
e = e3;
inputStream5 = r3;
httpURLConnection2 = httpURLConnection;
inputStream = inputStream5;
throw AbstractC0751f.e(e);
} catch (Throwable th4) {
th = th4;
inputStream = r3;
httpURLConnection2 = httpURLConnection;
Utils.r0(httpURLConnection2);
Utils.P(inputStream2, outputStream, inputStream);
throw th;
}
}
Utils.r0(httpURLConnection);
Utils.P(null, null, null);
return null;
} catch (InterruptedIOException unused4) {
outputStream = null;
r3 = 0;
} catch (Exception e4) {
e = e4;
outputStream = null;
inputStream4 = null;
} catch (Throwable th5) {
th = th5;
outputStream = null;
inputStream3 = null;
}
} catch (InterruptedIOException unused5) {
outputStream = null;
r3 = 0;
httpURLConnection = null;
inputStream2 = null;
} catch (Exception e5) {
e = e5;
outputStream = null;
inputStream = null;
inputStream2 = null;
} catch (Throwable th6) {
th = th6;
outputStream = null;
inputStream = null;
inputStream2 = null;
}
}
private Object doHttpCall(Callable<Object> callable) {
if (this.executor == null) {
this.executor = Executors.newCachedThreadPool(new ThreadFactoryC0686d("SoapDownloadThread"));
}
Future submit = this.executor.submit(callable);
this.lstTasks.add(new WeakReference<>(submit));
try {
return submit.get(this.nTimeout, TimeUnit.SECONDS);
} catch (InterruptedException e) {
e = e;
throw AbstractC0751f.e(e);
} catch (CancellationException unused) {
return null;
} catch (ExecutionException e2) {
e = e2;
throw AbstractC0751f.e(e);
} catch (TimeoutException e3) {
e = e3;
throw AbstractC0751f.e(e);
}
}
private Object doKsoaRequest(String str, String str2, String str3, String str4, l lVar, String str5, List<Pair<String, String>> list, String str6, String str7) {
l lVar2;
if (lVar == null) {
lVar2 = new l(str3, str5);
for (Pair<String, String> pair : list) {
lVar2.d((String) pair.first, (String) pair.second);
}
} else {
lVar2 = lVar;
}
d dVar = new d(this.context, str, str2, null, str6, str7, this.sUserAgent, this.fLocalCertPath, new HashSet());
if (TextUtils.isEmpty(str4)) {
str4 = lVar2.f();
}
if (str4.endsWith("/")) {
str4 = str4 + lVar2.e();
}
return dVar.a(str4, lVar2, getSecurityHeader()).f();
}
private static String encodeBase64(byte[] bArr) {
int length = bArr.length;
StringBuilder sb2 = new StringBuilder((bArr.length * 3) / 2);
int i = length - 3;
int i2 = 0;
loop0: while (true) {
int i3 = 0;
while (i2 <= i) {
int i4 = ((bArr[i2] & 255) << 16) | ((bArr[i2 + 1] & 255) << 8) | (bArr[i2 + 2] & 255);
char[] cArr = CHARACTERS;
sb2.append(cArr[(i4 >> 18) & 63]);
sb2.append(cArr[(i4 >> 12) & 63]);
sb2.append(cArr[(i4 >> 6) & 63]);
sb2.append(cArr[i4 & 63]);
i2 += 3;
int i5 = i3 + 1;
if (i3 >= 14) {
break;
}
i3 = i5;
}
sb2.append("\r\n");
}
if (i2 == length - 2) {
int i6 = ((bArr[i2 + 1] & 255) << 8) | ((bArr[i2] & 255) << 16);
char[] cArr2 = CHARACTERS;
sb2.append(cArr2[(i6 >> 18) & 63]);
sb2.append(cArr2[(i6 >> 12) & 63]);
sb2.append(cArr2[(i6 >> 6) & 63]);
sb2.append("=");
} else if (i2 == length - 1) {
int i7 = (bArr[i2] & 255) << 16;
char[] cArr3 = CHARACTERS;
sb2.append(cArr3[(i7 >> 18) & 63]);
sb2.append(cArr3[(i7 >> 12) & 63]);
sb2.append("==");
}
return sb2.toString();
}
private static File getCertificatePath(Map<String, String> map, String str) {
if (map == null) {
return null;
}
String y = t.y(map.get("localcertificatepath"));
if (TextUtils.isEmpty(y)) {
return null;
}
File file = new File(str, "certificates/" + y);
if (file.exists() && file.isFile()) {
return file;
}
return null;
}
@SuppressLint({"SimpleDateFormat"})
private static String getCreationDate() {
SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss'Z'");
simpleDateFormat.setTimeZone(DesugarTimeZone.getTimeZone("GMT"));
return simpleDateFormat.format(new Date());
}
private static String getNewNonce() {
return String.valueOf(new SecureRandom().nextInt(90000000) + 10000000);
}
private static String getPasswordDigest(String str, String str2, String str3) {
try {
byte[] S = t.S(str2);
byte[] S2 = t.S(str3);
byte[] S3 = t.S(str);
MessageDigest messageDigest = MessageDigest.getInstance("SHA-1");
messageDigest.update(S, 0, S.length);
messageDigest.update(S2, 0, S2.length);
messageDigest.update(S3, 0, S3.length);
return encodeBase64(messageDigest.digest());
} catch (NoSuchAlgorithmException e) {
throw AbstractC0751f.e(e);
}
}
public Object lambda$downloadData$0(String str, List list) {
return doBrokerRequest(this.sUrlAddress + "/SendMessage/", this.sSoaNamespace, this.sSoaAction, null, str, list);
}
public Object lambda$downloadData$1(String str, List list) {
return doKsoaRequest(this.sUrlAddress, this.sXmlVersionTag, this.sSoaNamespace, this.sSoaAction, null, str, list, null, null);
}
public Object lambda$downloadData$2(l lVar) {
return doBrokerRequest(this.sUrlAddress, null, this.sSoaAction, lVar, "", null);
}
public Object lambda$downloadData$3(l lVar) {
return doKsoaRequest(this.sUrlAddress, this.sXmlVersionTag, null, this.sSoaAction, lVar, null, null, this.sBasicHttpUsername, this.sBasicHttpPassword);
}
private static Object parseResult(j jVar, String str) {
String string = new JSONObject(str).getString("data");
if (TextUtils.isEmpty(string)) {
Utils.l("XOneAndroidFramework", "Empty response.");
return null;
}
Utils.l("XOneAndroidFramework", string);
try {
jVar.h(string);
return jVar.f();
} catch (Exception e) {
e.printStackTrace();
return null;
}
}
@Override
public long LastInsertedRowId() {
return a.a(this);
}
@Override
public long LastRowsAffected() {
return a.b(this);
}
@Override
public boolean acceptsEmptyQueries() {
return a.c(this);
}
@Override
public boolean acceptsParsedSentences() {
return true;
}
@Override
public void beginTrans() {
this.bStartTrans = true;
if (this.statementTrans == null) {
this.statementTrans = new C0968h(this);
}
if (this.nTransCounter == 0) {
this.statementTrans.beginTrans();
}
this.nTransCounter++;
}
@Override
public void cancelProcesses(int i) {
Future<Object> future;
for (WeakReference<Future<Object>> weakReference : this.lstTasks) {
if (weakReference != null && (future = weakReference.get()) != null) {
future.cancel(true);
}
}
this.lstTasks.clear();
}
@Override
public void clearAuthenticationToken() {
a.g(this);
}
@Override
public void close() {
}
@Override
public Object commit() {
C0968h c0968h;
int i = this.nTransCounter - 1;
this.nTransCounter = i;
if (i > 0 || (c0968h = this.statementTrans) == null) {
return null;
}
c0968h.b();
return 0;
}
@Override
public g createStatement() {
return new C0968h(this);
}
@Override
public String decryptBlock(String str, String str2) {
return a.i(this, str, str2);
}
public Object downloadData(final String str, final List<Pair<String, String>> list) {
return this.bUseRemoteBroker ? doHttpCall(new Callable() {
@Override
public final Object call() {
Object lambda$downloadData$0;
lambda$downloadData$0 = SOAConnection.this.lambda$downloadData$0(str, list);
return lambda$downloadData$0;
}
}) : doHttpCall(new Callable() {
@Override
public final Object call() {
Object lambda$downloadData$1;
lambda$downloadData$1 = SOAConnection.this.lambda$downloadData$1(str, list);
return lambda$downloadData$1;
}
});
}
@Override
public Object execute(String str) {
ca.d dVar = new ca.d("ROWID");
dVar.F(str);
return execute(dVar);
}
@Override
public int executeOperation(e eVar, String str, ContentValues contentValues, String str2) {
return 0;
}
@Override
public com.xone.db.commons.d executeQuery(String str) {
return new C0968h(this).V0(str, 1000);
}
public int executeUpdate(String str) {
return 0;
}
public Map getCryptoData() {
return a.j(this);
}
public int getFlags() {
return this.nFlags;
}
public Fb.a getSecurityHeader() {
if (TextUtils.isEmpty(this.sUsername) || TextUtils.isEmpty(this.sPassword)) {
return null;
}
String newNonce = getNewNonce();
String creationDate = getCreationDate();
String passwordDigest = getPasswordDigest(this.sPassword, newNonce, creationDate);
Fb.a aVar = new Fb.a("", "wsse:Security");
aVar.o(null, "soap:mustUnderstand", "1");
aVar.o(null, "xmlns:wsse", "http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd");
aVar.o(null, "xmlns:wsu", "http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-utility-1.0.xsd");
Fb.a aVar2 = new Fb.a("", "wsse:UsernameToken");
aVar2.o(null, "wsu:Id", "UsernameToken-1");
Fb.a aVar3 = new Fb.a("", "wsse:Username");
aVar3.c(this.sUsername);
aVar2.a(aVar3);
Fb.a aVar4 = new Fb.a("", "wsse:Password");
aVar4.o(null, "Type", "http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-username-token-profile-1.0#PasswordDigest");
aVar4.c(passwordDigest);
aVar2.a(aVar4);
Fb.a aVar5 = new Fb.a("", "wsse:Nonce");
aVar5.o(null, "EncodingType", "http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-soap-message-security-1.0#Base64Binary");
aVar5.c(Base64.encodeToString(t.S(newNonce), 2));
aVar2.a(aVar5);
Fb.a aVar6 = new Fb.a("", "wsu:Created");
aVar6.c(creationDate);
aVar2.a(aVar6);
aVar.a(aVar2);
return aVar;
}
public String getSoaNamespace() {
return this.sSoaNamespace;
}
@Override
public TokenData getTokenFromAuth(String str, String str2) {
return a.k(this, str, str2);
}
public boolean isClosed() {
return a.l(this);
}
@Override
public boolean isCryptoSupported() {
return a.m(this);
}
public boolean outerJoinsSupported() {
return a.n(this);
}
@Override
public TokenData refreshAuthenticationToken() {
return a.o(this);
}
@Override
public void rollback() {
C0968h c0968h = this.statementTrans;
if (c0968h != null) {
c0968h.rollback();
}
this.nTransCounter = 0;
this.bStartTrans = false;
}
@Override
public void setCryptoData(Map map) {
a.q(this, map);
}
@Override
public void setOnTokenExpiredCallback(Object obj) {
a.r(this, obj);
}
public int executeUpdate(ca.d dVar) {
return 0;
}
@Override
public com.xone.db.commons.d executeQuery(ca.d dVar) {
return new C0968h(this).executeQuery(dVar);
}
public Object downloadData(final l lVar) {
if (this.bUseRemoteBroker) {
return doHttpCall(new Callable() {
@Override
public final Object call() {
Object lambda$downloadData$2;
lambda$downloadData$2 = SOAConnection.this.lambda$downloadData$2(lVar);
return lambda$downloadData$2;
}
});
}
return doHttpCall(new Callable() {
@Override
public final Object call() {
Object lambda$downloadData$3;
lambda$downloadData$3 = SOAConnection.this.lambda$downloadData$3(lVar);
return lambda$downloadData$3;
}
});
}
@Override
public Object execute(ca.d dVar) {
if (!this.bStartTrans) {
return new C0968h(this).execute(dVar);
}
if (this.statementTrans == null) {
this.statementTrans = new C0968h(this);
}
return this.statementTrans.execute(dVar);
}
@Override
public Object execute(C1019d c1019d, int i) {
Object a = c1019d.a();
if (a instanceof IXoneObject) {
return new C0968h(this).c((IXoneObject) a);
}
return null;
}
}