|
|
8ccff0 |
diff --git a/ivy.xml b/ivy.xml
|
|
|
8ccff0 |
index d448897..7d8896a 100644
|
|
|
8ccff0 |
--- a/ivy.xml
|
|
|
8ccff0 |
+++ b/ivy.xml
|
|
|
8ccff0 |
@@ -50,8 +50,8 @@
|
|
|
8ccff0 |
<dependency org="com.jcraft" name="jsch.agentproxy" rev="0.0.6" conf="default,sftp->default"/>
|
|
|
8ccff0 |
<dependency org="com.jcraft" name="jsch.agentproxy.connector-factory" rev="0.0.6" conf="default,sftp->default"/>
|
|
|
8ccff0 |
<dependency org="com.jcraft" name="jsch.agentproxy.jsch" rev="0.0.6" conf="default,sftp->default"/>
|
|
|
8ccff0 |
- <dependency org="org.bouncycastle" name="bcpg-jdk14" rev="1.45" conf="default"/>
|
|
|
8ccff0 |
- <dependency org="org.bouncycastle" name="bcprov-jdk14" rev="1.45" conf="default"/>
|
|
|
8ccff0 |
+ <dependency org="org.bouncycastle" name="bcpg-jdk15on" rev="1.52" conf="default"/>
|
|
|
8ccff0 |
+ <dependency org="org.bouncycastle" name="bcprov-jdk15on" rev="1.52" conf="default"/>
|
|
|
8ccff0 |
|
|
|
8ccff0 |
|
|
|
8ccff0 |
<dependency org="junit" name="junit" rev="3.8.2" conf="test->default"/>
|
|
|
8ccff0 |
diff --git a/src/java/org/apache/ivy/plugins/signer/bouncycastle/OpenPGPSignatureGenerator.java b/src/java/org/apache/ivy/plugins/signer/bouncycastle/OpenPGPSignatureGenerator.java
|
|
|
8ccff0 |
index af7beae..bec8ae4 100644
|
|
|
8ccff0 |
--- a/src/java/org/apache/ivy/plugins/signer/bouncycastle/OpenPGPSignatureGenerator.java
|
|
|
8ccff0 |
+++ b/src/java/org/apache/ivy/plugins/signer/bouncycastle/OpenPGPSignatureGenerator.java
|
|
|
8ccff0 |
@@ -23,16 +23,18 @@ import java.io.FileOutputStream;
|
|
|
8ccff0 |
import java.io.IOException;
|
|
|
8ccff0 |
import java.io.InputStream;
|
|
|
8ccff0 |
import java.io.OutputStream;
|
|
|
8ccff0 |
-import java.security.NoSuchAlgorithmException;
|
|
|
8ccff0 |
-import java.security.NoSuchProviderException;
|
|
|
8ccff0 |
import java.security.Security;
|
|
|
8ccff0 |
-import java.security.SignatureException;
|
|
|
8ccff0 |
import java.util.Iterator;
|
|
|
8ccff0 |
|
|
|
8ccff0 |
import org.apache.ivy.plugins.signer.SignatureGenerator;
|
|
|
8ccff0 |
import org.bouncycastle.bcpg.ArmoredOutputStream;
|
|
|
8ccff0 |
import org.bouncycastle.bcpg.BCPGOutputStream;
|
|
|
8ccff0 |
import org.bouncycastle.jce.provider.BouncyCastleProvider;
|
|
|
8ccff0 |
+import org.bouncycastle.openpgp.operator.PBESecretKeyDecryptor;
|
|
|
8ccff0 |
+import org.bouncycastle.openpgp.operator.bc.BcKeyFingerprintCalculator;
|
|
|
8ccff0 |
+import org.bouncycastle.openpgp.operator.bc.BcPBESecretKeyDecryptorBuilder;
|
|
|
8ccff0 |
+import org.bouncycastle.openpgp.operator.bc.BcPGPContentSignerBuilder;
|
|
|
8ccff0 |
+import org.bouncycastle.openpgp.operator.bc.BcPGPDigestCalculatorProvider;
|
|
|
8ccff0 |
import org.bouncycastle.openpgp.PGPException;
|
|
|
8ccff0 |
import org.bouncycastle.openpgp.PGPPrivateKey;
|
|
|
8ccff0 |
import org.bouncycastle.openpgp.PGPSecretKey;
|
|
|
8ccff0 |
@@ -101,11 +103,13 @@ public class OpenPGPSignatureGenerator implements SignatureGenerator {
|
|
|
8ccff0 |
pgpSec = readSecretKey(keyIn);
|
|
|
8ccff0 |
}
|
|
|
8ccff0 |
|
|
|
8ccff0 |
- PGPPrivateKey pgpPrivKey = pgpSec.extractPrivateKey(password.toCharArray(),
|
|
|
8ccff0 |
- BouncyCastleProvider.PROVIDER_NAME);
|
|
|
8ccff0 |
- PGPSignatureGenerator sGen = new PGPSignatureGenerator(pgpSec.getPublicKey()
|
|
|
8ccff0 |
- .getAlgorithm(), PGPUtil.SHA1, BouncyCastleProvider.PROVIDER_NAME);
|
|
|
8ccff0 |
- sGen.initSign(PGPSignature.BINARY_DOCUMENT, pgpPrivKey);
|
|
|
8ccff0 |
+ PBESecretKeyDecryptor decryptor = new BcPBESecretKeyDecryptorBuilder(
|
|
|
8ccff0 |
+ new BcPGPDigestCalculatorProvider()).build(password.toCharArray());
|
|
|
8ccff0 |
+ PGPPrivateKey pgpPrivKey = pgpSec.extractPrivateKey(decryptor);
|
|
|
8ccff0 |
+ PGPSignatureGenerator sGen = new PGPSignatureGenerator(
|
|
|
8ccff0 |
+ new BcPGPContentSignerBuilder(pgpSec.getPublicKey()
|
|
|
8ccff0 |
+ .getAlgorithm(), PGPUtil.SHA1));
|
|
|
8ccff0 |
+ sGen.init(PGPSignature.BINARY_DOCUMENT, pgpPrivKey);
|
|
|
8ccff0 |
|
|
|
8ccff0 |
in = new FileInputStream(src);
|
|
|
8ccff0 |
out = new BCPGOutputStream(new ArmoredOutputStream(new FileOutputStream(dest)));
|
|
|
8ccff0 |
@@ -116,22 +120,10 @@ public class OpenPGPSignatureGenerator implements SignatureGenerator {
|
|
|
8ccff0 |
}
|
|
|
8ccff0 |
|
|
|
8ccff0 |
sGen.generate().encode(out);
|
|
|
8ccff0 |
- } catch (SignatureException e) {
|
|
|
8ccff0 |
- IOException ioexc = new IOException();
|
|
|
8ccff0 |
- ioexc.initCause(e);
|
|
|
8ccff0 |
- throw ioexc;
|
|
|
8ccff0 |
} catch (PGPException e) {
|
|
|
8ccff0 |
IOException ioexc = new IOException();
|
|
|
8ccff0 |
ioexc.initCause(e);
|
|
|
8ccff0 |
throw ioexc;
|
|
|
8ccff0 |
- } catch (NoSuchAlgorithmException e) {
|
|
|
8ccff0 |
- IOException ioexc = new IOException();
|
|
|
8ccff0 |
- ioexc.initCause(e);
|
|
|
8ccff0 |
- throw ioexc;
|
|
|
8ccff0 |
- } catch (NoSuchProviderException e) {
|
|
|
8ccff0 |
- IOException ioexc = new IOException();
|
|
|
8ccff0 |
- ioexc.initCause(e);
|
|
|
8ccff0 |
- throw ioexc;
|
|
|
8ccff0 |
} finally {
|
|
|
8ccff0 |
if (out != null) {
|
|
|
8ccff0 |
try {
|
|
|
8ccff0 |
@@ -156,7 +148,8 @@ public class OpenPGPSignatureGenerator implements SignatureGenerator {
|
|
|
8ccff0 |
|
|
|
8ccff0 |
private PGPSecretKey readSecretKey(InputStream in) throws IOException, PGPException {
|
|
|
8ccff0 |
in = PGPUtil.getDecoderStream(in);
|
|
|
8ccff0 |
- PGPSecretKeyRingCollection pgpSec = new PGPSecretKeyRingCollection(in);
|
|
|
8ccff0 |
+ PGPSecretKeyRingCollection pgpSec = new PGPSecretKeyRingCollection(in,
|
|
|
8ccff0 |
+ new BcKeyFingerprintCalculator());
|
|
|
8ccff0 |
|
|
|
8ccff0 |
PGPSecretKey key = null;
|
|
|
8ccff0 |
for (Iterator it = pgpSec.getKeyRings(); key == null && it.hasNext();) {
|