mirror of
https://github.com/GravitLauncher/Launcher
synced 2024-12-23 09:01:08 +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 {
|
public class SignerJar implements AutoCloseable {
|
||||||
|
|
||||||
private static final String MANIFEST_FN = "META-INF/MANIFEST.MF";
|
private static final String MANIFEST_FN = "META-INF/MANIFEST.MF";
|
||||||
private static final String SIG_FN = "META-INF/SIGNUMO.SF";
|
private final String SIG_FN;
|
||||||
private static final String SIG_RSA_FN = "META-INF/SIGNUMO.RSA";
|
private final String SIG_KEY_FN;
|
||||||
private static final String DIGEST_HASH = SignHelper.hashFunctionName + "-Digest";
|
private static final String DIGEST_HASH = SignHelper.hashFunctionName + "-Digest";
|
||||||
|
|
||||||
private final ZipOutputStream zos;
|
private final ZipOutputStream zos;
|
||||||
|
@ -56,12 +56,14 @@ public class SignerJar implements AutoCloseable {
|
||||||
private final Map<String, String> sectionDigests;
|
private final Map<String, String> sectionDigests;
|
||||||
private final Supplier<CMSSignedDataGenerator> gen;
|
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;
|
zos = out;
|
||||||
this.gen = gen;
|
this.gen = gen;
|
||||||
manifestAttributes = new LinkedHashMap<>();
|
manifestAttributes = new LinkedHashMap<>();
|
||||||
fileDigests = new LinkedHashMap<>();
|
fileDigests = new LinkedHashMap<>();
|
||||||
sectionDigests = 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
|
* @throws RuntimeException if the signing failed
|
||||||
*/
|
*/
|
||||||
private void writeSignature(byte[] sigFile) throws IOException {
|
private void writeSignature(byte[] sigFile) throws IOException {
|
||||||
zos.putNextEntry(IOHelper.newZipEntry(SIG_RSA_FN));
|
zos.putNextEntry(IOHelper.newZipEntry(SIG_KEY_FN));
|
||||||
try {
|
try {
|
||||||
byte[] signature = signSigFile(sigFile);
|
byte[] signature = signSigFile(sigFile);
|
||||||
zos.write(signature);
|
zos.write(signature);
|
||||||
|
|
|
@ -42,7 +42,8 @@ public String getName() {
|
||||||
public Path process(Path inputFile) throws IOException {
|
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);
|
||||||
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();
|
||||||
|
|
|
@ -233,6 +233,8 @@ public static class JarSignerConf {
|
||||||
public String keyStorePass = "mypass";
|
public String keyStorePass = "mypass";
|
||||||
public String keyAlias = "myname";
|
public String keyAlias = "myname";
|
||||||
public String keyPass = "mypass";
|
public String keyPass = "mypass";
|
||||||
|
public String manifestFileName = "SIGNUMO.RSA";
|
||||||
|
public String manifestFileSfName = "SIGNUMO.SF";
|
||||||
public String signAlgo = "SHA256WITHRSA";
|
public String signAlgo = "SHA256WITHRSA";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue