use of org.jreleaser.util.command.CommandExecutor 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.CommandExecutor 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;
}
use of org.jreleaser.util.command.CommandExecutor in project jreleaser by jreleaser.
the class Cosign method verifyBlob.
public void verifyBlob(Path keyFile, Path signature, Path input) throws SigningException {
context.getLogger().debug("{}", context.relativizeToBasedir(signature));
Command command = tool.asCommand().arg("verify-blob").arg("--key").arg(keyFile.toAbsolutePath().toString()).arg("--signature").arg(signature.toAbsolutePath().toString()).arg(input.toAbsolutePath().toString());
try {
executeCommand(() -> new CommandExecutor(context.getLogger(), true).executeCommand(command));
} catch (CommandException e) {
throw new SigningException(RB.$("ERROR_signing_verify_signature", context.relativizeToBasedir(signature)), e);
}
}
use of org.jreleaser.util.command.CommandExecutor in project jreleaser by jreleaser.
the class Cosign method generateKeyPair.
public Path generateKeyPair(byte[] password) throws SigningException {
Command command = tool.asCommand().arg("generate-key-pair");
Path homeDir = resolveJReleaserHomeDir();
try {
executeCommand(() -> new CommandExecutor(context.getLogger(), true).environment("COSIGN_PASSWORD", new String(password)).executeCommand(homeDir, command));
} catch (CommandException e) {
throw new SigningException(RB.$("ERROR_unexpected_generate_key_pair"), e);
}
context.getLogger().info(RB.$("cosign.generated.keys.at"), homeDir.toAbsolutePath());
return homeDir.resolve("cosign.key");
}
use of org.jreleaser.util.command.CommandExecutor in project jreleaser by jreleaser.
the class Upx method compress.
public void compress(Path parent, List<String> args) throws CommandException {
Command command = tool.asCommand().args(args);
executeCommand(() -> new CommandExecutor(context.getLogger()).executeCommand(parent, command));
}
Aggregations