1
0
Fork 0
mirror of https://github.com/pgpainless/pgpainless.git synced 2024-11-05 20:15:59 +01:00

Remove unnecessary throws declarations

This commit is contained in:
Paul Schaub 2022-09-29 13:02:22 +02:00
parent be8439532d
commit 6809a490c1
13 changed files with 19 additions and 35 deletions

View file

@ -74,7 +74,7 @@ public class PGPKeyRingCollection {
}
public PGPKeyRingCollection(@Nonnull Collection<PGPKeyRing> collection, boolean isSilent)
throws IOException, PGPException {
throws PGPException {
List<PGPSecretKeyRing> secretKeyRings = new ArrayList<>();
List<PGPPublicKeyRing> publicKeyRings = new ArrayList<>();

View file

@ -327,7 +327,7 @@ public class SecretKeyRingEditor implements SecretKeyRingEditorInterface {
@Nonnull SecretKeyRingProtector primaryKeyProtector,
@Nonnull KeyFlag keyFlag,
KeyFlag... additionalKeyFlags)
throws PGPException, IOException, NoSuchAlgorithmException {
throws PGPException, IOException {
KeyFlag[] flags = concat(keyFlag, additionalKeyFlags);
PublicKeyAlgorithm subkeyAlgorithm = PublicKeyAlgorithm.requireFromId(subkey.getPublicKey().getAlgorithm());
SignatureSubpacketsUtil.assureKeyCanCarryFlags(subkeyAlgorithm);

View file

@ -232,10 +232,9 @@ public class KeyRingReader {
* @return public key ring collection
*
* @throws IOException in case of an IO error or exceeding of max iterations
* @throws PGPException in case of a broken key
*/
public static PGPPublicKeyRingCollection readPublicKeyRingCollection(@Nonnull InputStream inputStream, int maxIterations)
throws IOException, PGPException {
throws IOException {
PGPObjectFactory objectFactory = ImplementationFactory.getInstance().getPGPObjectFactory(
ArmorUtils.getDecoderStream(inputStream));
@ -317,11 +316,10 @@ public class KeyRingReader {
* @return secret key ring collection
*
* @throws IOException in case of an IO error or exceeding of max iterations
* @throws PGPException in case of a broken secret key
*/
public static PGPSecretKeyRingCollection readSecretKeyRingCollection(@Nonnull InputStream inputStream,
int maxIterations)
throws IOException, PGPException {
throws IOException {
PGPObjectFactory objectFactory = ImplementationFactory.getInstance().getPGPObjectFactory(
ArmorUtils.getDecoderStream(inputStream));

View file

@ -167,12 +167,9 @@ public final class KeyRingUtils {
*
* @param secretKeyRings secret key ring collection
* @return public key ring collection
* @throws PGPException TODO: remove
* @throws IOException TODO: remove
*/
@Nonnull
public static PGPPublicKeyRingCollection publicKeyRingCollectionFrom(@Nonnull PGPSecretKeyRingCollection secretKeyRings)
throws PGPException, IOException {
public static PGPPublicKeyRingCollection publicKeyRingCollectionFrom(@Nonnull PGPSecretKeyRingCollection secretKeyRings) {
List<PGPPublicKeyRing> certificates = new ArrayList<>();
for (PGPSecretKeyRing secretKey : secretKeyRings) {
certificates.add(PGPainless.extractCertificate(secretKey));
@ -200,13 +197,9 @@ public final class KeyRingUtils {
*
* @param rings array of public key rings
* @return key ring collection
*
* @throws IOException in case of an io error
* @throws PGPException in case of a broken key
*/
@Nonnull
public static PGPPublicKeyRingCollection keyRingsToKeyRingCollection(@Nonnull PGPPublicKeyRing... rings)
throws IOException, PGPException {
public static PGPPublicKeyRingCollection keyRingsToKeyRingCollection(@Nonnull PGPPublicKeyRing... rings) {
return new PGPPublicKeyRingCollection(Arrays.asList(rings));
}
@ -215,13 +208,9 @@ public final class KeyRingUtils {
*
* @param rings array of secret key rings
* @return secret key ring collection
*
* @throws IOException in case of an io error
* @throws PGPException in case of a broken key
*/
@Nonnull
public static PGPSecretKeyRingCollection keyRingsToKeyRingCollection(@Nonnull PGPSecretKeyRing... rings)
throws IOException, PGPException {
public static PGPSecretKeyRingCollection keyRingsToKeyRingCollection(@Nonnull PGPSecretKeyRing... rings) {
return new PGPSecretKeyRingCollection(Arrays.asList(rings));
}

View file

@ -530,7 +530,7 @@ public class ModificationDetectionTests {
);
}
private PGPSecretKeyRingCollection getDecryptionKey() throws IOException, PGPException {
private PGPSecretKeyRingCollection getDecryptionKey() throws IOException {
PGPSecretKeyRing secretKeys = PGPainless.readKeyRing().secretKeyRing(keyAscii);
return new PGPSecretKeyRingCollection(Collections.singletonList(secretKeys));
}

View file

@ -9,7 +9,6 @@ import static org.junit.jupiter.api.Assertions.assertNull;
import static org.junit.jupiter.api.Assertions.assertThrows;
import static org.junit.jupiter.api.Assertions.assertTrue;
import java.io.IOException;
import java.security.InvalidAlgorithmParameterException;
import java.security.NoSuchAlgorithmException;
import java.util.Arrays;
@ -165,7 +164,7 @@ public class EncryptionOptionsTest {
}
@Test
public void testAddRecipients_PGPPublicKeyRingCollection() throws PGPException, InvalidAlgorithmParameterException, NoSuchAlgorithmException, IOException {
public void testAddRecipients_PGPPublicKeyRingCollection() throws PGPException, InvalidAlgorithmParameterException, NoSuchAlgorithmException {
PGPPublicKeyRing secondKeyRing = KeyRingUtils.publicKeyRingFrom(
PGPainless.generateKeyRing().modernKeyRing("other@pgpainless.org"));

View file

@ -140,7 +140,7 @@ public class CertifyCertificateTest {
}
@Test
public void testScopedDelegation() throws PGPException, InvalidAlgorithmParameterException, NoSuchAlgorithmException, IOException {
public void testScopedDelegation() throws PGPException, InvalidAlgorithmParameterException, NoSuchAlgorithmException {
PGPSecretKeyRing aliceKey = PGPainless.generateKeyRing()
.modernKeyRing("Alice <alice@pgpainless.org>");
PGPSecretKeyRing caKey = PGPainless.generateKeyRing()

View file

@ -7,7 +7,6 @@ package org.pgpainless.key.generation;
import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertFalse;
import java.io.IOException;
import java.security.InvalidAlgorithmParameterException;
import java.security.NoSuchAlgorithmException;
import java.util.Date;
@ -26,14 +25,15 @@ import org.pgpainless.key.generation.type.rsa.RsaLength;
import org.pgpainless.key.util.KeyRingUtils;
import org.pgpainless.key.util.UserId;
import org.pgpainless.timeframe.TestTimeFrameProvider;
import org.pgpainless.util.DateUtil;
import org.pgpainless.util.TestAllImplementations;
public class GenerateKeyWithAdditionalUserIdTest {
@TestTemplate
@ExtendWith(TestAllImplementations.class)
public void test() throws InvalidAlgorithmParameterException, NoSuchAlgorithmException, PGPException, IOException {
Date now = new Date();
public void test() throws InvalidAlgorithmParameterException, NoSuchAlgorithmException, PGPException {
Date now = DateUtil.now();
Date expiration = TestTimeFrameProvider.defaultExpirationForCreationDate(now);
PGPSecretKeyRing secretKeys = PGPainless.buildKeyRing()
.setPrimaryKey(KeySpec.getBuilder(

View file

@ -8,7 +8,6 @@ import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertFalse;
import static org.junit.jupiter.api.Assertions.assertTrue;
import java.io.IOException;
import java.security.InvalidAlgorithmParameterException;
import java.security.NoSuchAlgorithmException;
import java.util.Iterator;
@ -36,8 +35,7 @@ public class BCUtilTest {
@Test
public void keyRingToCollectionTest()
throws PGPException, NoSuchAlgorithmException, InvalidAlgorithmParameterException,
IOException {
throws PGPException, NoSuchAlgorithmException, InvalidAlgorithmParameterException {
PGPSecretKeyRing sec = PGPainless.buildKeyRing()
.setPrimaryKey(KeySpec.getBuilder(
KeyType.RSA(RsaLength._3072),

View file

@ -56,7 +56,7 @@ public class KeyRingsFromCollectionTest {
}
@Test
public void selectPublicKeyRingFromPublicKeyRingCollectionTest() throws IOException, PGPException {
public void selectPublicKeyRingFromPublicKeyRingCollectionTest() throws IOException {
PGPPublicKeyRing emil = TestKeys.getEmilPublicKeyRing();
PGPPublicKeyRing juliet = TestKeys.getJulietPublicKeyRing();
PGPPublicKeyRingCollection collection = new PGPPublicKeyRingCollection(Arrays.asList(emil, juliet));
@ -68,7 +68,7 @@ public class KeyRingsFromCollectionTest {
}
@Test
public void selectPublicKeyRingMapFromPublicKeyRingCollectionMapTest() throws IOException, PGPException {
public void selectPublicKeyRingMapFromPublicKeyRingCollectionMapTest() throws IOException {
PGPPublicKeyRing emil = TestKeys.getEmilPublicKeyRing();
PGPPublicKeyRing juliet = TestKeys.getJulietPublicKeyRing();
MultiMap<String, PGPPublicKeyRingCollection> map = new MultiMap<>();

View file

@ -18,7 +18,7 @@ import sop.operation.Dearmor;
public class DearmorImpl implements Dearmor {
@Override
public Ready data(InputStream data) throws IOException {
public Ready data(InputStream data) {
InputStream decoder;
try {
decoder = PGPUtil.getDecoderStream(data);

View file

@ -76,7 +76,7 @@ public class InlineSignImpl implements InlineSign {
}
@Override
public Ready data(InputStream data) throws SOPGPException.KeyIsProtected, IOException, SOPGPException.ExpectedText {
public Ready data(InputStream data) throws SOPGPException.KeyIsProtected, SOPGPException.ExpectedText {
for (PGPSecretKeyRing key : signingKeys) {
try {
if (mode == InlineSignAs.CleartextSigned) {

View file

@ -53,7 +53,7 @@ public class InlineVerifyImpl implements InlineVerify {
}
@Override
public ReadyWithResult<List<Verification>> data(InputStream data) throws IOException, SOPGPException.NoSignature, SOPGPException.BadData {
public ReadyWithResult<List<Verification>> data(InputStream data) throws SOPGPException.NoSignature, SOPGPException.BadData {
return new ReadyWithResult<List<Verification>>() {
@Override
public List<Verification> writeTo(OutputStream outputStream) throws IOException, SOPGPException.NoSignature {