Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
Diffstat (limited to 'bundles/org.eclipse.equinox.p2.artifact.repository')
-rw-r--r--bundles/org.eclipse.equinox.p2.artifact.repository/schema/artifactChecksums.exsd38
-rw-r--r--bundles/org.eclipse.equinox.p2.artifact.repository/src/org/eclipse/equinox/internal/p2/artifact/processors/checksum/ChecksumUtilities.java19
-rw-r--r--bundles/org.eclipse.equinox.p2.artifact.repository/src/org/eclipse/equinox/internal/p2/artifact/processors/checksum/ChecksumVerifier.java13
-rw-r--r--bundles/org.eclipse.equinox.p2.artifact.repository/src/org/eclipse/equinox/internal/p2/artifact/repository/Messages.java1
-rw-r--r--bundles/org.eclipse.equinox.p2.artifact.repository/src/org/eclipse/equinox/internal/p2/artifact/repository/messages.properties5
5 files changed, 54 insertions, 22 deletions
diff --git a/bundles/org.eclipse.equinox.p2.artifact.repository/schema/artifactChecksums.exsd b/bundles/org.eclipse.equinox.p2.artifact.repository/schema/artifactChecksums.exsd
index 8c2a30612..0f7b4b097 100644
--- a/bundles/org.eclipse.equinox.p2.artifact.repository/schema/artifactChecksums.exsd
+++ b/bundles/org.eclipse.equinox.p2.artifact.repository/schema/artifactChecksums.exsd
@@ -69,6 +69,13 @@ As other tools will rely on this id, consider using some well-defined value (i.e
</documentation>
</annotation>
</attribute>
+ <attribute name="providerName" type="string">
+ <annotation>
+ <documentation>
+ For custom security provider, name of the security provider that provides this message digest implementation, the value returned by &lt;code&gt;java.security.Provider.getName()&lt;/code&gt;.
+ </documentation>
+ </annotation>
+ </attribute>
</complexType>
</element>
@@ -97,18 +104,35 @@ As other tools will rely on this id, consider using some well-defined value (i.e
&lt;/extension&gt;
&lt;/pre&gt;
-If the MessageDigest implementation is provided by a custom Provider (from the contributing bundle itself or some other bundle), it should be first dynamically registered:
+If the MessageDigest implementation is provided by a custom security provider (from the contributing bundle itself or some other bundle), it should be registered first with the Framework service registry under interface &lt;code&gt;java.security.Provider&lt;/code&gt;:
&lt;pre&gt;
-import java.security.Security;
+import java.security.Provider;
+import java.util.Dictionary;
+import java.util.Hashtable;
+
import org.bouncycastle.jce.provider.BouncyCastleProvider;
+import org.osgi.framework.BundleActivator;
+import org.osgi.framework.BundleContext;
+import org.osgi.framework.ServiceRegistration;
+
+...
-public class Activator implements BundleActivator {
+Dictionary&lt;String, Object&gt; props = new Hashtable&lt;&gt;();
+props.put(&quot;providerName&quot;, &quot;BC&quot;);
+ServiceRegistration&lt;Provider&gt; registration = context.registerService(Provider.class, new BouncyCastleProvider(), props);
+&lt;/pre&gt;
+
+and then register an extension using &lt;code&gt;providerName&lt;/code&gt; attribute:
- public void start(BundleContext context) throws Exception {
- Security.addProvider(new BouncyCastleProvider());
- }
-}
+&lt;pre&gt;
+&lt;extension point=&quot;org.eclipse.equinox.p2.artifact.repository.artifactChecksums&quot;&gt;
+ &lt;artifactChecksum
+ algorithm=&quot;Whirlpool&quot;
+ id=&quot;whirlpool&quot;
+ providerName=&quot;BC&quot;&gt;
+ &lt;/artifactChecksum&gt;
+&lt;/extension&gt;
&lt;/pre&gt;
</documentation>
</annotation>
diff --git a/bundles/org.eclipse.equinox.p2.artifact.repository/src/org/eclipse/equinox/internal/p2/artifact/processors/checksum/ChecksumUtilities.java b/bundles/org.eclipse.equinox.p2.artifact.repository/src/org/eclipse/equinox/internal/p2/artifact/processors/checksum/ChecksumUtilities.java
index 012b39688..f45b7f203 100644
--- a/bundles/org.eclipse.equinox.p2.artifact.repository/src/org/eclipse/equinox/internal/p2/artifact/processors/checksum/ChecksumUtilities.java
+++ b/bundles/org.eclipse.equinox.p2.artifact.repository/src/org/eclipse/equinox/internal/p2/artifact/processors/checksum/ChecksumUtilities.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
@@ -16,6 +16,7 @@ package org.eclipse.equinox.internal.p2.artifact.processors.checksum;
import java.io.File;
import java.io.IOException;
import java.security.NoSuchAlgorithmException;
+import java.security.NoSuchProviderException;
import java.util.*;
import java.util.Map.Entry;
import org.eclipse.core.runtime.*;
@@ -56,7 +57,8 @@ public class ChecksumUtilities {
String checksumId = checksumVerifierConfiguration.getAttribute("id"); //$NON-NLS-1$
if (checksumEntry.getKey().equals(checksumId)) {
String checksumAlgorithm = checksumVerifierConfiguration.getAttribute("algorithm"); //$NON-NLS-1$
- ChecksumVerifier checksumVerifier = new ChecksumVerifier(checksumAlgorithm, checksumId);
+ String providerName = checksumVerifierConfiguration.getAttribute("providerName"); //$NON-NLS-1$
+ ChecksumVerifier checksumVerifier = new ChecksumVerifier(checksumAlgorithm, providerName, checksumId);
checksumVerifier.initialize(null, new ProcessingStepDescriptor(null, checksumEntry.getValue(), true), descriptor);
if (checksumVerifier.getStatus().isOK())
steps.add(checksumVerifier);
@@ -91,21 +93,22 @@ public class ChecksumUtilities {
// don't calculate checksum if algo is disabled
continue;
String algorithm = checksumVerifierConfiguration.getAttribute("algorithm"); //$NON-NLS-1$
- Optional<String> checksum = calculateChecksum(pathOnDisk, status, id, algorithm);
+ String providerName = checksumVerifierConfiguration.getAttribute("providerName"); //$NON-NLS-1$
+ Optional<String> checksum = calculateChecksum(pathOnDisk, status, id, algorithm, providerName);
checksum.ifPresent(c -> checksums.put(id, c));
}
return status;
}
- private static Optional<String> calculateChecksum(File pathOnDisk, MultiStatus status, String id, String algorithm) {
+ private static Optional<String> calculateChecksum(File pathOnDisk, MultiStatus status, String id, String algorithm, String providerName) {
try {
- String checksum = ChecksumProducer.produce(pathOnDisk, algorithm);
- String message = NLS.bind(Messages.calculateChecksum_ok, new Object[] {id, algorithm, checksum});
+ String checksum = ChecksumProducer.produce(pathOnDisk, algorithm, providerName);
+ String message = NLS.bind(Messages.calculateChecksum_ok, new Object[] {id, algorithm, providerName, checksum});
status.add(new Status(IStatus.OK, Activator.ID, message));
return Optional.of(checksum);
- } catch (NoSuchAlgorithmException e) {
- String message = NLS.bind(Messages.calculateChecksum_error, id, algorithm);
+ } catch (NoSuchAlgorithmException | NoSuchProviderException e) {
+ String message = NLS.bind(Messages.calculateChecksum_providerError, new Object[] {id, algorithm, providerName});
status.add(new Status(IStatus.ERROR, Activator.ID, message, e));
} catch (IOException e) {
String message = NLS.bind(Messages.calculateChecksum_error, id, algorithm);
diff --git a/bundles/org.eclipse.equinox.p2.artifact.repository/src/org/eclipse/equinox/internal/p2/artifact/processors/checksum/ChecksumVerifier.java b/bundles/org.eclipse.equinox.p2.artifact.repository/src/org/eclipse/equinox/internal/p2/artifact/processors/checksum/ChecksumVerifier.java
index 34df102e6..4d913c46d 100644
--- a/bundles/org.eclipse.equinox.p2.artifact.repository/src/org/eclipse/equinox/internal/p2/artifact/processors/checksum/ChecksumVerifier.java
+++ b/bundles/org.eclipse.equinox.p2.artifact.repository/src/org/eclipse/equinox/internal/p2/artifact/processors/checksum/ChecksumVerifier.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
@@ -15,11 +15,12 @@ package org.eclipse.equinox.internal.p2.artifact.processors.checksum;
import static java.util.Optional.ofNullable;
-import java.security.MessageDigest;
import java.security.NoSuchAlgorithmException;
+import java.security.NoSuchProviderException;
import org.eclipse.core.runtime.IStatus;
import org.eclipse.core.runtime.Status;
import org.eclipse.equinox.internal.p2.artifact.repository.Activator;
+import org.eclipse.equinox.internal.p2.repository.helpers.ChecksumProducer;
import org.eclipse.equinox.p2.core.IProvisioningAgent;
import org.eclipse.equinox.p2.core.ProvisionException;
import org.eclipse.equinox.p2.repository.artifact.IArtifactDescriptor;
@@ -30,11 +31,13 @@ final public class ChecksumVerifier extends MessageDigestProcessingStep {
private String expectedChecksum;
final private String algorithmName;
+ final private String providerName;
final private String algorithmId;
// public to access from tests
- public ChecksumVerifier(String digestAlgorithm, String algorithmId) {
+ public ChecksumVerifier(String digestAlgorithm, String providerName, String algorithmId) {
this.algorithmName = digestAlgorithm;
+ this.providerName = providerName;
this.algorithmId = algorithmId;
basicInitialize(null);
}
@@ -56,9 +59,9 @@ final public class ChecksumVerifier extends MessageDigestProcessingStep {
private void basicInitialize(IProcessingStepDescriptor descriptor) {
try {
- messageDigest = MessageDigest.getInstance(algorithmName);
+ messageDigest = ChecksumProducer.getMessageDigest(algorithmName, providerName);
setStatus(Status.OK_STATUS);
- } catch (NoSuchAlgorithmException e) {
+ } catch (NoSuchProviderException | NoSuchAlgorithmException e) {
int code = buildErrorCode(descriptor);
setStatus(new Status(code, Activator.ID, NLS.bind(Messages.Error_checksum_unavailable, algorithmName), e));
}
diff --git a/bundles/org.eclipse.equinox.p2.artifact.repository/src/org/eclipse/equinox/internal/p2/artifact/repository/Messages.java b/bundles/org.eclipse.equinox.p2.artifact.repository/src/org/eclipse/equinox/internal/p2/artifact/repository/Messages.java
index 9208be003..f4eba31a3 100644
--- a/bundles/org.eclipse.equinox.p2.artifact.repository/src/org/eclipse/equinox/internal/p2/artifact/repository/Messages.java
+++ b/bundles/org.eclipse.equinox.p2.artifact.repository/src/org/eclipse/equinox/internal/p2/artifact/repository/Messages.java
@@ -70,6 +70,7 @@ public class Messages extends NLS {
public static String calculateChecksum_file;
public static String calculateChecksum_ok;
public static String calculateChecksum_error;
+ public static String calculateChecksum_providerError;
static {
// initialize resource bundles
diff --git a/bundles/org.eclipse.equinox.p2.artifact.repository/src/org/eclipse/equinox/internal/p2/artifact/repository/messages.properties b/bundles/org.eclipse.equinox.p2.artifact.repository/src/org/eclipse/equinox/internal/p2/artifact/repository/messages.properties
index 2efde4def..fa54c3f8c 100644
--- a/bundles/org.eclipse.equinox.p2.artifact.repository/src/org/eclipse/equinox/internal/p2/artifact/repository/messages.properties
+++ b/bundles/org.eclipse.equinox.p2.artifact.repository/src/org/eclipse/equinox/internal/p2/artifact/repository/messages.properties
@@ -55,8 +55,9 @@ exception_unsupportedGetOutputStream=Cannot write artifacts to a composite repos
exception_unsupportedRemoveFromComposite = Cannot remove descriptors from a composite repository.
calculateChecksum_file=Calculating checksums for file {0}.
-calculateChecksum_ok=Calculated checksum using id={0} algorithm={1}: {2}.
-calculateChecksum_error=Error calculating checksum using id={0} algorithm={1}.
+calculateChecksum_ok=Calculated checksum using id={0} algorithm={1} provider={2}: {3}.
+calculateChecksum_error=Error calculating checksum using id={0} algorithm={1} provider={2}.
+calculateChecksum_providerError=Checksum provider id={0} algorithm={1} provider={2} error.
exception_unableToCreateParentDir = Unable to create parent directory.
folder_artifact_not_file_repo=Artifact {0} is a folder but the repository is an archive or remote location.

Back to the top