Commit 7c53b985 authored by Skylot's avatar Skylot

refactor(gui): remove JCertificate node

parent c8df26f2
package jadx.gui.treemodel;
import java.io.BufferedInputStream;
import java.io.File;
import java.io.FileInputStream;
import java.io.IOException;
import java.io.InputStream;
import java.util.zip.ZipEntry;
import java.util.zip.ZipFile;
import javax.swing.*;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import jadx.api.ResourceFile;
import jadx.core.utils.files.ZipSecurity;
import jadx.gui.utils.CertificateManager;
import jadx.gui.utils.NLS;
import jadx.gui.utils.UiUtils;
public class JCertificate extends JNode {
private static final long serialVersionUID = 4308696770188518731L;
private static final Logger LOG = LoggerFactory.getLogger(JCertificate.class);
private static final ImageIcon CERTIFICATE_ICON = UiUtils.openIcon("certificate_obj");
private final transient ResourceFile rf;
public JCertificate(ResourceFile resFile) {
this.rf = resFile;
}
@Override
public JClass getJParent() {
return null;
}
@Override
public Icon getIcon() {
return CERTIFICATE_ICON;
}
@Override
public String makeString() {
return NLS.str("certificate.title");
}
@Override
public String getContent() {
try {
ResourceFile.ZipRef zipRef = rf.getZipRef();
if (zipRef == null) {
File file = new File(rf.getName());
try (InputStream inputStream = new BufferedInputStream(new FileInputStream(file))) {
return CertificateManager.decode(inputStream);
}
} else {
try (ZipFile zipFile = new ZipFile(zipRef.getZipFile())) {
ZipEntry entry = zipFile.getEntry(zipRef.getEntryName());
if (entry == null) {
throw new IOException("Zip entry not found: " + zipRef);
}
if (!ZipSecurity.isValidZipEntry(entry)) {
return null;
}
try (InputStream inputStream = new BufferedInputStream(zipFile.getInputStream(entry))) {
return CertificateManager.decode(inputStream);
}
}
}
} catch (Exception e) {
LOG.error("Certificate decode error: {}", rf.getName(), e);
return "Decode error: " + e.getMessage();
}
}
}
......@@ -42,11 +42,6 @@ public class JRoot extends JNode {
if (signature != null) {
add(signature);
}
JCertificate certificate = getCertificate(wrapper.getResources());
if (certificate != null) {
add(certificate);
}
}
private List<JResource> getHierarchyResources(List<ResourceFile> resources) {
......@@ -82,22 +77,6 @@ public class JRoot extends JNode {
return Collections.singletonList(root);
}
private JCertificate getCertificate(List<ResourceFile> resources) {
if (resources.isEmpty()) {
return null;
}
for (ResourceFile rf : resources) {
if (rf.getZipRef() != null) {
String rfName = rf.getName().toUpperCase();
if (rfName.endsWith(".DSA") || rfName.endsWith(".RSA")) {
return new JCertificate(rf);
}
}
}
return null;
}
private JResource getResourceByName(JResource rf, String name) {
for (JResource sub : rf.getFiles()) {
if (sub.getName().equals(name)) {
......
......@@ -51,7 +51,6 @@ import jadx.gui.settings.JadxProject;
import jadx.gui.settings.JadxSettings;
import jadx.gui.settings.JadxSettingsWindow;
import jadx.gui.treemodel.ApkSignature;
import jadx.gui.treemodel.JCertificate;
import jadx.gui.treemodel.JClass;
import jadx.gui.treemodel.JLoadableNode;
import jadx.gui.treemodel.JNode;
......@@ -492,7 +491,7 @@ public class MainWindow extends JFrame {
if (resFile != null && JResource.isSupportedForView(resFile.getType())) {
tabbedPane.showResource(res);
}
} else if (obj instanceof JCertificate || obj instanceof ApkSignature) {
} else if (obj instanceof ApkSignature) {
tabbedPane.showSimpleNode((JNode) obj);
} else if (obj instanceof JNode) {
JNode node = (JNode) obj;
......
......@@ -19,7 +19,6 @@ import org.slf4j.LoggerFactory;
import jadx.api.ResourceFile;
import jadx.api.ResourceType;
import jadx.gui.treemodel.ApkSignature;
import jadx.gui.treemodel.JCertificate;
import jadx.gui.treemodel.JClass;
import jadx.gui.treemodel.JNode;
import jadx.gui.treemodel.JResource;
......@@ -178,9 +177,6 @@ public class TabbedPane extends JTabbedPane {
if (node instanceof ApkSignature) {
return new HtmlPanel(this, node);
}
if (node instanceof JCertificate) {
return new CertificatePanel(this, node);
}
return new ClassCodeContentPanel(this, node);
}
......
......@@ -151,7 +151,6 @@ confirm.save_as_message=%s already exists.\nDo you want to replace it?
confirm.not_saved_title=Save project
confirm.not_saved_message=Save the current project before proceeding?
certificate.title=Certificate
certificate.cert_type=Type
certificate.serialSigVer=Version
certificate.serialNumber=Serial number
......
......@@ -151,7 +151,6 @@ popup.select_all=Seleccionar todo
#confirm.not_saved_title=
#confirm.not_saved_message=
certificate.title=Certificado
certificate.cert_type=Tipo
certificate.serialSigVer=Versión
certificate.serialNumber=Número de serial
......
......@@ -151,7 +151,6 @@ confirm.save_as_message=%s 已存在。\n你想替换它吗?
confirm.not_saved_title=保存项目
confirm.not_saved_message=在继续之前保存当前项目?
certificate.title=证书
certificate.cert_type=类型
certificate.serialSigVer=版本
certificate.serialNumber=序列号
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment