what-the-bank/sources/o/jUH.java

252 lines
10 KiB
Java

package o;
import com.adobe.internal.xmp.XMPException;
import com.google.common.primitives.UnsignedBytes;
import java.io.ByteArrayInputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.StringReader;
import java.io.UnsupportedEncodingException;
import javax.xml.parsers.DocumentBuilder;
import javax.xml.parsers.DocumentBuilderFactory;
import javax.xml.parsers.ParserConfigurationException;
import net.sf.scuba.smartcards.ISO7816;
import org.w3c.dom.Document;
import org.w3c.dom.Node;
import org.w3c.dom.NodeList;
import org.w3c.dom.ProcessingInstruction;
import org.xml.sax.InputSource;
import org.xml.sax.SAXException;
/* loaded from: classes.dex */
public final class jUH {
private static final Object e = new Object();
private static DocumentBuilderFactory b = e();
private static Document e(mVl mvl, khW khw) throws XMPException {
try {
InputSource inputSource = new InputSource(new ByteArrayInputStream(mvl.e, 0, mvl.c));
try {
if ((khw.a & 64) != 0) {
try {
b.setFeature("http://apache.org/xml/features/disallow-doctype-decl", true);
} catch (Throwable unused) {
}
}
return c(inputSource);
} catch (XMPException e2) {
if ("DOCTYPE is disallowed".equals(e2.getCause().getMessage())) {
throw new XMPException(e2.getCause().getMessage(), 201);
}
if (e2.c != 201 && e2.c != 204) {
throw e2;
}
if ((khw.a & 16) != 0 && "UTF-8".equals(mvl.b())) {
byte[] bArr = new byte[8];
mVl mvl2 = new mVl((mvl.c << 2) / 3);
int i = 0;
char c = 0;
int i2 = 0;
int i3 = 0;
while (i < mvl.c) {
if (i < mvl.c) {
byte b2 = mvl.e[i];
int i4 = b2 & UnsignedBytes.MAX_VALUE;
if (c == 11) {
if (i2 > 0 && (b2 & ISO7816.INS_GET_RESPONSE) == 128) {
int i5 = i3 + 1;
bArr[i3] = (byte) i4;
i2--;
if (i2 == 0) {
mvl2.b(bArr, i5);
} else {
i3 = i5;
}
} else {
byte[] b3 = C11546ehQ.b(bArr[0]);
mvl2.b(b3, b3.length);
i -= i3;
}
c = 0;
i3 = 0;
} else if (i4 < 127) {
byte b4 = (byte) i4;
mvl2.e(mvl2.c + 1);
byte[] bArr2 = mvl2.e;
int i6 = mvl2.c;
mvl2.c = i6 + 1;
bArr2[i6] = b4;
} else if (i4 >= 192) {
i2 = -1;
for (int i7 = i4; i2 < 8 && (i7 & 128) == 128; i7 <<= 1) {
i2++;
}
bArr[i3] = (byte) i4;
i3++;
c = 11;
} else {
byte[] b5 = C11546ehQ.b((byte) i4);
mvl2.b(b5, b5.length);
}
i++;
} else {
throw new IndexOutOfBoundsException("The index exceeds the valid buffer area");
}
}
if (c == 11) {
for (int i8 = 0; i8 < i3; i8++) {
byte[] b6 = C11546ehQ.b(bArr[i8]);
mvl2.b(b6, b6.length);
}
}
mvl = mvl2;
}
if ((khw.a & 8) != 0) {
return c(new InputSource(new WQL(new InputStreamReader(new ByteArrayInputStream(mvl.e, 0, mvl.c), mvl.b()))));
}
return c(new InputSource(new ByteArrayInputStream(mvl.e, 0, mvl.c)));
}
} catch (UnsupportedEncodingException e3) {
throw new XMPException("Unsupported Encoding", 9, e3);
}
}
private static Document c(InputSource inputSource) throws XMPException {
try {
DocumentBuilder newDocumentBuilder = b.newDocumentBuilder();
newDocumentBuilder.setErrorHandler(null);
return newDocumentBuilder.parse(inputSource);
} catch (IOException e2) {
throw new XMPException("Error reading the XML-file", 204, e2);
} catch (ParserConfigurationException e3) {
throw new XMPException("XML Parser not correctly configured", 0, e3);
} catch (SAXException e4) {
throw new XMPException("XML parsing failure", 201, e4);
}
}
private static Object[] e(Node node, boolean z, Object[] objArr) {
Node item;
while (true) {
NodeList childNodes = node.getChildNodes();
for (int i = 0; i < childNodes.getLength(); i++) {
item = childNodes.item(i);
if (7 == item.getNodeType()) {
ProcessingInstruction processingInstruction = (ProcessingInstruction) item;
if ("xpacket".equals(processingInstruction.getTarget())) {
if (objArr != null) {
objArr[2] = processingInstruction.getData();
}
}
}
if (3 != item.getNodeType() && 7 != item.getNodeType()) {
String namespaceURI = item.getNamespaceURI();
String localName = item.getLocalName();
if (("xmpmeta".equals(localName) || "xapmeta".equals(localName)) && "adobe:ns:meta/".equals(namespaceURI)) {
break;
}
if (!z && "RDF".equals(localName) && "http://www.w3.org/1999/02/22-rdf-syntax-ns#".equals(namespaceURI)) {
if (objArr != null) {
objArr[0] = item;
objArr[1] = e;
}
return objArr;
}
Object[] e2 = e(item, z, objArr);
if (e2 != null) {
return e2;
}
}
}
return null;
z = false;
node = item;
}
}
private static DocumentBuilderFactory e() {
DocumentBuilderFactory newInstance = DocumentBuilderFactory.newInstance();
newInstance.setNamespaceAware(true);
newInstance.setIgnoringComments(true);
newInstance.setExpandEntityReferences(false);
try {
newInstance.setFeature("http://apache.org/xml/features/disallow-doctype-decl", true);
newInstance.setFeature("http://xml.org/sax/features/external-general-entities", false);
newInstance.setFeature("http://xerces.apache.org/xerces2-j/features.html#disallow-doctype-decl", false);
newInstance.setFeature("http://xml.org/sax/features/external-parameter-entities", false);
newInstance.setFeature("http://xerces.apache.org/xerces2-j/features.html#external-parameter-entities", false);
newInstance.setFeature("http://apache.org/xml/features/nonvalidating/load-external-dtd", false);
newInstance.setXIncludeAware(false);
newInstance.setExpandEntityReferences(false);
} catch (Throwable unused) {
}
return newInstance;
}
public static OPB e(Object obj, khW khw) throws XMPException {
Document a;
if (obj == null) {
throw new XMPException("Parameter must not be null", 4);
}
if ((obj instanceof String) && ((String) obj).length() == 0) {
throw new XMPException("Parameter must not be null or empty", 4);
}
if (khw == null) {
khw = new khW();
}
if (obj instanceof InputStream) {
a = e((InputStream) obj, khw);
} else if (obj instanceof byte[]) {
a = e(new mVl((byte[]) obj), khw);
} else {
a = a((String) obj, khw);
}
Object[] e2 = e(a, (khw.a & 1) != 0, new Object[3]);
if (e2 != null && e2[1] == e) {
Node node = (Node) e2[0];
C16814rTK c16814rTK = new C16814rTK();
if (!node.hasAttributes()) {
throw new XMPException("Invalid attributes of rdf:RDF element", 202);
}
sfI sfi = c16814rTK.b;
for (int i = 0; i < node.getChildNodes().getLength(); i++) {
Node item = node.getChildNodes().item(i);
if (!Eli.d(item)) {
Eli.a(c16814rTK, sfi, item, true, khw);
}
}
return (khw.a & 32) != 0 ? c16814rTK : C17589xzn.a(c16814rTK, khw);
}
return new C16814rTK();
}
private static Document e(InputStream inputStream, khW khw) throws XMPException {
if ((khw.a & 16) == 0 && (khw.a & 8) == 0 && (khw.a & 64) == 0) {
return c(new InputSource(inputStream));
}
try {
return e(new mVl(inputStream), khw);
} catch (IOException e2) {
throw new XMPException("Error reading the XML-file", 204, e2);
}
}
private static Document a(String str, khW khw) throws XMPException {
try {
if ((khw.a & 64) != 0) {
try {
b.setFeature("http://apache.org/xml/features/disallow-doctype-decl", true);
} catch (Throwable unused) {
}
}
return c(new InputSource(new StringReader(str)));
} catch (XMPException e2) {
if (e2.c == 201 && (khw.a & 8) != 0) {
return c(new InputSource(new WQL(new StringReader(str))));
}
throw e2;
}
}
}