Search in sources :

Example 1 with SignatureVerificationService

use of org.gradle.api.internal.artifacts.verification.signatures.SignatureVerificationService in project gradle by gradle.

the class WriteDependencyVerificationFile method buildFinished.

@Override
public void buildFinished(Gradle gradle) {
    ensureOutputDirCreated();
    maybeReadExistingFile();
    // when we generate the verification file, we intentionally ignore if the "use key servers" flag is false
    // because otherwise it forces the user to remove the option in the XML file, generate, then switch it back.
    boolean offline = gradle.getStartParameter().isOffline();
    SignatureVerificationService signatureVerificationService = signatureVerificationServiceFactory.create(keyrings, DefaultKeyServers.getOrDefaults(verificationsBuilder.getKeyServers()), !offline);
    if (!verificationsBuilder.isUseKeyServers() && !offline) {
        LOGGER.lifecycle("Will use key servers to download missing keys. If you really want to ignore key servers when generating the verification file, you can use the --offline flag in addition");
    }
    try {
        validateChecksums();
        resolveAllConfigurationsConcurrently(gradle);
        computeChecksumsConcurrently(signatureVerificationService);
        writeEntriesSerially();
        serializeResult(signatureVerificationService);
    } catch (IOException e) {
        throw UncheckedException.throwAsUncheckedException(e);
    } finally {
        signatureVerificationService.stop();
    }
}
Also used : SignatureVerificationService(org.gradle.api.internal.artifacts.verification.signatures.SignatureVerificationService) UncheckedIOException(org.gradle.api.UncheckedIOException) IOException(java.io.IOException) DependencyVerificationOverride(org.gradle.api.internal.artifacts.ivyservice.ivyresolve.verification.DependencyVerificationOverride)

Example 2 with SignatureVerificationService

use of org.gradle.api.internal.artifacts.verification.signatures.SignatureVerificationService in project gradle by gradle.

the class ChecksumAndSignatureVerificationOverride method verifyConcurrently.

