From 155e4ad7c5ab018e78f071027dccbe8d58e4f030 Mon Sep 17 00:00:00 2001 From: Thomas Watson Date: Wed, 10 Jul 2013 13:14:08 -0500 Subject: Bug 411035 - Some tests depend on SignedContentFactory.getSignedContent(File) to return an empty unsigned SignedContent object when the input is an invalid zip file. Signed-off-by: Thomas Watson --- .../internal/p2/artifact/repository/SignatureVerifier.java | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/bundles/org.eclipse.equinox.p2.artifact.repository/src/org/eclipse/equinox/internal/p2/artifact/repository/SignatureVerifier.java b/bundles/org.eclipse.equinox.p2.artifact.repository/src/org/eclipse/equinox/internal/p2/artifact/repository/SignatureVerifier.java index 99c9080ac..1b93ffcec 100644 --- a/bundles/org.eclipse.equinox.p2.artifact.repository/src/org/eclipse/equinox/internal/p2/artifact/repository/SignatureVerifier.java +++ b/bundles/org.eclipse.equinox.p2.artifact.repository/src/org/eclipse/equinox/internal/p2/artifact/repository/SignatureVerifier.java @@ -1,5 +1,5 @@ /******************************************************************************* -* Copyright (c) 2007, 2010 compeople AG and others. +* Copyright (c) 2007, 2013 compeople AG and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at @@ -14,6 +14,7 @@ package org.eclipse.equinox.internal.p2.artifact.repository; import java.io.*; import java.security.GeneralSecurityException; import java.util.ArrayList; +import java.util.zip.ZipException; import org.eclipse.core.runtime.*; import org.eclipse.equinox.internal.p2.core.helpers.FileUtils; import org.eclipse.equinox.internal.p2.core.helpers.ServiceHelper; @@ -77,6 +78,13 @@ public class SignatureVerifier extends ProcessingStep { signedContent = verifierFactory.getSignedContent(inputFile); } catch (GeneralSecurityException e) { return new Status(IStatus.ERROR, Activator.ID, MirrorRequest.ARTIFACT_PROCESSING_ERROR, Messages.SignatureVerification_failedRead + inputFile, e); + } catch (ZipException e) { + // SignedContentFactory behavior changed to throw a ZipException if the + // file is not a valid zip file, before it would just return an empty unsigned content object. + // Here we return OK_STATUS just to keep previous behavior with the assumption that an error + // will be detected for the invalid artifact later. + // TODO is this valid? + return Status.OK_STATUS; } ArrayList allStatus = new ArrayList(0); SignedContentEntry[] entries = signedContent.getSignedEntries(); -- cgit v1.2.3