mirror of
https://github.com/pgpainless/pgpainless.git
synced 2024-12-23 03:17:58 +01:00
Remove unnecessary throws declarations
This commit is contained in:
parent
81bb8cba54
commit
09f94944b3
13 changed files with 19 additions and 35 deletions
|
@ -74,7 +74,7 @@ public class PGPKeyRingCollection {
|
||||||
}
|
}
|
||||||
|
|
||||||
public PGPKeyRingCollection(@Nonnull Collection<PGPKeyRing> collection, boolean isSilent)
|
public PGPKeyRingCollection(@Nonnull Collection<PGPKeyRing> collection, boolean isSilent)
|
||||||
throws IOException, PGPException {
|
throws PGPException {
|
||||||
List<PGPSecretKeyRing> secretKeyRings = new ArrayList<>();
|
List<PGPSecretKeyRing> secretKeyRings = new ArrayList<>();
|
||||||
List<PGPPublicKeyRing> publicKeyRings = new ArrayList<>();
|
List<PGPPublicKeyRing> publicKeyRings = new ArrayList<>();
|
||||||
|
|
||||||
|
|
|
@ -327,7 +327,7 @@ public class SecretKeyRingEditor implements SecretKeyRingEditorInterface {
|
||||||
@Nonnull SecretKeyRingProtector primaryKeyProtector,
|
@Nonnull SecretKeyRingProtector primaryKeyProtector,
|
||||||
@Nonnull KeyFlag keyFlag,
|
@Nonnull KeyFlag keyFlag,
|
||||||
KeyFlag... additionalKeyFlags)
|
KeyFlag... additionalKeyFlags)
|
||||||
throws PGPException, IOException, NoSuchAlgorithmException {
|
throws PGPException, IOException {
|
||||||
KeyFlag[] flags = concat(keyFlag, additionalKeyFlags);
|
KeyFlag[] flags = concat(keyFlag, additionalKeyFlags);
|
||||||
PublicKeyAlgorithm subkeyAlgorithm = PublicKeyAlgorithm.requireFromId(subkey.getPublicKey().getAlgorithm());
|
PublicKeyAlgorithm subkeyAlgorithm = PublicKeyAlgorithm.requireFromId(subkey.getPublicKey().getAlgorithm());
|
||||||
SignatureSubpacketsUtil.assureKeyCanCarryFlags(subkeyAlgorithm);
|
SignatureSubpacketsUtil.assureKeyCanCarryFlags(subkeyAlgorithm);
|
||||||
|
|
|
@ -232,10 +232,9 @@ public class KeyRingReader {
|
||||||
* @return public key ring collection
|
* @return public key ring collection
|
||||||
*
|
*
|
||||||
* @throws IOException in case of an IO error or exceeding of max iterations
|
* @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)
|
public static PGPPublicKeyRingCollection readPublicKeyRingCollection(@Nonnull InputStream inputStream, int maxIterations)
|
||||||
throws IOException, PGPException {
|
throws IOException {
|
||||||
PGPObjectFactory objectFactory = ImplementationFactory.getInstance().getPGPObjectFactory(
|
PGPObjectFactory objectFactory = ImplementationFactory.getInstance().getPGPObjectFactory(
|
||||||
ArmorUtils.getDecoderStream(inputStream));
|
ArmorUtils.getDecoderStream(inputStream));
|
||||||
|
|
||||||
|
@ -317,11 +316,10 @@ public class KeyRingReader {
|
||||||
* @return secret key ring collection
|
* @return secret key ring collection
|
||||||
*
|
*
|
||||||
* @throws IOException in case of an IO error or exceeding of max iterations
|
* @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,
|
public static PGPSecretKeyRingCollection readSecretKeyRingCollection(@Nonnull InputStream inputStream,
|
||||||
int maxIterations)
|
int maxIterations)
|
||||||
throws IOException, PGPException {
|
throws IOException {
|
||||||
PGPObjectFactory objectFactory = ImplementationFactory.getInstance().getPGPObjectFactory(
|
PGPObjectFactory objectFactory = ImplementationFactory.getInstance().getPGPObjectFactory(
|
||||||
ArmorUtils.getDecoderStream(inputStream));
|
ArmorUtils.getDecoderStream(inputStream));
|
||||||
|
|
||||||
|
|
|
@ -167,12 +167,9 @@ public final class KeyRingUtils {
|
||||||
*
|
*
|
||||||
* @param secretKeyRings secret key ring collection
|
* @param secretKeyRings secret key ring collection
|
||||||
* @return public key ring collection
|
* @return public key ring collection
|
||||||
* @throws PGPException TODO: remove
|
|
||||||
* @throws IOException TODO: remove
|
|
||||||
*/
|
*/
|
||||||
@Nonnull
|
@Nonnull
|
||||||
public static PGPPublicKeyRingCollection publicKeyRingCollectionFrom(@Nonnull PGPSecretKeyRingCollection secretKeyRings)
|
public static PGPPublicKeyRingCollection publicKeyRingCollectionFrom(@Nonnull PGPSecretKeyRingCollection secretKeyRings) {
|
||||||
throws PGPException, IOException {
|
|
||||||
List<PGPPublicKeyRing> certificates = new ArrayList<>();
|
List<PGPPublicKeyRing> certificates = new ArrayList<>();
|
||||||
for (PGPSecretKeyRing secretKey : secretKeyRings) {
|
for (PGPSecretKeyRing secretKey : secretKeyRings) {
|
||||||
certificates.add(PGPainless.extractCertificate(secretKey));
|
certificates.add(PGPainless.extractCertificate(secretKey));
|
||||||
|
@ -200,13 +197,9 @@ public final class KeyRingUtils {
|
||||||
*
|
*
|
||||||
* @param rings array of public key rings
|
* @param rings array of public key rings
|
||||||
* @return key ring collection
|
* @return key ring collection
|
||||||
*
|
|
||||||
* @throws IOException in case of an io error
|
|
||||||
* @throws PGPException in case of a broken key
|
|
||||||
*/
|
*/
|
||||||
@Nonnull
|
@Nonnull
|
||||||
public static PGPPublicKeyRingCollection keyRingsToKeyRingCollection(@Nonnull PGPPublicKeyRing... rings)
|
public static PGPPublicKeyRingCollection keyRingsToKeyRingCollection(@Nonnull PGPPublicKeyRing... rings) {
|
||||||
throws IOException, PGPException {
|
|
||||||
return new PGPPublicKeyRingCollection(Arrays.asList(rings));
|
return new PGPPublicKeyRingCollection(Arrays.asList(rings));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -215,13 +208,9 @@ public final class KeyRingUtils {
|
||||||
*
|
*
|
||||||
* @param rings array of secret key rings
|
* @param rings array of secret key rings
|
||||||
* @return secret key ring collection
|
* @return secret key ring collection
|
||||||
*
|
|
||||||
* @throws IOException in case of an io error
|
|
||||||
* @throws PGPException in case of a broken key
|
|
||||||
*/
|
*/
|
||||||
@Nonnull
|
@Nonnull
|
||||||
public static PGPSecretKeyRingCollection keyRingsToKeyRingCollection(@Nonnull PGPSecretKeyRing... rings)
|
public static PGPSecretKeyRingCollection keyRingsToKeyRingCollection(@Nonnull PGPSecretKeyRing... rings) {
|
||||||
throws IOException, PGPException {
|
|
||||||
return new PGPSecretKeyRingCollection(Arrays.asList(rings));
|
return new PGPSecretKeyRingCollection(Arrays.asList(rings));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -530,7 +530,7 @@ public class ModificationDetectionTests {
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
private PGPSecretKeyRingCollection getDecryptionKey() throws IOException, PGPException {
|
private PGPSecretKeyRingCollection getDecryptionKey() throws IOException {
|
||||||
PGPSecretKeyRing secretKeys = PGPainless.readKeyRing().secretKeyRing(keyAscii);
|
PGPSecretKeyRing secretKeys = PGPainless.readKeyRing().secretKeyRing(keyAscii);
|
||||||
return new PGPSecretKeyRingCollection(Collections.singletonList(secretKeys));
|
return new PGPSecretKeyRingCollection(Collections.singletonList(secretKeys));
|
||||||
}
|
}
|
||||||
|
|
|
@ -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.assertThrows;
|
||||||
import static org.junit.jupiter.api.Assertions.assertTrue;
|
import static org.junit.jupiter.api.Assertions.assertTrue;
|
||||||
|
|
||||||
import java.io.IOException;
|
|
||||||
import java.security.InvalidAlgorithmParameterException;
|
import java.security.InvalidAlgorithmParameterException;
|
||||||
import java.security.NoSuchAlgorithmException;
|
import java.security.NoSuchAlgorithmException;
|
||||||
import java.util.Arrays;
|
import java.util.Arrays;
|
||||||
|
@ -165,7 +164,7 @@ public class EncryptionOptionsTest {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testAddRecipients_PGPPublicKeyRingCollection() throws PGPException, InvalidAlgorithmParameterException, NoSuchAlgorithmException, IOException {
|
public void testAddRecipients_PGPPublicKeyRingCollection() throws PGPException, InvalidAlgorithmParameterException, NoSuchAlgorithmException {
|
||||||
PGPPublicKeyRing secondKeyRing = KeyRingUtils.publicKeyRingFrom(
|
PGPPublicKeyRing secondKeyRing = KeyRingUtils.publicKeyRingFrom(
|
||||||
PGPainless.generateKeyRing().modernKeyRing("other@pgpainless.org"));
|
PGPainless.generateKeyRing().modernKeyRing("other@pgpainless.org"));
|
||||||
|
|
||||||
|
|
|
@ -140,7 +140,7 @@ public class CertifyCertificateTest {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testScopedDelegation() throws PGPException, InvalidAlgorithmParameterException, NoSuchAlgorithmException, IOException {
|
public void testScopedDelegation() throws PGPException, InvalidAlgorithmParameterException, NoSuchAlgorithmException {
|
||||||
PGPSecretKeyRing aliceKey = PGPainless.generateKeyRing()
|
PGPSecretKeyRing aliceKey = PGPainless.generateKeyRing()
|
||||||
.modernKeyRing("Alice <alice@pgpainless.org>");
|
.modernKeyRing("Alice <alice@pgpainless.org>");
|
||||||
PGPSecretKeyRing caKey = PGPainless.generateKeyRing()
|
PGPSecretKeyRing caKey = PGPainless.generateKeyRing()
|
||||||
|
|
|
@ -7,7 +7,6 @@ package org.pgpainless.key.generation;
|
||||||
import static org.junit.jupiter.api.Assertions.assertEquals;
|
import static org.junit.jupiter.api.Assertions.assertEquals;
|
||||||
import static org.junit.jupiter.api.Assertions.assertFalse;
|
import static org.junit.jupiter.api.Assertions.assertFalse;
|
||||||
|
|
||||||
import java.io.IOException;
|
|
||||||
import java.security.InvalidAlgorithmParameterException;
|
import java.security.InvalidAlgorithmParameterException;
|
||||||
import java.security.NoSuchAlgorithmException;
|
import java.security.NoSuchAlgorithmException;
|
||||||
import java.util.Date;
|
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.KeyRingUtils;
|
||||||
import org.pgpainless.key.util.UserId;
|
import org.pgpainless.key.util.UserId;
|
||||||
import org.pgpainless.timeframe.TestTimeFrameProvider;
|
import org.pgpainless.timeframe.TestTimeFrameProvider;
|
||||||
|
import org.pgpainless.util.DateUtil;
|
||||||
import org.pgpainless.util.TestAllImplementations;
|
import org.pgpainless.util.TestAllImplementations;
|
||||||
|
|
||||||
public class GenerateKeyWithAdditionalUserIdTest {
|
public class GenerateKeyWithAdditionalUserIdTest {
|
||||||
|
|
||||||
@TestTemplate
|
@TestTemplate
|
||||||
@ExtendWith(TestAllImplementations.class)
|
@ExtendWith(TestAllImplementations.class)
|
||||||
public void test() throws InvalidAlgorithmParameterException, NoSuchAlgorithmException, PGPException, IOException {
|
public void test() throws InvalidAlgorithmParameterException, NoSuchAlgorithmException, PGPException {
|
||||||
Date now = new Date();
|
Date now = DateUtil.now();
|
||||||
Date expiration = TestTimeFrameProvider.defaultExpirationForCreationDate(now);
|
Date expiration = TestTimeFrameProvider.defaultExpirationForCreationDate(now);
|
||||||
PGPSecretKeyRing secretKeys = PGPainless.buildKeyRing()
|
PGPSecretKeyRing secretKeys = PGPainless.buildKeyRing()
|
||||||
.setPrimaryKey(KeySpec.getBuilder(
|
.setPrimaryKey(KeySpec.getBuilder(
|
||||||
|
|
|
@ -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.assertFalse;
|
||||||
import static org.junit.jupiter.api.Assertions.assertTrue;
|
import static org.junit.jupiter.api.Assertions.assertTrue;
|
||||||
|
|
||||||
import java.io.IOException;
|
|
||||||
import java.security.InvalidAlgorithmParameterException;
|
import java.security.InvalidAlgorithmParameterException;
|
||||||
import java.security.NoSuchAlgorithmException;
|
import java.security.NoSuchAlgorithmException;
|
||||||
import java.util.Iterator;
|
import java.util.Iterator;
|
||||||
|
@ -36,8 +35,7 @@ public class BCUtilTest {
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void keyRingToCollectionTest()
|
public void keyRingToCollectionTest()
|
||||||
throws PGPException, NoSuchAlgorithmException, InvalidAlgorithmParameterException,
|
throws PGPException, NoSuchAlgorithmException, InvalidAlgorithmParameterException {
|
||||||
IOException {
|
|
||||||
PGPSecretKeyRing sec = PGPainless.buildKeyRing()
|
PGPSecretKeyRing sec = PGPainless.buildKeyRing()
|
||||||
.setPrimaryKey(KeySpec.getBuilder(
|
.setPrimaryKey(KeySpec.getBuilder(
|
||||||
KeyType.RSA(RsaLength._3072),
|
KeyType.RSA(RsaLength._3072),
|
||||||
|
|
|
@ -56,7 +56,7 @@ public class KeyRingsFromCollectionTest {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void selectPublicKeyRingFromPublicKeyRingCollectionTest() throws IOException, PGPException {
|
public void selectPublicKeyRingFromPublicKeyRingCollectionTest() throws IOException {
|
||||||
PGPPublicKeyRing emil = TestKeys.getEmilPublicKeyRing();
|
PGPPublicKeyRing emil = TestKeys.getEmilPublicKeyRing();
|
||||||
PGPPublicKeyRing juliet = TestKeys.getJulietPublicKeyRing();
|
PGPPublicKeyRing juliet = TestKeys.getJulietPublicKeyRing();
|
||||||
PGPPublicKeyRingCollection collection = new PGPPublicKeyRingCollection(Arrays.asList(emil, juliet));
|
PGPPublicKeyRingCollection collection = new PGPPublicKeyRingCollection(Arrays.asList(emil, juliet));
|
||||||
|
@ -68,7 +68,7 @@ public class KeyRingsFromCollectionTest {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void selectPublicKeyRingMapFromPublicKeyRingCollectionMapTest() throws IOException, PGPException {
|
public void selectPublicKeyRingMapFromPublicKeyRingCollectionMapTest() throws IOException {
|
||||||
PGPPublicKeyRing emil = TestKeys.getEmilPublicKeyRing();
|
PGPPublicKeyRing emil = TestKeys.getEmilPublicKeyRing();
|
||||||
PGPPublicKeyRing juliet = TestKeys.getJulietPublicKeyRing();
|
PGPPublicKeyRing juliet = TestKeys.getJulietPublicKeyRing();
|
||||||
MultiMap<String, PGPPublicKeyRingCollection> map = new MultiMap<>();
|
MultiMap<String, PGPPublicKeyRingCollection> map = new MultiMap<>();
|
||||||
|
|
|
@ -18,7 +18,7 @@ import sop.operation.Dearmor;
|
||||||
public class DearmorImpl implements Dearmor {
|
public class DearmorImpl implements Dearmor {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Ready data(InputStream data) throws IOException {
|
public Ready data(InputStream data) {
|
||||||
InputStream decoder;
|
InputStream decoder;
|
||||||
try {
|
try {
|
||||||
decoder = PGPUtil.getDecoderStream(data);
|
decoder = PGPUtil.getDecoderStream(data);
|
||||||
|
|
|
@ -71,7 +71,7 @@ public class InlineSignImpl implements InlineSign {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@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) {
|
for (PGPSecretKeyRing key : signingKeys) {
|
||||||
try {
|
try {
|
||||||
if (mode == InlineSignAs.clearsigned) {
|
if (mode == InlineSignAs.clearsigned) {
|
||||||
|
|
|
@ -49,7 +49,7 @@ public class InlineVerifyImpl implements InlineVerify {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@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>>() {
|
return new ReadyWithResult<List<Verification>>() {
|
||||||
@Override
|
@Override
|
||||||
public List<Verification> writeTo(OutputStream outputStream) throws IOException, SOPGPException.NoSignature {
|
public List<Verification> writeTo(OutputStream outputStream) throws IOException, SOPGPException.NoSignature {
|
||||||
|
|
Loading…
Reference in a new issue