mirror of
https://github.com/pgpainless/pgpainless.git
synced 2025-09-10 18:59:39 +02:00
Workaround for #159: Avoid to prevent swallowing IOExceptions
This commit is contained in:
parent
10bb033e40
commit
fc311fe781
25 changed files with 216 additions and 72 deletions
|
@ -23,8 +23,8 @@ import java.nio.charset.Charset;
|
|||
import java.util.Arrays;
|
||||
|
||||
import org.bouncycastle.bcpg.ArmoredOutputStream;
|
||||
import org.bouncycastle.util.io.Streams;
|
||||
import org.pgpainless.util.ArmoredOutputStreamFactory;
|
||||
import org.pgpainless.util.StreamUtil;
|
||||
import sop.Ready;
|
||||
import sop.enums.ArmorLabel;
|
||||
import sop.exception.SOPGPException;
|
||||
|
@ -57,10 +57,10 @@ public class ArmorImpl implements Armor {
|
|||
int read = pbIn.read(buffer);
|
||||
pbIn.unread(buffer, 0, read);
|
||||
if (!allowNested && Arrays.equals(ARMOR_START, buffer)) {
|
||||
Streams.pipeAll(pbIn, System.out);
|
||||
StreamUtil.pipeAll(pbIn, System.out);
|
||||
} else {
|
||||
ArmoredOutputStream armor = ArmoredOutputStreamFactory.get(System.out);
|
||||
Streams.pipeAll(pbIn, armor);
|
||||
StreamUtil.pipeAll(pbIn, armor);
|
||||
armor.close();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -20,7 +20,7 @@ import java.io.InputStream;
|
|||
import java.io.OutputStream;
|
||||
|
||||
import org.bouncycastle.openpgp.PGPUtil;
|
||||
import org.bouncycastle.util.io.Streams;
|
||||
import org.pgpainless.util.StreamUtil;
|
||||
import sop.Ready;
|
||||
import sop.operation.Dearmor;
|
||||
|
||||
|
@ -32,7 +32,7 @@ public class DearmorImpl implements Dearmor {
|
|||
return new Ready() {
|
||||
@Override
|
||||
public void writeTo(OutputStream outputStream) throws IOException {
|
||||
Streams.pipeAll(decoder, outputStream);
|
||||
StreamUtil.pipeAll(decoder, outputStream);
|
||||
decoder.close();
|
||||
}
|
||||
};
|
||||
|
|
|
@ -27,7 +27,6 @@ import org.bouncycastle.openpgp.PGPPublicKeyRingCollection;
|
|||
import org.bouncycastle.openpgp.PGPSecretKeyRing;
|
||||
import org.bouncycastle.openpgp.PGPSecretKeyRingCollection;
|
||||
import org.bouncycastle.openpgp.PGPSignature;
|
||||
import org.bouncycastle.util.io.Streams;
|
||||
import org.pgpainless.PGPainless;
|
||||
import org.pgpainless.decryption_verification.ConsumerOptions;
|
||||
import org.pgpainless.decryption_verification.DecryptionStream;
|
||||
|
@ -37,6 +36,7 @@ import org.pgpainless.key.SubkeyIdentifier;
|
|||
import org.pgpainless.key.info.KeyRingInfo;
|
||||
import org.pgpainless.key.protection.SecretKeyRingProtector;
|
||||
import org.pgpainless.util.Passphrase;
|
||||
import org.pgpainless.util.StreamUtil;
|
||||
import sop.DecryptionResult;
|
||||
import sop.ReadyWithResult;
|
||||
import sop.SessionKey;
|
||||
|
@ -151,7 +151,7 @@ public class DecryptImpl implements Decrypt {
|
|||
return new ReadyWithResult<DecryptionResult>() {
|
||||
@Override
|
||||
public DecryptionResult writeTo(OutputStream outputStream) throws IOException, SOPGPException.NoSignature {
|
||||
Streams.pipeAll(decryptionStream, outputStream);
|
||||
StreamUtil.pipeAll(decryptionStream, outputStream);
|
||||
decryptionStream.close();
|
||||
OpenPgpMetadata metadata = decryptionStream.getResult();
|
||||
|
||||
|
|
|
@ -22,7 +22,6 @@ import java.io.OutputStream;
|
|||
import org.bouncycastle.openpgp.PGPException;
|
||||
import org.bouncycastle.openpgp.PGPPublicKeyRingCollection;
|
||||
import org.bouncycastle.openpgp.PGPSecretKeyRingCollection;
|
||||
import org.bouncycastle.util.io.Streams;
|
||||
import org.pgpainless.PGPainless;
|
||||
import org.pgpainless.algorithm.DocumentSignatureType;
|
||||
import org.pgpainless.algorithm.StreamEncoding;
|
||||
|
@ -33,11 +32,12 @@ import org.pgpainless.encryption_signing.SigningOptions;
|
|||
import org.pgpainless.exception.WrongPassphraseException;
|
||||
import org.pgpainless.key.protection.SecretKeyRingProtector;
|
||||
import org.pgpainless.util.Passphrase;
|
||||
import sop.util.ProxyOutputStream;
|
||||
import org.pgpainless.util.StreamUtil;
|
||||
import sop.Ready;
|
||||
import sop.enums.EncryptAs;
|
||||
import sop.exception.SOPGPException;
|
||||
import sop.operation.Encrypt;
|
||||
import sop.util.ProxyOutputStream;
|
||||
|
||||
public class EncryptImpl implements Encrypt {
|
||||
|
||||
|
@ -117,7 +117,7 @@ public class EncryptImpl implements Encrypt {
|
|||
@Override
|
||||
public void writeTo(OutputStream outputStream) throws IOException {
|
||||
proxy.replaceOutputStream(outputStream);
|
||||
Streams.pipeAll(plaintext, encryptionStream);
|
||||
StreamUtil.pipeAll(plaintext, encryptionStream);
|
||||
encryptionStream.close();
|
||||
}
|
||||
};
|
||||
|
|
|
@ -25,7 +25,6 @@ import java.util.List;
|
|||
import org.bouncycastle.openpgp.PGPException;
|
||||
import org.bouncycastle.openpgp.PGPSecretKeyRing;
|
||||
import org.bouncycastle.openpgp.PGPSignature;
|
||||
import org.bouncycastle.util.io.Streams;
|
||||
import org.pgpainless.PGPainless;
|
||||
import org.pgpainless.algorithm.DocumentSignatureType;
|
||||
import org.pgpainless.encryption_signing.EncryptionResult;
|
||||
|
@ -36,6 +35,7 @@ import org.pgpainless.key.SubkeyIdentifier;
|
|||
import org.pgpainless.key.info.KeyRingInfo;
|
||||
import org.pgpainless.key.protection.SecretKeyRingProtector;
|
||||
import org.pgpainless.util.ArmoredOutputStreamFactory;
|
||||
import org.pgpainless.util.StreamUtil;
|
||||
import sop.Ready;
|
||||
import sop.enums.SignAs;
|
||||
import sop.exception.SOPGPException;
|
||||
|
@ -92,7 +92,7 @@ public class SignImpl implements Sign {
|
|||
throw new IllegalStateException("EncryptionStream is already closed.");
|
||||
}
|
||||
|
||||
Streams.pipeAll(data, signingStream);
|
||||
StreamUtil.pipeAll(data, signingStream);
|
||||
signingStream.close();
|
||||
EncryptionResult encryptionResult = signingStream.getResult();
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue