use of org.gradle.api.internal.artifacts.verification.signatures.BuildTreeDefinedKeys in project gradle by gradle.
the class WriteDependencyVerificationFile method exportKeyRingCollection.
private void exportKeyRingCollection(PublicKeyService publicKeyService, BuildTreeDefinedKeys keyrings, Set<String> publicKeys) throws IOException {
List<PGPPublicKeyRing> existingRings = loadExistingKeyRing(keyrings);
PGPPublicKeyRingListBuilder builder = new PGPPublicKeyRingListBuilder();
for (String publicKey : publicKeys) {
if (publicKey.length() <= 16) {
publicKeyService.findByLongId(new BigInteger(publicKey, 16).longValue(), builder);
} else {
publicKeyService.findByFingerprint(Fingerprint.fromString(publicKey).getBytes(), builder);
}
}
List<PGPPublicKeyRing> keysSeenInVerifier = builder.build().stream().filter(WriteDependencyVerificationFile::hasAtLeastOnePublicKey).filter(e -> existingRings.stream().noneMatch(ring -> keyIds(ring).equals(keyIds(e)))).collect(Collectors.toList());
ImmutableList<PGPPublicKeyRing> allKeyRings = ImmutableList.<PGPPublicKeyRing>builder().addAll(existingRings).addAll(keysSeenInVerifier).build();
File keyringFile = keyrings.getBinaryKeyringsFile();
writeBinaryKeyringFile(keyringFile, allKeyRings);
File asciiArmoredFile = keyrings.getAsciiKeyringsFile();
writeAsciiArmoredKeyRingFile(asciiArmoredFile, allKeyRings);
LOGGER.lifecycle("Exported {} keys to {} and {}", allKeyRings.size(), keyringFile, asciiArmoredFile);
}
use of org.gradle.api.internal.artifacts.verification.signatures.BuildTreeDefinedKeys in project gradle by gradle.
the class WriteDependencyVerificationFile method exportKeys.
private void exportKeys(SignatureVerificationService signatureVerificationService, DependencyVerifier verifier) throws IOException {
BuildTreeDefinedKeys keys = isDryRun ? keyrings.dryRun() : keyrings;
Set<String> keysToExport = Sets.newHashSet();
verifier.getConfiguration().getTrustedKeys().stream().map(DependencyVerificationConfiguration.TrustedKey::getKeyId).forEach(keysToExport::add);
verifier.getConfiguration().getIgnoredKeys().stream().map(IgnoredKey::getKeyId).forEach(keysToExport::add);
verifier.getVerificationMetadata().stream().flatMap(md -> md.getArtifactVerifications().stream()).flatMap(avm -> Stream.concat(avm.getTrustedPgpKeys().stream(), avm.getIgnoredPgpKeys().stream().map(IgnoredKey::getKeyId))).forEach(keysToExport::add);
exportKeyRingCollection(signatureVerificationService.getPublicKeyService(), keys, keysToExport);
}
Aggregations