Check and sign the bank programmatically

I am new to this topic, so I hope I use the correct dictionary. Is it possible to get the Jarsigner feature inside Java self?

I need the ability to do the following things programmatically:

  • check if a jar is signed with a specific private key from the keystore
  • if checked: unsign the jar
  • Sign the bank with another private key from an official certification authority located in the same or in a different keystore

In pseudo code, I imagine something like this:

JarVerifier verifier = new JarVerifier(/*all needed parameters like the location of the keystore*/);
verifier.verify(jarFile); //returns a value which indicates the result (an Enum or an integer value)

Signing a jar should work in a similar way:

JarSigner signer = new JarSigner(/*all needed parameters like the location of the keystore, passwords, alias*/);
signer.sign(jarFile);

, , . , , OpenJDK, , . , ( ), (, ) .

, , , , , , Oracle, , .

+3
1

.

Jar, , . .

Ant SignJar, , Ant Java

:

public class JarSigner extends SignJar {

public JarSigner() {
    project = new Project();
    project.init();
    taskType = "signJar";
    taskName = "signJar";
    target = new Target();
}

public static void signJar(File jarToSign, String alias, String keypass, String keystore, String storepass) {
    JarSigner signer = new JarSigner();
    signer.setJar(jarToSign);
    signer.setAlias(alias);
    signer.setKeypass(keypass);
    signer.setKeystore(keystore);
    signer.setStorepass(storepass);
    signer.setSignedjar(jarToSign);
    signer.execute();
}
}

unsigning

.

0

All Articles