mirror of
https://github.com/GravitLauncher/Launcher
synced 2024-12-23 00:51:01 +03:00
[FEATURE] Настраиваемый аллиас файла в манифесте
This commit is contained in:
parent
d84b13c319
commit
72f938333a
3 changed files with 10 additions and 5 deletions
|
@ -41,8 +41,8 @@
|
|||
public class SignerJar implements AutoCloseable {
|
||||
|
||||
private static final String MANIFEST_FN = "META-INF/MANIFEST.MF";
|
||||
private static final String SIG_FN = "META-INF/SIGNUMO.SF";
|
||||
private static final String SIG_RSA_FN = "META-INF/SIGNUMO.RSA";
|
||||
private final String SIG_FN;
|
||||
private final String SIG_KEY_FN;
|
||||
private static final String DIGEST_HASH = SignHelper.hashFunctionName + "-Digest";
|
||||
|
||||
private final ZipOutputStream zos;
|
||||
|
@ -56,12 +56,14 @@ public class SignerJar implements AutoCloseable {
|
|||
private final Map<String, String> sectionDigests;
|
||||
private final Supplier<CMSSignedDataGenerator> gen;
|
||||
|
||||
public SignerJar(ZipOutputStream out, Supplier<CMSSignedDataGenerator> gen) {
|
||||
public SignerJar(ZipOutputStream out, Supplier<CMSSignedDataGenerator> gen, String sig_fn, String sig_key_fn) {
|
||||
zos = out;
|
||||
this.gen = gen;
|
||||
manifestAttributes = new LinkedHashMap<>();
|
||||
fileDigests = new LinkedHashMap<>();
|
||||
sectionDigests = new LinkedHashMap<>();
|
||||
SIG_FN = "META-INF/".concat(sig_fn);
|
||||
SIG_KEY_FN = "META-INF/".concat(sig_key_fn);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -273,7 +275,7 @@ private byte[] writeSigFile() throws IOException {
|
|||
* @throws RuntimeException if the signing failed
|
||||
*/
|
||||
private void writeSignature(byte[] sigFile) throws IOException {
|
||||
zos.putNextEntry(IOHelper.newZipEntry(SIG_RSA_FN));
|
||||
zos.putNextEntry(IOHelper.newZipEntry(SIG_KEY_FN));
|
||||
try {
|
||||
byte[] signature = signSigFile(sigFile);
|
||||
zos.write(signature);
|
||||
|
|
|
@ -42,7 +42,8 @@ public String getName() {
|
|||
public Path process(Path inputFile) throws IOException {
|
||||
Path toRet = srv.launcherBinary.nextPath("signed");
|
||||
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);
|
||||
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.
|
||||
ZipEntry e = input.getNextEntry();
|
||||
|
|
|
@ -233,6 +233,8 @@ public static class JarSignerConf {
|
|||
public String keyStorePass = "mypass";
|
||||
public String keyAlias = "myname";
|
||||
public String keyPass = "mypass";
|
||||
public String manifestFileName = "SIGNUMO.RSA";
|
||||
public String manifestFileSfName = "SIGNUMO.SF";
|
||||
public String signAlgo = "SHA256WITHRSA";
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue