use of org.jreleaser.util.command.CommandException 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();
}
}
use of org.jreleaser.util.command.CommandException in project jreleaser by jreleaser.
the class GpgCommandSigner method sign.
public byte[] sign(byte[] in) throws CommandException {
try {
Path input = Files.createTempFile("jreleaser", "sign-input");
Files.write(input, in, WRITE);
Path output = Files.createTempDirectory("jreleaser-" + UUID.randomUUID()).resolve(UUID.randomUUID().toString());
sign(input, output);
return Files.readAllBytes(output);
} catch (IOException e) {
throw new CommandException(RB.$("ERROR_unexpected_error"), e);
}
}
use of org.jreleaser.util.command.CommandException in project jreleaser by jreleaser.
the class Cosign method signBlob.
public void signBlob(Path keyFile, byte[] password, Path input, Path destinationDir) throws SigningException {
context.getLogger().info("{}", context.relativizeToBasedir(input));
ByteArrayInputStream in = new ByteArrayInputStream(password);
ByteArrayOutputStream out = new ByteArrayOutputStream();
Command command = tool.asCommand().arg("sign-blob").arg("--key").arg(keyFile.toAbsolutePath().toString()).arg(input.toAbsolutePath().toString());
try {
executeCommand(() -> new CommandExecutor(context.getLogger(), true).executeCommandWithInputCapturing(command, in, out));
} catch (CommandException e) {
throw new SigningException(RB.$("ERROR_unexpected_error_signing", input.toAbsolutePath()), e);
}
try {
Path signature = destinationDir.resolve(input.getFileName() + ".sig");
Files.write(signature, out.toByteArray());
} catch (IOException e) {
throw new SigningException(RB.$("ERROR_unexpected_error_signing", input), e);
}
}
use of org.jreleaser.util.command.CommandException in project jreleaser by jreleaser.
the class DownloadableTool method verify.
private boolean verify(Path executable) {
Command command = new Command(executable.toString()).arg(properties.getProperty(COMMAND_VERSION));
try {
ByteArrayOutputStream out = new ByteArrayOutputStream();
executeCommandCapturing(command, out);
String verify = properties.getProperty(COMMAND_VERIFY).trim();
Map<String, Object> props = props();
verify = resolveTemplate(verify, props);
Pattern pattern = Pattern.compile(verify);
return pattern.matcher(out.toString()).find();
} catch (CommandException e) {
if (null != e.getCause()) {
logger.debug(e.getCause().getMessage());
} else {
logger.debug(e.getMessage());
}
}
return false;
}
use of org.jreleaser.util.command.CommandException in project jreleaser by jreleaser.
the class Cosign method checkPassword.
public boolean checkPassword(Path keyFile, byte[] password) {
ByteArrayInputStream in = new ByteArrayInputStream(password);
Command command = tool.asCommand().arg("public-key").arg("--key").arg(keyFile.toAbsolutePath().toString());
try {
executeCommand(() -> new CommandExecutor(context.getLogger(), true).executeCommandWithInput(command, in));
return true;
} catch (CommandException e) {
context.getLogger().debug(RB.$("ERROR_password_incorrect"));
}
return false;
}
Aggregations