Avoid unnecessary Guava dependencies

This commit is contained in:
Reinhard Pointner 2016-11-13 02:00:26 +08:00
parent e8b50b2542
commit 67af50b49e
1 changed files with 7 additions and 5 deletions

View File

@ -15,9 +15,8 @@ import java.util.Map;
import java.util.jar.JarEntry;
import java.util.jar.JarInputStream;
import com.google.common.io.ByteStreams;
import net.filebot.Resource;
import net.filebot.util.ByteBufferOutputStream;
public class ScriptBundle implements ScriptProvider {
@ -37,16 +36,19 @@ public class ScriptBundle implements ScriptProvider {
continue;
// completely read and verify current jar entry
byte[] bytes = ByteStreams.toByteArray(jar);
ByteBufferOutputStream buffer = new ByteBufferOutputStream(f.getSize());
buffer.transferFully(jar);
jar.closeEntry();
// file must be signed
Certificate[] certificates = f.getCertificates();
if (certificates == null || stream(f.getCertificates()).noneMatch(certificate::equals))
if (certificates == null || stream(f.getCertificates()).noneMatch(certificate::equals)) {
throw new SecurityException(String.format("BAD certificate: %s", Arrays.toString(certificates)));
}
return new String(bytes, UTF_8);
return UTF_8.decode(buffer.getByteBuffer()).toString();
}
}