📄 aejarbuilder.java
字号:
// Decompiled by Jad v1.5.8e2. Copyright 2001 Pavel Kouznetsov.
// Jad home page: http://kpdus.tripod.com/jad.html
// Decompiler options: packimports(3) fieldsfirst ansi space
// Source File Name: AEJarBuilder.java
package org.gudy.azureus2.core3.util.jar;
import java.io.*;
import java.net.URI;
import java.net.URL;
import java.util.*;
import java.util.jar.JarEntry;
import java.util.jar.JarOutputStream;
import org.gudy.azureus2.core3.logging.LogAlert;
import org.gudy.azureus2.core3.logging.Logger;
import org.gudy.azureus2.core3.security.SESecurityManager;
import org.gudy.azureus2.core3.util.*;
// Referenced classes of package org.gudy.azureus2.core3.util.jar:
// AEJarSigner2
public class AEJarBuilder
{
public AEJarBuilder()
{
}
public static long buildFromPackages(OutputStream os, ClassLoader class_loader, String package_names[], Map package_map, String sign_alias)
throws IOException
{
List resource_names = new ArrayList();
for (int i = 0; i < package_names.length; i++)
{
List entries = (List)package_map.get(package_names[i]);
if (entries == null)
{
Debug.out((new StringBuilder()).append("package '").append(package_names[i]).append("' missing").toString());
continue;
}
for (int j = 0; j < entries.size(); j++)
resource_names.add((new StringBuilder()).append(package_names[i]).append("/").append(entries.get(j)).toString());
}
String res[] = new String[resource_names.size()];
resource_names.toArray(res);
return buildFromResources2(os, class_loader, null, res, sign_alias);
}
public static void buildFromResources(OutputStream os, ClassLoader class_loader, String resource_prefix, String resource_names[], String sign_alias)
throws IOException
{
buildFromResources2(os, class_loader, resource_prefix, resource_names, sign_alias);
}
private static long buildFromResources2(OutputStream os, ClassLoader class_loader, String resource_prefix, String resource_names[], String sign_alias)
throws IOException
{
ByteArrayOutputStream baos;
long tim;
if (sign_alias == null)
break MISSING_BLOCK_LABEL_173;
baos = new ByteArrayOutputStream(0x10000);
tim = buildFromResourcesSupport(new JarOutputStream(baos), class_loader, resource_prefix, resource_names);
org.gudy.azureus2.core3.security.SEKeyDetails kd = SESecurityManager.getKeyDetails(sign_alias);
if (kd == null)
{
Logger.log(new LogAlert(false, 3, (new StringBuilder()).append("Certificate alias '").append(sign_alias).append("' not found, jar signing fails").toString()));
throw new Exception((new StringBuilder()).append("Certificate alias '").append(sign_alias).append("' not found ").toString());
}
AEJarSigner2 signer = new AEJarSigner2(sign_alias, SESecurityManager.getKeystoreName(), SESecurityManager.getKeystorePassword());
signer.signJarStream(new ByteArrayInputStream(baos.toByteArray()), os);
return tim;
Throwable e;
e;
Debug.printStackTrace(e);
throw new IOException(e.getMessage());
JarOutputStream jos;
if (os instanceof JarOutputStream)
jos = (JarOutputStream)os;
else
jos = new JarOutputStream(os);
return buildFromResourcesSupport(jos, class_loader, resource_prefix, resource_names);
}
public static long buildFromResourcesSupport(JarOutputStream jos, ClassLoader class_loader, String resource_prefix, String resource_names[])
throws IOException
{
long latest_time;
long now;
int i;
latest_time = 0L;
now = SystemTime.getCurrentTime();
i = 0;
_L3:
if (i >= resource_names.length) goto _L2; else goto _L1
_L1:
String resource_name;
InputStream is;
resource_name = resource_names[i];
if (resource_prefix != null)
resource_name = (new StringBuilder()).append(resource_prefix).append("/").append(resource_name).toString();
is = null;
is = class_loader.getResourceAsStream(resource_name);
if (is == null)
{
Debug.out((new StringBuilder()).append("WUJarBuilder: failed to find resource '").append(resource_name).append("'").toString());
} else
{
URL url = class_loader.getResource(resource_name);
try
{
File file = null;
if (url != null)
{
String url_str = url.toString();
if (url_str.startsWith("jar:file:"))
file = FileUtil.getJarFileFromURL(url_str);
else
if (url_str.startsWith("file:"))
file = new File(URI.create(url_str));
}
if (file == null)
{
latest_time = now;
} else
{
long time = file.lastModified();
if (time > latest_time)
latest_time = time;
}
}
catch (Throwable e)
{
Debug.printStackTrace(e);
}
JarEntry entry = new JarEntry(resource_name);
writeEntry(jos, entry, is);
}
if (is != null)
is.close();
continue; /* Loop/switch isn't completed */
Exception exception;
exception;
if (is != null)
is.close();
throw exception;
i++;
goto _L3
_L2:
JarEntry entry = new JarEntry("META-INF/MANIFEST.MF");
ByteArrayInputStream bais = new ByteArrayInputStream("Manifest-Version: 1.0\r\n\r\n".getBytes());
writeEntry(jos, entry, bais);
jos.flush();
jos.finish();
return latest_time;
}
private static void writeEntry(JarOutputStream jos, JarEntry entry, InputStream data)
throws IOException
{
jos.putNextEntry(entry);
byte newBytes[] = new byte[4096];
for (int size = data.read(newBytes); size != -1; size = data.read(newBytes))
jos.write(newBytes, 0, size);
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -