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