1
0
Fork 0
mirror of https://github.com/pgpainless/pgpainless.git synced 2024-11-18 02:12:06 +01:00

KeyRingReader: Remove unused @throws IOException

This commit is contained in:
Paul Schaub 2023-05-03 17:23:13 +02:00
parent fb581f11c7
commit 005b9d477a
Signed by: vanitasvitae
GPG key ID: 62BEE9264BF17311
8 changed files with 14 additions and 25 deletions

View file

@ -4,9 +4,9 @@
package org.pgpainless.encryption_signing;
import java.io.IOException;
import java.io.OutputStream;
import java.security.MessageDigest;
import javax.annotation.Nonnull;
import org.bouncycastle.crypto.Digest;
import org.bouncycastle.crypto.Signer;
@ -23,18 +23,15 @@ abstract class PGPHashContextContentSignerBuilder implements PGPContentSignerBui
this.sig = sig;
}
public void write(byte[] bytes, int off, int len)
throws IOException {
public void write(@Nonnull byte[] bytes, int off, int len) {
sig.update(bytes, off, len);
}
public void write(byte[] bytes)
throws IOException {
public void write(@Nonnull byte[] bytes) {
sig.update(bytes, 0, bytes.length);
}
public void write(int b)
throws IOException {
public void write(int b) {
sig.update((byte) b);
}
}

View file

@ -188,7 +188,7 @@ public interface SecretKeyRingEditorInterface {
@Nonnull SecretKeyRingProtector primaryKeyProtector,
@Nonnull KeyFlag keyFlag,
KeyFlag... additionalKeyFlags)
throws PGPException, IOException, NoSuchAlgorithmException;
throws PGPException, IOException;
/**
* Revoke the key ring.

View file

@ -88,12 +88,12 @@ public class KeyRingReader {
}
public PGPPublicKeyRingCollection publicKeyRingCollection(@Nonnull InputStream inputStream)
throws IOException, PGPException {
throws IOException {
return readPublicKeyRingCollection(inputStream);
}
public PGPPublicKeyRingCollection publicKeyRingCollection(@Nonnull byte[] bytes)
throws IOException, PGPException {
throws IOException {
return publicKeyRingCollection(new ByteArrayInputStream(bytes));
}
@ -118,17 +118,17 @@ public class KeyRingReader {
}
public PGPSecretKeyRingCollection secretKeyRingCollection(@Nonnull InputStream inputStream)
throws IOException, PGPException {
throws IOException {
return readSecretKeyRingCollection(inputStream);
}
public PGPSecretKeyRingCollection secretKeyRingCollection(@Nonnull byte[] bytes)
throws IOException, PGPException {
throws IOException {
return secretKeyRingCollection(new ByteArrayInputStream(bytes));
}
public PGPSecretKeyRingCollection secretKeyRingCollection(@Nonnull String asciiArmored)
throws IOException, PGPException {
throws IOException {
return secretKeyRingCollection(asciiArmored.getBytes(UTF8));
}

View file

@ -243,7 +243,7 @@ public final class SignatureUtils {
* @throws IOException in case of a stream error
* @throws PGPException in case of an OpenPGP error
*/
public static List<PGPSignature> readSignatures(InputStream inputStream, int maxIterations) throws IOException, PGPException {
public static List<PGPSignature> readSignatures(InputStream inputStream, int maxIterations) throws IOException {
List<PGPSignature> signatures = new ArrayList<>();
InputStream pgpIn = ArmorUtils.getDecoderStream(inputStream);
PGPObjectFactory objectFactory = ImplementationFactory.getInstance().getPGPObjectFactory(pgpIn);

View file

@ -7,8 +7,6 @@ package org.bouncycastle;
import java.io.ByteArrayInputStream;
import java.io.ByteArrayOutputStream;
import java.io.IOException;
import java.security.InvalidAlgorithmParameterException;
import java.security.NoSuchAlgorithmException;
import org.bouncycastle.openpgp.PGPException;
import org.bouncycastle.openpgp.PGPPrivateKey;
@ -25,8 +23,6 @@ import org.pgpainless.key.info.KeyRingInfo;
import org.pgpainless.key.protection.SecretKeyRingProtector;
import org.pgpainless.key.protection.UnlockSecretKey;
import static org.junit.jupiter.api.Assertions.assertEquals;
public class CachingBcPublicKeyDataDecryptorFactoryTest {
private static final String KEY = "-----BEGIN PGP PRIVATE KEY BLOCK-----\n" +
@ -64,7 +60,7 @@ public class CachingBcPublicKeyDataDecryptorFactoryTest {
"-----END PGP MESSAGE-----";
@Test
public void test() throws PGPException, InvalidAlgorithmParameterException, NoSuchAlgorithmException, IOException {
public void test() throws PGPException, IOException {
PGPSecretKeyRing secretKeys = PGPainless.readKeyRing().secretKeyRing(KEY);
SecretKeyRingProtector protector = SecretKeyRingProtector.unprotectedKeys();
KeyRingInfo info = PGPainless.inspectKeyRing(secretKeys);

View file

@ -56,7 +56,7 @@ public class PGPKeyRingCollectionTest {
}
@Test
public void testConstructorFromCollection() throws PGPException, InvalidAlgorithmParameterException, NoSuchAlgorithmException, IOException {
public void testConstructorFromCollection() throws PGPException, InvalidAlgorithmParameterException, NoSuchAlgorithmException {
PGPSecretKeyRing first = PGPainless.generateKeyRing().simpleEcKeyRing("alice@wonderland.lit");
PGPSecretKeyRing second = PGPainless.generateKeyRing().simpleEcKeyRing("bob@the-builder.tv");
PGPPublicKeyRing secondPub = KeyRingUtils.publicKeyRingFrom(second);

View file

@ -113,7 +113,7 @@ public class EncryptImpl implements Encrypt {
encryptionOptions.addRecipients(certificates);
} catch (KeyException.UnacceptableEncryptionKeyException e) {
throw new SOPGPException.CertCannotEncrypt(e.getMessage(), e);
} catch (IOException | PGPException e) {
} catch (IOException e) {
throw new SOPGPException.BadData(e);
}
return this;

View file

@ -33,8 +33,6 @@ class KeyReader {
throw new SOPGPException.BadData(e);
}
throw e;
} catch (PGPException e) {
throw new SOPGPException.BadData("Cannot read keys.", e);
}
if (requireContent && (keys == null || keys.size() == 0)) {
@ -54,8 +52,6 @@ class KeyReader {
throw new SOPGPException.BadData(e);
}
throw e;
} catch (PGPException e) {
throw new SOPGPException.BadData(e);
}
if (requireContent && (certs == null || certs.size() == 0)) {
throw new SOPGPException.BadData(new PGPException("No cert data found."));