Search in sources :

Example 1 with IgnoredKey

use of org.gradle.api.internal.artifacts.verification.model.IgnoredKey in project gradle by gradle.

the class WriteDependencyVerificationFile method postProcessPgpResults.

private void postProcessPgpResults(Set<String> collectedIgnoredKeys) {
    for (String ignoredKey : collectedIgnoredKeys) {
        verificationsBuilder.addIgnoredKey(new IgnoredKey(ignoredKey, KEY_NOT_DOWNLOADED));
    }
    PgpKeyGrouper grouper = new PgpKeyGrouper(verificationsBuilder, entriesToBeWritten);
    grouper.performPgpKeyGrouping();
}
Also used : IgnoredKey(org.gradle.api.internal.artifacts.verification.model.IgnoredKey)

Example 2 with IgnoredKey

use of org.gradle.api.internal.artifacts.verification.model.IgnoredKey in project gradle by gradle.

the class DependencyVerificationsXmlWriter method writIgnoredKeys.

private void writIgnoredKeys(DependencyVerificationConfiguration configuration) throws IOException {
    Set<IgnoredKey> ignoredKeys = configuration.getIgnoredKeys();
    if (!ignoredKeys.isEmpty()) {
        writer.startElement(IGNORED_KEYS);
        for (IgnoredKey ignoredKey : ignoredKeys) {
            writeIgnoredKey(ignoredKey);
        }
        writer.endElement();
    }
}
Also used : IgnoredKey(org.gradle.api.internal.artifacts.verification.model.IgnoredKey)

Example 3 with IgnoredKey

use of org.gradle.api.internal.artifacts.verification.model.IgnoredKey in project gradle by gradle.

the class DependencyVerificationsXmlWriter method writeIgnoredKeys.

private void writeIgnoredKeys(Set<IgnoredKey> ignoredPgpKeys) throws IOException {
    if (ignoredPgpKeys.isEmpty()) {
        return;
    }
    writer.startElement(IGNORED_KEYS);
    for (IgnoredKey ignoredPgpKey : ignoredPgpKeys) {
        writeIgnoredKey(ignoredPgpKey);
    }
    writer.endElement();
}
Also used : IgnoredKey(org.gradle.api.internal.artifacts.verification.model.IgnoredKey)

Example 4 with IgnoredKey

use of org.gradle.api.internal.artifacts.verification.model.IgnoredKey in project gradle by gradle.

the class WriteDependencyVerificationFile method registerEntryToBuilder.

private void registerEntryToBuilder(VerificationEntry entry, AtomicReference<PgpEntry> previousEntry) {
    // checksums are written _after_ PGP, so if the previous entry was PGP and
    // that it matches the artifact id we don't always need to write the checksum
    PgpEntry pgpEntry = previousEntry.get();
    if (pgpEntry != null && !pgpEntry.id.equals(entry.id)) {
        // previous entry was on unrelated module
        pgpEntry = null;
        previousEntry.set(null);
    }
    if (entry instanceof ChecksumEntry) {
        ChecksumEntry checksum = (ChecksumEntry) entry;
        if (pgpEntry == null || (entry.id.equals(pgpEntry.id) && pgpEntry.isRequiringChecksums())) {
            String label = "Generated by Gradle";
            if (pgpEntry != null) {
                if (pgpEntry.isFailed()) {
                    hasFailedVerification = true;
                    label += " because PGP signature verification failed!";
                } else {
                    if (pgpEntry.hasSignatureFile()) {
                        hasMissingKeys = true;
                        label += " because a key couldn't be downloaded";
                    } else {
                        hasMissingSignatures = true;
                        label += " because artifact wasn't signed";
                    }
                }
            }
            verificationsBuilder.addChecksum(entry.id, checksum.getChecksumKind(), checksum.getChecksum(), label);
        }
    } else {
        PgpEntry pgp = (PgpEntry) entry;
        previousEntry.set(pgp);
        Set<String> failedKeys = Sets.newTreeSet(pgp.getFailed());
        for (String failedKey : failedKeys) {
            verificationsBuilder.addIgnoredKey(pgp.id, new IgnoredKey(failedKey, PGP_VERIFICATION_FAILED));
        }
        if (pgp.hasArtifactLevelKeys()) {
            for (String key : pgp.getArtifactLevelKeys()) {
                if (!failedKeys.contains(key)) {
                    verificationsBuilder.addTrustedKey(pgp.id, key);
                }
            }
        }
    }
}
Also used : IgnoredKey(org.gradle.api.internal.artifacts.verification.model.IgnoredKey)

Example 5 with IgnoredKey

