Search in sources :

Example 1 with GpgCommandSigner

use of org.jreleaser.util.signing.GpgCommandSigner in project jreleaser by jreleaser.

the class Signer method verify.

private static boolean verify(JReleaserContext context, FilePair filePair) throws SigningException {
    context.getLogger().setPrefix("verify");
    try {
        context.getLogger().debug("{}", context.relativizeToBasedir(filePair.signatureFile));
        GpgCommandSigner commandSigner = initCommandSigner(context);
        return commandSigner.verify(filePair.signatureFile, filePair.inputFile);
    } catch (CommandException e) {
        throw new SigningException(RB.$("ERROR_signing_verify_signature", context.relativizeToBasedir(filePair.inputFile)), e);
    } finally {
        context.getLogger().restorePrefix();
    }
}
Also used : SigningException(org.jreleaser.util.signing.SigningException) GpgCommandSigner(org.jreleaser.util.signing.GpgCommandSigner) CommandException(org.jreleaser.util.command.CommandException)

Example 2 with GpgCommandSigner

use of org.jreleaser.util.signing.GpgCommandSigner in project jreleaser by jreleaser.

the class Signer method sign.

private static void sign(JReleaserContext context, List<FilePair> files) throws SigningException {
    Path signaturesDirectory = context.getSignaturesDirectory();
    try {
        Files.createDirectories(signaturesDirectory);
    } catch (IOException e) {
        throw new SigningException(RB.$("ERROR_signing_create_signature_dir"), e);
    }
    context.getLogger().debug(RB.$("signing.signing.files"), files.size(), context.relativizeToBasedir(signaturesDirectory));
    GpgCommandSigner commandSigner = initCommandSigner(context);
    for (FilePair pair : files) {
        sign(context, commandSigner, pair.inputFile, pair.signatureFile);
    }
}
Also used : Path(java.nio.file.Path) SigningException(org.jreleaser.util.signing.SigningException) GpgCommandSigner(org.jreleaser.util.signing.GpgCommandSigner) IOException(java.io.IOException)

Example 3 with GpgCommandSigner

use of org.jreleaser.util.signing.GpgCommandSigner in project jreleaser by jreleaser.

the class Signer method initCommandSigner.

private static GpgCommandSigner initCommandSigner(JReleaserContext context) {
    GpgCommandSigner cmd = new GpgCommandSigner(context.getLogger());
    Signing signing = context.getModel().getSigning();
    cmd.setExecutable(signing.getCommand().getExecutable());
    cmd.setPassphrase(signing.getResolvedPassphrase());
    cmd.setHomeDir(signing.getCommand().getHomeDir());
    cmd.setKeyName(signing.getCommand().getKeyName());
    cmd.setPublicKeyring(signing.getCommand().getPublicKeyring());
    cmd.setDefaultKeyring(signing.getCommand().isDefaultKeyring());
    cmd.setArgs(signing.getCommand().getArgs());
    return cmd;
}
Also used : Signing(org.jreleaser.model.Signing) GpgCommandSigner(org.jreleaser.util.signing.GpgCommandSigner)

Aggregations

GpgCommandSigner (org.jreleaser.util.signing.GpgCommandSigner)3 SigningException (org.jreleaser.util.signing.SigningException)2 IOException (java.io.IOException)1 Path (java.nio.file.Path)1 Signing (org.jreleaser.model.Signing)1 CommandException (org.jreleaser.util.command.CommandException)1