Search in sources :

Example 1 with DependencyVerificationException

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

the class ChecksumAndSignatureVerificationOverride method artifactsAccessed.

@Override
public void artifactsAccessed(String displayName) {
    verifyConcurrently();
    synchronized (failures) {
        if (hasFatalFailure.get() && !failures.isEmpty()) {
            // There are fatal failures, but not necessarily on all artifacts so we first filter out
            // the artifacts which only have not fatal errors
            failures.asMap().entrySet().removeIf(entry -> {
                Collection<RepositoryAwareVerificationFailure> value = entry.getValue();
                return value.stream().noneMatch(wrapper -> wrapper.getFailure().isFatal());
            });
            VerificationReport report = reportWriter.generateReport(displayName, failures, verifier.getConfiguration().isUseKeyServers());
            String errorMessage = buildConsoleErrorMessage(report);
            if (verificationMode == DependencyVerificationMode.LENIENT) {
                LOGGER.error(errorMessage);
                failures.clear();
                hasFatalFailure.set(false);
            } else {
                throw new DependencyVerificationException(errorMessage);
            }
        }
    }
}
Also used : VerificationReport(org.gradle.api.internal.artifacts.ivyservice.ivyresolve.verification.report.VerificationReport) DependencyVerificationException(org.gradle.api.internal.artifacts.verification.DependencyVerificationException)

Example 2 with DependencyVerificationException

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

the class DependencyVerificationsXmlReader method readFromXml.

public static void readFromXml(InputStream in, DependencyVerifierBuilder builder) {
    try {
        SAXParser saxParser = createSecureParser();
        XMLReader xmlReader = saxParser.getXMLReader();
        VerifiersHandler handler = new VerifiersHandler(builder);
        xmlReader.setProperty("http://xml.org/sax/properties/lexical-handler", handler);
        xmlReader.setContentHandler(handler);
        xmlReader.parse(new InputSource(in));
    } catch (Exception e) {
        throw new DependencyVerificationException("Unable to read dependency verification metadata", e);
    } finally {
        try {
            in.close();
        } catch (IOException e) {
            throw UncheckedException.throwAsUncheckedException(e);
        }
    }
}
Also used : InputSource(org.xml.sax.InputSource) SAXParser(javax.xml.parsers.SAXParser) IOException(java.io.IOException) DependencyVerificationException(org.gradle.api.internal.artifacts.verification.DependencyVerificationException) XMLReader(org.xml.sax.XMLReader) URISyntaxException(java.net.URISyntaxException) UncheckedException(org.gradle.internal.UncheckedException) DependencyVerificationException(org.gradle.api.internal.artifacts.verification.DependencyVerificationException) SAXException(org.xml.sax.SAXException) IOException(java.io.IOException) ParserConfigurationException(javax.xml.parsers.ParserConfigurationException)

Aggregations

DependencyVerificationException (org.gradle.api.internal.artifacts.verification.DependencyVerificationException)2 IOException (java.io.IOException)1 URISyntaxException (java.net.URISyntaxException)1 ParserConfigurationException (javax.xml.parsers.ParserConfigurationException)1 SAXParser (javax.xml.parsers.SAXParser)1 VerificationReport (org.gradle.api.internal.artifacts.ivyservice.ivyresolve.verification.report.VerificationReport)1 UncheckedException (org.gradle.internal.UncheckedException)1 InputSource (org.xml.sax.InputSource)1 SAXException (org.xml.sax.SAXException)1 XMLReader (org.xml.sax.XMLReader)1