Files
rr3-apk/decompiled/sources/com/amazonaws/regions/RegionMetadataParser.java
Daniel Elliott f9d20bb3fc Add decompiled APK source code (JADX)
- 28,932 files
- Full Java source code
- Smali files
- Resources

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
2026-02-18 14:52:23 -08:00

86 lines
3.5 KiB
Java

package com.amazonaws.regions;
import java.io.IOException;
import java.io.InputStream;
import java.util.ArrayList;
import java.util.List;
import javax.xml.parsers.DocumentBuilderFactory;
import org.w3c.dom.Element;
import org.w3c.dom.Node;
import org.w3c.dom.NodeList;
@Deprecated
/* loaded from: classes.dex */
public class RegionMetadataParser {
@Deprecated
public RegionMetadataParser() {
}
public List parseRegionMetadata(InputStream inputStream) {
return internalParse(inputStream, false);
}
public static List internalParse(InputStream inputStream, boolean z) {
try {
try {
DocumentBuilderFactory newInstance = DocumentBuilderFactory.newInstance();
newInstance.setFeature("http://apache.org/xml/features/disallow-doctype-decl", true);
newInstance.setXIncludeAware(false);
newInstance.setExpandEntityReferences(false);
NodeList elementsByTagName = newInstance.newDocumentBuilder().parse(inputStream).getElementsByTagName("Region");
ArrayList arrayList = new ArrayList();
for (int i = 0; i < elementsByTagName.getLength(); i++) {
Node item = elementsByTagName.item(i);
if (item.getNodeType() == 1) {
arrayList.add(parseRegionElement((Element) item, z));
}
}
return arrayList;
} finally {
try {
inputStream.close();
} catch (IOException unused) {
}
}
} catch (IOException e) {
throw e;
} catch (Exception e2) {
throw new IOException("Unable to parse region metadata file: " + e2.getMessage(), e2);
}
}
public static Region parseRegionElement(Element element, boolean z) {
Region region = new Region(getChildElementValue("Name", element), getChildElementValue("Domain", element));
NodeList elementsByTagName = element.getElementsByTagName("Endpoint");
for (int i = 0; i < elementsByTagName.getLength(); i++) {
addRegionEndpoint(region, (Element) elementsByTagName.item(i), z);
}
return region;
}
public static void addRegionEndpoint(Region region, Element element, boolean z) {
String childElementValue = getChildElementValue("ServiceName", element);
String childElementValue2 = getChildElementValue("Hostname", element);
String childElementValue3 = getChildElementValue("Http", element);
String childElementValue4 = getChildElementValue("Https", element);
if (z && !verifyLegacyEndpoint(childElementValue2)) {
throw new IllegalStateException("Invalid service endpoint (" + childElementValue2 + ") is detected.");
}
region.getServiceEndpoints().put(childElementValue, childElementValue2);
region.getHttpSupport().put(childElementValue, Boolean.valueOf("true".equals(childElementValue3)));
region.getHttpsSupport().put(childElementValue, Boolean.valueOf("true".equals(childElementValue4)));
}
public static String getChildElementValue(String str, Element element) {
Node item = element.getElementsByTagName(str).item(0);
if (item == null) {
return null;
}
return item.getChildNodes().item(0).getNodeValue();
}
public static boolean verifyLegacyEndpoint(String str) {
return str.endsWith(".amazonaws.com");
}
}