1
0
Fork 0
mirror of https://github.com/pgpainless/pgpainless.git synced 2025-09-10 18:59:39 +02:00

Revert introduction of StreamUtil

This commit is contained in:
Paul Schaub 2021-07-31 20:40:31 +02:00
parent b8f719d3eb
commit 311c842196
Signed by: vanitasvitae
GPG key ID: 62BEE9264BF17311
27 changed files with 78 additions and 137 deletions

View file

@ -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)) {
StreamUtil.pipeAll(pbIn, System.out);
Streams.pipeAll(pbIn, System.out);
} else {
ArmoredOutputStream armor = ArmoredOutputStreamFactory.get(System.out);
StreamUtil.pipeAll(pbIn, armor);
Streams.pipeAll(pbIn, armor);
armor.close();
}
}

View file

@ -20,7 +20,7 @@ import java.io.InputStream;
import java.io.OutputStream;
import org.bouncycastle.openpgp.PGPUtil;
import org.pgpainless.util.StreamUtil;
import org.bouncycastle.util.io.Streams;
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 {
StreamUtil.pipeAll(decoder, outputStream);
Streams.pipeAll(decoder, outputStream);
decoder.close();
}
};

View file

@ -27,6 +27,7 @@ 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;
@ -36,7 +37,6 @@ 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 {
StreamUtil.pipeAll(decryptionStream, outputStream);
Streams.pipeAll(decryptionStream, outputStream);
decryptionStream.close();
OpenPgpMetadata metadata = decryptionStream.getResult();

View file

@ -22,6 +22,7 @@ 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;
@ -32,12 +33,11 @@ import org.pgpainless.encryption_signing.SigningOptions;
import org.pgpainless.exception.WrongPassphraseException;
import org.pgpainless.key.protection.SecretKeyRingProtector;
import org.pgpainless.util.Passphrase;
import org.pgpainless.util.StreamUtil;
import sop.util.ProxyOutputStream;
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);
StreamUtil.pipeAll(plaintext, encryptionStream);
Streams.pipeAll(plaintext, encryptionStream);
encryptionStream.close();
}
};

View file

@ -25,6 +25,7 @@ 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;
@ -35,7 +36,6 @@ 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.");
}
StreamUtil.pipeAll(data, signingStream);
Streams.pipeAll(data, signingStream);
signingStream.close();
EncryptionResult encryptionResult = signingStream.getResult();