Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMykola Nikishov2018-01-27 07:00:46 -0500
committerAlexander Kurtakov2018-01-31 02:31:05 -0500
commit6d666004be0ecf6cfe36180e8585010b1602044a (patch)
treebe5850b2153bd229041543cb6b472c8f8cafaf4c
parent5358b3b9924cc59de38929f6e0817f904f5bde64 (diff)
downloadrt.equinox.p2-6d666004be0ecf6cfe36180e8585010b1602044a.tar.gz
rt.equinox.p2-6d666004be0ecf6cfe36180e8585010b1602044a.tar.xz
rt.equinox.p2-6d666004be0ecf6cfe36180e8585010b1602044a.zip
Bug 423715 - Add SHA256 to p2 metadata publishingI20180201-0200I20180131-2000
Extract method to add checksum verifier to processing steps Change-Id: Id3dccedc687afee6faf97a66d21873e98a52717a Signed-off-by: Mykola Nikishov <mn@mn.com.ua>
-rw-r--r--bundles/org.eclipse.equinox.p2.artifact.repository/src/org/eclipse/equinox/internal/p2/artifact/repository/simple/SimpleArtifactRepository.java16
1 files changed, 12 insertions, 4 deletions
diff --git a/bundles/org.eclipse.equinox.p2.artifact.repository/src/org/eclipse/equinox/internal/p2/artifact/repository/simple/SimpleArtifactRepository.java b/bundles/org.eclipse.equinox.p2.artifact.repository/src/org/eclipse/equinox/internal/p2/artifact/repository/simple/SimpleArtifactRepository.java
index 9053227f2..69905d5f9 100644
--- a/bundles/org.eclipse.equinox.p2.artifact.repository/src/org/eclipse/equinox/internal/p2/artifact/repository/simple/SimpleArtifactRepository.java
+++ b/bundles/org.eclipse.equinox.p2.artifact.repository/src/org/eclipse/equinox/internal/p2/artifact/repository/simple/SimpleArtifactRepository.java
@@ -459,8 +459,8 @@ public class SimpleArtifactRepository extends AbstractArtifactRepository impleme
private synchronized OutputStream addPostSteps(ProcessingStepHandler handler, IArtifactDescriptor descriptor, OutputStream destination, IProgressMonitor monitor) {
ArrayList<ProcessingStep> steps = new ArrayList<>();
steps.add(new SignatureVerifier());
- if (ARTIFACT_MD5_CHECKSUM_ENABLED && descriptor.getProperty(IArtifactDescriptor.ARTIFACT_MD5) != null)
- steps.add(new MD5Verifier(descriptor.getProperty(IArtifactDescriptor.ARTIFACT_MD5)));
+ addChecksumVerifiers(steps, ARTIFACT_MD5_CHECKSUM_ENABLED, descriptor.getProperty(IArtifactDescriptor.ARTIFACT_MD5));
+
if (steps.isEmpty())
return destination;
ProcessingStep[] stepArray = steps.toArray(new ProcessingStep[steps.size()]);
@@ -472,8 +472,8 @@ public class SimpleArtifactRepository extends AbstractArtifactRepository impleme
ArrayList<ProcessingStep> steps = new ArrayList<>();
if (IArtifactDescriptor.TYPE_ZIP.equals(descriptor.getProperty(IArtifactDescriptor.DOWNLOAD_CONTENTTYPE)))
steps.add(new ZipVerifierStep());
- if (DOWNLOAD_MD5_CHECKSUM_ENABLED && descriptor.getProperty(IArtifactDescriptor.DOWNLOAD_MD5) != null)
- steps.add(new MD5Verifier(descriptor.getProperty(IArtifactDescriptor.DOWNLOAD_MD5)));
+ addChecksumVerifiers(steps, DOWNLOAD_MD5_CHECKSUM_ENABLED, descriptor.getProperty(IArtifactDescriptor.DOWNLOAD_MD5));
+
// Add steps here if needed
if (steps.isEmpty())
return destination;
@@ -482,6 +482,14 @@ public class SimpleArtifactRepository extends AbstractArtifactRepository impleme
return handler.link(stepArray, destination, monitor);
}
+ /**
+ * Adds checksum verifier to steps only if isChecksumEnabled and checksum is not null
+ */
+ private void addChecksumVerifiers(ArrayList<ProcessingStep> steps, boolean isChecksumEnabled, String checksum) {
+ if (isChecksumEnabled && checksum != null)
+ steps.add(new MD5Verifier(checksum));
+ }
+
private byte[] bytesFromHexString(String string) {
byte[] bytes = new byte[UniversalUniqueIdentifier.BYTES_SIZE];
for (int i = 0; i < string.length(); i += 2) {

Back to the top