private void verifyConcurrently() {
    hasFatalFailure.set(false);
    synchronized (verificationEvents) {
        if (verificationEvents.isEmpty()) {
            return;
        }
    }
    if (closed.get()) {
        LOGGER.debug("Cannot perform verification of all dependencies because the verification service has been shutdown. Under normal circumstances this shouldn't happen unless a user buildFinished was added in an unexpected way.");
        return;
    }
    buildOperationExecutor.runAll(queue -> {
        VerificationEvent event;
        synchronized (verificationEvents) {
            while ((event = verificationEvents.poll()) != null) {
                VerificationEvent ve = event;
                queue.add(new RunnableBuildOperation() {

                    @Override
                    public void run(BuildOperationContext context) {
                        verifier.verify(checksumService, signatureVerificationService, ve.kind, ve.artifact, ve.mainFile, ve.signatureFile.create(), f -> {
                            synchronized (failures) {
                                failures.put(ve.artifact, new RepositoryAwareVerificationFailure(f, ve.repositoryName));
                            }
                            if (f.isFatal()) {
                                hasFatalFailure.set(true);
                            }
                        });
                    }

                    @Override
                    public BuildOperationDescriptor.Builder description() {
                        return BuildOperationDescriptor.displayName("Dependency verification").progressDisplayName("Verifying " + ve.artifact);
                    }
                });
            }
        }
    });
}
Also used : ConsoleRenderer(org.gradle.internal.logging.ConsoleRenderer) DependencyVerifyingModuleComponentRepository(org.gradle.api.internal.artifacts.ivyservice.ivyresolve.DependencyVerifyingModuleComponentRepository) AtomicBoolean(java.util.concurrent.atomic.AtomicBoolean) Multimap(com.google.common.collect.Multimap) Deque(java.util.Deque) ChecksumService(org.gradle.internal.hash.ChecksumService) Logger(org.gradle.api.logging.Logger) DependencyVerificationReportWriter(org.gradle.api.internal.artifacts.ivyservice.ivyresolve.verification.report.DependencyVerificationReportWriter) VerificationReport(org.gradle.api.internal.artifacts.ivyservice.ivyresolve.verification.report.VerificationReport) UncheckedException(org.gradle.internal.UncheckedException) RunnableBuildOperation(org.gradle.internal.operations.RunnableBuildOperation) ModuleComponentRepository(org.gradle.api.internal.artifacts.ivyservice.ivyresolve.ModuleComponentRepository) ResolvedVariantResult(org.gradle.api.artifacts.result.ResolvedVariantResult) DependencyVerificationException(org.gradle.api.internal.artifacts.verification.DependencyVerificationException) BuildTreeDefinedKeys(org.gradle.api.internal.artifacts.verification.signatures.BuildTreeDefinedKeys) URI(java.net.URI) LinkedHashMultimap(com.google.common.collect.LinkedHashMultimap) Artifact(org.gradle.api.component.Artifact) SignatureVerificationService(org.gradle.api.internal.artifacts.verification.signatures.SignatureVerificationService) DependencyVerificationsXmlReader(org.gradle.api.internal.artifacts.verification.serializer.DependencyVerificationsXmlReader) Collection(java.util.Collection) SignatureVerificationServiceFactory(org.gradle.api.internal.artifacts.verification.signatures.SignatureVerificationServiceFactory) DependencyVerifier(org.gradle.api.internal.artifacts.verification.verifier.DependencyVerifier) Set(java.util.Set) FileInputStream(java.io.FileInputStream) ComponentArtifactIdentifier(org.gradle.api.artifacts.component.ComponentArtifactIdentifier) DocumentationRegistry(org.gradle.api.internal.DocumentationRegistry) BuildOperationDescriptor(org.gradle.internal.operations.BuildOperationDescriptor) Sets(com.google.common.collect.Sets) File(java.io.File) FileNotFoundException(java.io.FileNotFoundException) ResolutionStrategyInternal(org.gradle.api.internal.artifacts.configurations.ResolutionStrategyInternal) Queues(com.google.common.collect.Queues) List(java.util.List) Stoppable(org.gradle.internal.concurrent.Stoppable) BuildOperationExecutor(org.gradle.internal.operations.BuildOperationExecutor) Logging(org.gradle.api.logging.Logging) Factory(org.gradle.internal.Factory) ModuleComponentArtifactIdentifier(org.gradle.internal.component.external.model.ModuleComponentArtifactIdentifier) BuildOperationContext(org.gradle.internal.operations.BuildOperationContext) GradleProperties(org.gradle.api.internal.properties.GradleProperties) ResolvedArtifactResult(org.gradle.api.artifacts.result.ResolvedArtifactResult) DependencyVerificationMode(org.gradle.api.artifacts.verification.DependencyVerificationMode) BuildOperationContext(org.gradle.internal.operations.BuildOperationContext) RunnableBuildOperation(org.gradle.internal.operations.RunnableBuildOperation)

Example 3 with SignatureVerificationService

use of org.gradle.api.internal.artifacts.verification.signatures.SignatureVerificationService 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

SignatureVerificationService (org.gradle.api.internal.artifacts.verification.signatures.SignatureVerificationService)3 Sets (com.google.common.collect.Sets)2 File (java.io.File)2 FileInputStream (java.io.FileInputStream)2 FileNotFoundException (java.io.FileNotFoundException)2 IOException (java.io.IOException)2 List (java.util.List)2 Set (java.util.Set)2 ResolutionStrategyInternal (org.gradle.api.internal.artifacts.configurations.ResolutionStrategyInternal)2 DependencyVerifyingModuleComponentRepository (org.gradle.api.internal.artifacts.ivyservice.ivyresolve.DependencyVerifyingModuleComponentRepository)2 ModuleComponentRepository (org.gradle.api.internal.artifacts.ivyservice.ivyresolve.ModuleComponentRepository)2 DependencyVerificationException (org.gradle.api.internal.artifacts.verification.DependencyVerificationException)2 DependencyVerificationsXmlReader (org.gradle.api.internal.artifacts.verification.serializer.DependencyVerificationsXmlReader)2 BuildTreeDefinedKeys (org.gradle.api.internal.artifacts.verification.signatures.BuildTreeDefinedKeys)2 SignatureVerificationServiceFactory (org.gradle.api.internal.artifacts.verification.signatures.SignatureVerificationServiceFactory)2 DependencyVerifier (org.gradle.api.internal.artifacts.verification.verifier.DependencyVerifier)2 Logger (org.gradle.api.logging.Logger)2 Logging (org.gradle.api.logging.Logging)2 Factory (org.gradle.internal.Factory)2 UncheckedException (org.gradle.internal.UncheckedException)2