use of org.gradle.api.internal.artifacts.verification.model.IgnoredKey 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);
}
Also used : DependencyVerificationOverride(org.gradle.api.internal.artifacts.ivyservice.ivyresolve.verification.DependencyVerificationOverride) SignatureVerificationResultBuilder(org.gradle.api.internal.artifacts.verification.signatures.SignatureVerificationResultBuilder) ChecksumService(org.gradle.internal.hash.ChecksumService) UncheckedException(org.gradle.internal.UncheckedException) PublicKeyService(org.gradle.security.internal.PublicKeyService) ModuleComponentRepository(org.gradle.api.internal.artifacts.ivyservice.ivyresolve.ModuleComponentRepository) ProjectInternal(org.gradle.api.internal.project.ProjectInternal) DependencyVerificationException(org.gradle.api.internal.artifacts.verification.DependencyVerificationException) PGPPublicKeyRing(org.bouncycastle.openpgp.PGPPublicKeyRing) BigInteger(java.math.BigInteger) ChecksumKind(org.gradle.api.internal.artifacts.verification.model.ChecksumKind) ImmutableSet(com.google.common.collect.ImmutableSet) Project(org.gradle.api.Project) Files.getNameWithoutExtension(com.google.common.io.Files.getNameWithoutExtension) DependencyVerificationsXmlReader(org.gradle.api.internal.artifacts.verification.serializer.DependencyVerificationsXmlReader) SignatureVerificationServiceFactory(org.gradle.api.internal.artifacts.verification.signatures.SignatureVerificationServiceFactory) DependencyVerifier(org.gradle.api.internal.artifacts.verification.verifier.DependencyVerifier) Set(java.util.Set) PGPPublicKey(org.bouncycastle.openpgp.PGPPublicKey) IgnoredKey(org.gradle.api.internal.artifacts.verification.model.IgnoredKey) BuildOperationDescriptor(org.gradle.internal.operations.BuildOperationDescriptor) Collectors(java.util.stream.Collectors) Sets(com.google.common.collect.Sets) Gradle(org.gradle.api.invocation.Gradle) FileNotFoundException(java.io.FileNotFoundException) StandardCharsets(java.nio.charset.StandardCharsets) ArtifactView(org.gradle.api.artifacts.ArtifactView) List(java.util.List) Stream(java.util.stream.Stream) BuildOperationExecutor(org.gradle.internal.operations.BuildOperationExecutor) DefaultKeyServers(org.gradle.api.internal.artifacts.ivyservice.ivyresolve.verification.DefaultKeyServers) Factory(org.gradle.internal.Factory) DeprecatableConfiguration(org.gradle.internal.deprecation.DeprecatableConfiguration) DependencyVerifyingModuleComponentRepository(org.gradle.api.internal.artifacts.ivyservice.ivyresolve.DependencyVerifyingModuleComponentRepository) DependencyVerificationConfiguration(org.gradle.api.internal.artifacts.verification.verifier.DependencyVerificationConfiguration) AtomicReference(java.util.concurrent.atomic.AtomicReference) UncheckedIOException(org.gradle.api.UncheckedIOException) Logger(org.gradle.api.logging.Logger) BuildOperationQueue(org.gradle.internal.operations.BuildOperationQueue) Configuration(org.gradle.api.artifacts.Configuration) ArtifactVerificationOperation(org.gradle.api.internal.artifacts.ivyservice.ivyresolve.verification.ArtifactVerificationOperation) RunnableBuildOperation(org.gradle.internal.operations.RunnableBuildOperation) ImmutableList(com.google.common.collect.ImmutableList) BuildTreeDefinedKeys(org.gradle.api.internal.artifacts.verification.signatures.BuildTreeDefinedKeys) DependencyVerificationsXmlWriter(org.gradle.api.internal.artifacts.verification.serializer.DependencyVerificationsXmlWriter) Fingerprint(org.gradle.security.internal.Fingerprint) OutputStream(java.io.OutputStream) PublicKeyResultBuilder(org.gradle.security.internal.PublicKeyResultBuilder) Action(org.gradle.api.Action) Iterator(java.util.Iterator) SignatureVerificationService(org.gradle.api.internal.artifacts.verification.signatures.SignatureVerificationService) DependencyVerifierBuilder(org.gradle.api.internal.artifacts.verification.verifier.DependencyVerifierBuilder) FileOutputStream(java.io.FileOutputStream) IOException(java.io.IOException) FileInputStream(java.io.FileInputStream) File(java.io.File) ModuleComponentIdentifier(org.gradle.api.artifacts.component.ModuleComponentIdentifier) ResolutionStrategyInternal(org.gradle.api.internal.artifacts.configurations.ResolutionStrategyInternal) ArmoredOutputStream(org.bouncycastle.bcpg.ArmoredOutputStream) Logging(org.gradle.api.logging.Logging) SecuritySupport(org.gradle.security.internal.SecuritySupport) ModuleComponentArtifactIdentifier(org.gradle.internal.component.external.model.ModuleComponentArtifactIdentifier) BuildOperationContext(org.gradle.internal.operations.BuildOperationContext) PGPUtils(org.gradle.api.internal.artifacts.ivyservice.ivyresolve.verification.utils.PGPUtils) Collections(java.util.Collections) BuildTreeDefinedKeys(org.gradle.api.internal.artifacts.verification.signatures.BuildTreeDefinedKeys) DependencyVerificationConfiguration(org.gradle.api.internal.artifacts.verification.verifier.DependencyVerificationConfiguration)

Aggregations

IgnoredKey (org.gradle.api.internal.artifacts.verification.model.IgnoredKey)5 ImmutableList (com.google.common.collect.ImmutableList)1 ImmutableSet (com.google.common.collect.ImmutableSet)1 Sets (com.google.common.collect.Sets)1 Files.getNameWithoutExtension (com.google.common.io.Files.getNameWithoutExtension)1 File (java.io.File)1 FileInputStream (java.io.FileInputStream)1 FileNotFoundException (java.io.FileNotFoundException)1 FileOutputStream (java.io.FileOutputStream)1 IOException (java.io.IOException)1 OutputStream (java.io.OutputStream)1 BigInteger (java.math.BigInteger)1 StandardCharsets (java.nio.charset.StandardCharsets)1 Collections (java.util.Collections)1 Iterator (java.util.Iterator)1 List (java.util.List)1 Set (java.util.Set)1 AtomicReference (java.util.concurrent.atomic.AtomicReference)1 Collectors (java.util.stream.Collectors)1 Stream (java.util.stream.Stream)1