Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMykola Nikishov2016-04-21 19:59:26 +0000
committerMykola Nikishov2019-07-08 17:47:43 +0000
commit568ec2758ef480b7a69dc8572bf80fa8f1b281b2 (patch)
tree60b685ade900b9b5463fc7710d9362e1e4dab6c2 /bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests
parent2bcad99a06945190c7baff4268f9fc459bc34dfd (diff)
downloadrt.equinox.p2-568ec2758ef480b7a69dc8572bf80fa8f1b281b2.tar.gz
rt.equinox.p2-568ec2758ef480b7a69dc8572bf80fa8f1b281b2.tar.xz
rt.equinox.p2-568ec2758ef480b7a69dc8572bf80fa8f1b281b2.zip
Extend o.e.e.p2.artifact.repository.artifactChecksums extension point with attribute providerName to support custom MessageDigest implementations as per Java Security API. To get an instance of custom MessageDigest in ChecksumProducer's getMessageDigest(String, String), look for service object under java.security.Provider interface filtered by providerName property and pass it to java.security.MessageDigest's getInstance(String, Provider). Throws NoSuchProviderException if no such service was found. Bundle that contributes such implementation should register it with the Framework service registry under interface java.security.Provider. The registration properties of the service should contain property 'providerName' with value of type String as returned by implementation's java.security.Provider.getName(). The same value should be used for providerName attribute in artifactChecksums extension point. o.e.equinox.p2.artifact.checksums.bouncycastle bundle demonstrates how this works by adding support for Whirlpool and DSTU7564 message digests using the Bouncy Castle Crypto APIs [1]. It is not part of the distribution and used by unit tests only. [1] https://bouncycastle.org/ Change-Id: I0cfd06ceca6e1911d69bab09331399500a00dcee Signed-off-by: Mykola Nikishov <mn@mn.com.ua>
Diffstat (limited to 'bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests')
-rw-r--r--bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/artifact/processors/ChecksumUtilitiesTest.java8
-rw-r--r--bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/artifact/processors/ChecksumVerifierTest.java32
-rw-r--r--bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/publisher/ChecksumGenerationTest.java7
3 files changed, 34 insertions, 13 deletions
diff --git a/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/artifact/processors/ChecksumUtilitiesTest.java b/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/artifact/processors/ChecksumUtilitiesTest.java
index 9b2ba1052..9f95fbdcd 100644
--- a/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/artifact/processors/ChecksumUtilitiesTest.java
+++ b/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/artifact/processors/ChecksumUtilitiesTest.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2018 Mykola Nikishov
+ * Copyright (c) 2018, 2019 Mykola Nikishov
*
* This program and the accompanying materials
* are made available under the terms of the Eclipse Public License 2.0
@@ -54,9 +54,13 @@ public class ChecksumUtilitiesTest {
return asList(new Object[][] {{IArtifactDescriptor.ARTIFACT_CHECKSUM, IArtifactDescriptor.ARTIFACT_MD5, "123456789_123456789_123456789_12", "MD5", "md5"},
{IArtifactDescriptor.ARTIFACT_CHECKSUM, IArtifactDescriptor.ARTIFACT_CHECKSUM.concat(".md5"), "123456789_123456789_123456789_12", "MD5", "md5"},
{IArtifactDescriptor.ARTIFACT_CHECKSUM, IArtifactDescriptor.ARTIFACT_CHECKSUM.concat(".sha-256"), "123456789_123456789_123456789_123456789_123456789_123456789_1234", "SHA-256", "sha-256"},
+ {IArtifactDescriptor.ARTIFACT_CHECKSUM, IArtifactDescriptor.ARTIFACT_CHECKSUM.concat(".dstu7564-512"), "123456789_123456789_123456789_123456789_123456789_123456789_1234", "DSTU7564-512", "dstu7564-512"},
+ {IArtifactDescriptor.ARTIFACT_CHECKSUM, IArtifactDescriptor.ARTIFACT_CHECKSUM.concat(".whirlpool"), "123456789_123456789_123456789_123456789_123456789_123456789_1234", "Whirlpool", "whirlpool"},
{IArtifactDescriptor.DOWNLOAD_CHECKSUM, IArtifactDescriptor.DOWNLOAD_MD5, "123456789_123456789_123456789_12", "MD5", "md5"},
{IArtifactDescriptor.DOWNLOAD_CHECKSUM, IArtifactDescriptor.DOWNLOAD_CHECKSUM.concat(".md5"), "123456789_123456789_123456789_12", "MD5", "md5"},
- {IArtifactDescriptor.DOWNLOAD_CHECKSUM, IArtifactDescriptor.DOWNLOAD_CHECKSUM.concat(".sha-256"), "123456789_123456789_123456789_123456789_123456789_123456789_1234", "SHA-256", "sha-256"}});
+ {IArtifactDescriptor.DOWNLOAD_CHECKSUM, IArtifactDescriptor.DOWNLOAD_CHECKSUM.concat(".sha-256"), "123456789_123456789_123456789_123456789_123456789_123456789_1234", "SHA-256", "sha-256"},
+ {IArtifactDescriptor.DOWNLOAD_CHECKSUM, IArtifactDescriptor.DOWNLOAD_CHECKSUM.concat(".dstu7564-512"), "123456789_123456789_123456789_123456789_123456789_123456789_1234", "DSTU7564-512", "dstu7564-512"},
+ {IArtifactDescriptor.DOWNLOAD_CHECKSUM, IArtifactDescriptor.DOWNLOAD_CHECKSUM.concat(".whirlpool"), "123456789_123456789_123456789_123456789_123456789_123456789_1234", "Whirlpool", "whirlpool"}});
}
private ArtifactDescriptor artifactDescriptor;
diff --git a/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/artifact/processors/ChecksumVerifierTest.java b/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/artifact/processors/ChecksumVerifierTest.java
index 3c7fe791b..fb012897e 100644
--- a/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/artifact/processors/ChecksumVerifierTest.java
+++ b/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/artifact/processors/ChecksumVerifierTest.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2015, 2018 Mykola Nikishov.
+ * Copyright (c) 2015, 2019 Mykola Nikishov.
*
* This program and the accompanying materials
* are made available under the terms of the Eclipse Public License 2.0
@@ -13,7 +13,12 @@
*******************************************************************************/
package org.eclipse.equinox.p2.tests.artifact.processors;
-import static org.easymock.EasyMock.*;
+import static org.easymock.EasyMock.createMock;
+import static org.easymock.EasyMock.eq;
+import static org.easymock.EasyMock.expect;
+import static org.easymock.EasyMock.not;
+import static org.easymock.EasyMock.replay;
+import static org.easymock.EasyMock.verify;
import java.io.IOException;
import java.util.Arrays;
@@ -35,19 +40,26 @@ public class ChecksumVerifierTest {
@Parameters
public static Collection<Object[]> generateData() {
return Arrays.asList(new Object[][] {
- {"MD5", "md5", IArtifactDescriptor.DOWNLOAD_CHECKSUM.concat(".md5"), IArtifactDescriptor.ARTIFACT_CHECKSUM.concat(".md5"), "123456789_123456789_123456789_12"},
- {"SHA-256", "sha-256", IArtifactDescriptor.DOWNLOAD_CHECKSUM.concat(".sha-256"), IArtifactDescriptor.ARTIFACT_CHECKSUM.concat(".sha-256"), "123456789_123456789_123456789_123456789_123456789_123456789_1234"}});
+ // legacy MD5 checksum location
+ {"MD5", null, "md5", IArtifactDescriptor.DOWNLOAD_MD5, IArtifactDescriptor.ARTIFACT_MD5, "123456789_123456789_123456789_12"},
+ // new checksum location
+ {"MD5", null, "md5", IArtifactDescriptor.DOWNLOAD_CHECKSUM.concat(".md5"), IArtifactDescriptor.ARTIFACT_CHECKSUM.concat(".md5"), "123456789_123456789_123456789_12"},
+ {"SHA-256", null, "sha-256", IArtifactDescriptor.DOWNLOAD_CHECKSUM.concat(".sha-256"), IArtifactDescriptor.ARTIFACT_CHECKSUM.concat(".sha-256"), "123456789_123456789_123456789_123456789_123456789_123456789_1234"},
+ {"Whirlpool", "BC", "whirlpool", IArtifactDescriptor.DOWNLOAD_CHECKSUM.concat(".whirlpool"), IArtifactDescriptor.ARTIFACT_CHECKSUM.concat(".whirlpool"), "f3073bf4b0867c7456850fbe317b322c03b00198e15fe40b9a455abde6e1c77e31d6ed6963a6755564a1adec0ed9bb8aac71d4a457256a85e9fc55a964ede598"},
+ {"DSTU7564-512", "BC", "dstu7564-512", IArtifactDescriptor.DOWNLOAD_CHECKSUM.concat(".dstu7564-512"), IArtifactDescriptor.ARTIFACT_CHECKSUM.concat(".dstu7564-512"), "b776aaeae5c45826515365fe017138eb6ac1e1ad866f7b7bcfba2ca752268afc493e3c19a9217e1ae07733676efb81123e5677dcadaf5c0ca1b530ab9f718b2c"}});
}
@Parameter(0)
public String digestAlgorithm;
@Parameter(1)
- public String algorithmId;
+ public String providerName;
@Parameter(2)
- public String downloadProperty;
+ public String algorithmId;
@Parameter(3)
- public String artifactProperty;
+ public String downloadProperty;
@Parameter(4)
+ public String artifactProperty;
+ @Parameter(5)
public String checksum;
@Test
@@ -56,7 +68,7 @@ public class ChecksumVerifierTest {
expect(processingStepDescriptor.getData()).andReturn(checksum);
replay(processingStepDescriptor);
- ChecksumVerifier verifier = new ChecksumVerifier(digestAlgorithm, algorithmId);
+ ChecksumVerifier verifier = new ChecksumVerifier(digestAlgorithm, providerName, algorithmId);
verifier.initialize(null, processingStepDescriptor, null);
@@ -79,7 +91,7 @@ public class ChecksumVerifierTest {
expect(artifactDescriptor.getProperties()).andReturn(properties);
replay(artifactDescriptor);
- ChecksumVerifier verifier = new ChecksumVerifier(digestAlgorithm, algorithmId);
+ ChecksumVerifier verifier = new ChecksumVerifier(digestAlgorithm, providerName, algorithmId);
verifier.initialize(null, processingStepDescriptor, artifactDescriptor);
@@ -102,7 +114,7 @@ public class ChecksumVerifierTest {
expect(artifactDescriptor.getProperty(not(eq(artifactProperty)))).andReturn(null).times(1, 2);
replay(artifactDescriptor);
- ChecksumVerifier verifier = new ChecksumVerifier(digestAlgorithm, algorithmId);
+ ChecksumVerifier verifier = new ChecksumVerifier(digestAlgorithm, providerName, algorithmId);
verifier.initialize(null, processingStepDescriptor, artifactDescriptor);
diff --git a/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/publisher/ChecksumGenerationTest.java b/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/publisher/ChecksumGenerationTest.java
index 08ff10842..8b9d303a7 100644
--- a/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/publisher/ChecksumGenerationTest.java
+++ b/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/publisher/ChecksumGenerationTest.java
@@ -37,7 +37,12 @@ public class ChecksumGenerationTest extends AbstractProvisioningTest {
@Parameters
public static Collection<Object[]> generateChecksums() {
- return Arrays.asList(new Object[][] {{IArtifactDescriptor.DOWNLOAD_MD5, "50d4ea58b02706ab373a908338877e02"}, {IArtifactDescriptor.DOWNLOAD_CHECKSUM.concat(".sha-256"), "11da2dd636ab76f460513cbcbfe8c56a6e5ad47aa9b38b36c6d04f8ee7722252"}});
+ return Arrays.asList(new Object[][] {{IArtifactDescriptor.DOWNLOAD_MD5, "50d4ea58b02706ab373a908338877e02"},
+ {IArtifactDescriptor.DOWNLOAD_CHECKSUM.concat(".md5"), "50d4ea58b02706ab373a908338877e02"},
+ {IArtifactDescriptor.DOWNLOAD_CHECKSUM.concat(".sha-256"), "11da2dd636ab76f460513cbcbfe8c56a6e5ad47aa9b38b36c6d04f8ee7722252"},
+ // TODO values are from the BC itself, check by external means
+ {IArtifactDescriptor.DOWNLOAD_CHECKSUM.concat(".dstu7564-512"), "b776aaeae5c45826515365fe017138eb6ac1e1ad866f7b7bcfba2ca752268afc493e3c19a9217e1ae07733676efb81123e5677dcadaf5c0ca1b530ab9f718b2c"},
+ {IArtifactDescriptor.DOWNLOAD_CHECKSUM.concat(".whirlpool"), "b951e497a53600173a0c464d451672086175530deaffb9f376962153e573e99de53131910ea9c3c8243afb73444dadfade5989dc6f8c6e4a96141eaf956daa22"}});
}
@Test

Back to the top