[FIX] Ошибки SignJarTask и отключение STRIP для библиотек

This commit is contained in:
Gravit 2019-10-20 22:55:36 +07:00
parent 8f779044fc
commit e1c6775e34
No known key found for this signature in database
GPG key ID: 061981E1E85D3216
3 changed files with 6 additions and 6 deletions

View file

@ -36,12 +36,12 @@ public String getName() {
public Path process(Path inputFile) throws IOException { public Path process(Path inputFile) throws IOException {
Path out = server.launcherBinary.nextPath("post-fixed"); Path out = server.launcherBinary.nextPath("post-fixed");
try (ZipOutputStream output = new ZipOutputStream(IOHelper.newOutput(out))) { try (ZipOutputStream output = new ZipOutputStream(IOHelper.newOutput(out))) {
apply(inputFile, inputFile, output, server, (e) -> false); apply(inputFile, inputFile, output, server, (e) -> false, true);
} }
return out; return out;
} }
public static void apply(Path inputFile, Path addFile, ZipOutputStream output, LaunchServer srv, Predicate<ZipEntry> excluder) throws IOException { public static void apply(Path inputFile, Path addFile, ZipOutputStream output, LaunchServer srv, Predicate<ZipEntry> excluder, boolean needFixes) throws IOException {
try (ClassMetadataReader reader = new ClassMetadataReader()) { try (ClassMetadataReader reader = new ClassMetadataReader()) {
reader.getCp().add(new JarFile(inputFile.toFile())); reader.getCp().add(new JarFile(inputFile.toFile()));
List<JarFile> libs = srv.launcherBinary.coreLibs.stream().map(e -> { List<JarFile> libs = srv.launcherBinary.coreLibs.stream().map(e -> {
@ -74,7 +74,7 @@ public static void apply(Path inputFile, Path addFile, ZipOutputStream output, L
bytes = outputStream.toByteArray(); bytes = outputStream.toByteArray();
} }
try { try {
bytes = classFix(bytes, reader, srv.config.launcher.stripLineNumbers); if(needFixes) bytes = classFix(bytes, reader, srv.config.launcher.stripLineNumbers);
} catch (Throwable t) { } catch (Throwable t) {
LogHelper.error(t); LogHelper.error(t);
} }

View file

@ -56,7 +56,7 @@ public Path process(Path inputFile) throws IOException {
private void attach(ZipOutputStream output, Path inputFile, List<Path> lst) throws IOException { private void attach(ZipOutputStream output, Path inputFile, List<Path> lst) throws IOException {
for (Path p : lst) { for (Path p : lst) {
LogHelper.debug("Attaching: " + p); LogHelper.debug("Attaching: " + p);
AdditionalFixesApplyTask.apply(inputFile, p, output, srv, (e) -> exclusions.stream().anyMatch(e.getName()::startsWith)); AdditionalFixesApplyTask.apply(inputFile, p, output, srv, (e) -> exclusions.stream().anyMatch(e.getName()::startsWith), false);
} }
} }

View file

@ -43,7 +43,7 @@ public Path process(Path inputFile) throws IOException {
Path toRet = srv.launcherBinary.nextPath("signed"); Path toRet = srv.launcherBinary.nextPath("signed");
KeyStore c = SignHelper.getStore(new File(config.keyStore).toPath(), config.keyStorePass, config.keyStoreType); KeyStore c = SignHelper.getStore(new File(config.keyStore).toPath(), config.keyStorePass, config.keyStoreType);
try (SignerJar output = new SignerJar(new ZipOutputStream(IOHelper.newOutput(toRet)), () -> this.gen(c), try (SignerJar output = new SignerJar(new ZipOutputStream(IOHelper.newOutput(toRet)), () -> this.gen(c),
config.manifestFileSfName, config.manifestFileSfName); config.manifestFileSfName, config.manifestFileName);
ZipInputStream input = new ZipInputStream(IOHelper.newInput(inputFile))) { ZipInputStream input = new ZipInputStream(IOHelper.newInput(inputFile))) {
//input.getManifest().getMainAttributes().forEach((a, b) -> output.addManifestAttribute(a.toString(), b.toString())); // may not work such as after Radon. //input.getManifest().getMainAttributes().forEach((a, b) -> output.addManifestAttribute(a.toString(), b.toString())); // may not work such as after Radon.
ZipEntry e = input.getNextEntry(); ZipEntry e = input.getNextEntry();
@ -69,7 +69,7 @@ public boolean allowDelete() {
public CMSSignedDataGenerator gen(KeyStore c) { public CMSSignedDataGenerator gen(KeyStore c) {
try { try {
return SignHelper.createSignedDataGenerator(c, return SignHelper.createSignedDataGenerator(c,
config.keyAlias, config.signAlgo, config.keyStorePass); config.keyAlias, config.signAlgo, config.keyPass);
} catch (CertificateEncodingException | UnrecoverableKeyException | KeyStoreException } catch (CertificateEncodingException | UnrecoverableKeyException | KeyStoreException
| OperatorCreationException | NoSuchAlgorithmException | CMSException e) { | OperatorCreationException | NoSuchAlgorithmException | CMSException e) {
LogHelper.error(e); LogHelper.error(e);