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

Mark KeyRingReader.read*KeyRing() as @Nullable/@Nonnull

This commit is contained in:
Paul Schaub 2023-05-16 16:26:52 +02:00
parent 1bf9abbdaf
commit d3ae02f137
Signed by: vanitasvitae
GPG key ID: 62BEE9264BF17311

View file

@ -12,6 +12,7 @@ import java.util.ArrayList;
import java.util.Iterator; import java.util.Iterator;
import java.util.List; import java.util.List;
import javax.annotation.Nonnull; import javax.annotation.Nonnull;
import javax.annotation.Nullable;
import org.bouncycastle.openpgp.PGPException; import org.bouncycastle.openpgp.PGPException;
import org.bouncycastle.openpgp.PGPKeyRing; import org.bouncycastle.openpgp.PGPKeyRing;
@ -41,6 +42,7 @@ public class KeyRingReader {
* @return key ring * @return key ring
* @throws IOException in case of an IO error * @throws IOException in case of an IO error
*/ */
@Nullable
public PGPKeyRing keyRing(@Nonnull InputStream inputStream) public PGPKeyRing keyRing(@Nonnull InputStream inputStream)
throws IOException { throws IOException {
return readKeyRing(inputStream); return readKeyRing(inputStream);
@ -54,6 +56,7 @@ public class KeyRingReader {
* @return key ring * @return key ring
* @throws IOException in case of an IO error * @throws IOException in case of an IO error
*/ */
@Nullable
public PGPKeyRing keyRing(@Nonnull byte[] bytes) public PGPKeyRing keyRing(@Nonnull byte[] bytes)
throws IOException { throws IOException {
return keyRing(new ByteArrayInputStream(bytes)); return keyRing(new ByteArrayInputStream(bytes));
@ -67,81 +70,97 @@ public class KeyRingReader {
* @return key ring * @return key ring
* @throws IOException in case of an IO error * @throws IOException in case of an IO error
*/ */
@Nullable
public PGPKeyRing keyRing(@Nonnull String asciiArmored) public PGPKeyRing keyRing(@Nonnull String asciiArmored)
throws IOException { throws IOException {
return keyRing(asciiArmored.getBytes(UTF8)); return keyRing(asciiArmored.getBytes(UTF8));
} }
@Nullable
public PGPPublicKeyRing publicKeyRing(@Nonnull InputStream inputStream) public PGPPublicKeyRing publicKeyRing(@Nonnull InputStream inputStream)
throws IOException { throws IOException {
return readPublicKeyRing(inputStream); return readPublicKeyRing(inputStream);
} }
@Nullable
public PGPPublicKeyRing publicKeyRing(@Nonnull byte[] bytes) public PGPPublicKeyRing publicKeyRing(@Nonnull byte[] bytes)
throws IOException { throws IOException {
return publicKeyRing(new ByteArrayInputStream(bytes)); return publicKeyRing(new ByteArrayInputStream(bytes));
} }
@Nullable
public PGPPublicKeyRing publicKeyRing(@Nonnull String asciiArmored) public PGPPublicKeyRing publicKeyRing(@Nonnull String asciiArmored)
throws IOException { throws IOException {
return publicKeyRing(asciiArmored.getBytes(UTF8)); return publicKeyRing(asciiArmored.getBytes(UTF8));
} }
@Nonnull
public PGPPublicKeyRingCollection publicKeyRingCollection(@Nonnull InputStream inputStream) public PGPPublicKeyRingCollection publicKeyRingCollection(@Nonnull InputStream inputStream)
throws IOException { throws IOException {
return readPublicKeyRingCollection(inputStream); return readPublicKeyRingCollection(inputStream);
} }
@Nonnull
public PGPPublicKeyRingCollection publicKeyRingCollection(@Nonnull byte[] bytes) public PGPPublicKeyRingCollection publicKeyRingCollection(@Nonnull byte[] bytes)
throws IOException { throws IOException {
return publicKeyRingCollection(new ByteArrayInputStream(bytes)); return publicKeyRingCollection(new ByteArrayInputStream(bytes));
} }
@Nonnull
public PGPPublicKeyRingCollection publicKeyRingCollection(@Nonnull String asciiArmored) public PGPPublicKeyRingCollection publicKeyRingCollection(@Nonnull String asciiArmored)
throws IOException, PGPException { throws IOException {
return publicKeyRingCollection(asciiArmored.getBytes(UTF8)); return publicKeyRingCollection(asciiArmored.getBytes(UTF8));
} }
@Nullable
public PGPSecretKeyRing secretKeyRing(@Nonnull InputStream inputStream) public PGPSecretKeyRing secretKeyRing(@Nonnull InputStream inputStream)
throws IOException { throws IOException {
return readSecretKeyRing(inputStream); return readSecretKeyRing(inputStream);
} }
@Nullable
public PGPSecretKeyRing secretKeyRing(@Nonnull byte[] bytes) public PGPSecretKeyRing secretKeyRing(@Nonnull byte[] bytes)
throws IOException { throws IOException {
return secretKeyRing(new ByteArrayInputStream(bytes)); return secretKeyRing(new ByteArrayInputStream(bytes));
} }
@Nullable
public PGPSecretKeyRing secretKeyRing(@Nonnull String asciiArmored) public PGPSecretKeyRing secretKeyRing(@Nonnull String asciiArmored)
throws IOException { throws IOException {
return secretKeyRing(asciiArmored.getBytes(UTF8)); return secretKeyRing(asciiArmored.getBytes(UTF8));
} }
@Nonnull
public PGPSecretKeyRingCollection secretKeyRingCollection(@Nonnull InputStream inputStream) public PGPSecretKeyRingCollection secretKeyRingCollection(@Nonnull InputStream inputStream)
throws IOException { throws IOException {
return readSecretKeyRingCollection(inputStream); return readSecretKeyRingCollection(inputStream);
} }
@Nonnull
public PGPSecretKeyRingCollection secretKeyRingCollection(@Nonnull byte[] bytes) public PGPSecretKeyRingCollection secretKeyRingCollection(@Nonnull byte[] bytes)
throws IOException { throws IOException {
return secretKeyRingCollection(new ByteArrayInputStream(bytes)); return secretKeyRingCollection(new ByteArrayInputStream(bytes));
} }
@Nonnull
public PGPSecretKeyRingCollection secretKeyRingCollection(@Nonnull String asciiArmored) public PGPSecretKeyRingCollection secretKeyRingCollection(@Nonnull String asciiArmored)
throws IOException { throws IOException {
return secretKeyRingCollection(asciiArmored.getBytes(UTF8)); return secretKeyRingCollection(asciiArmored.getBytes(UTF8));
} }
@Nonnull
public PGPKeyRingCollection keyRingCollection(@Nonnull InputStream inputStream, boolean isSilent) public PGPKeyRingCollection keyRingCollection(@Nonnull InputStream inputStream, boolean isSilent)
throws IOException, PGPException { throws IOException, PGPException {
return readKeyRingCollection(inputStream, isSilent); return readKeyRingCollection(inputStream, isSilent);
} }
@Nonnull
public PGPKeyRingCollection keyRingCollection(@Nonnull byte[] bytes, boolean isSilent) public PGPKeyRingCollection keyRingCollection(@Nonnull byte[] bytes, boolean isSilent)
throws IOException, PGPException { throws IOException, PGPException {
return keyRingCollection(new ByteArrayInputStream(bytes), isSilent); return keyRingCollection(new ByteArrayInputStream(bytes), isSilent);
} }
@Nonnull
public PGPKeyRingCollection keyRingCollection(@Nonnull String asciiArmored, boolean isSilent) public PGPKeyRingCollection keyRingCollection(@Nonnull String asciiArmored, boolean isSilent)
throws IOException, PGPException { throws IOException, PGPException {
return keyRingCollection(asciiArmored.getBytes(UTF8), isSilent); return keyRingCollection(asciiArmored.getBytes(UTF8), isSilent);
@ -157,6 +176,7 @@ public class KeyRingReader {
* @return key ring * @return key ring
* @throws IOException in case of an IO error * @throws IOException in case of an IO error
*/ */
@Nullable
public static PGPKeyRing readKeyRing(@Nonnull InputStream inputStream) public static PGPKeyRing readKeyRing(@Nonnull InputStream inputStream)
throws IOException { throws IOException {
return readKeyRing(inputStream, MAX_ITERATIONS); return readKeyRing(inputStream, MAX_ITERATIONS);
@ -173,6 +193,7 @@ public class KeyRingReader {
* @return key ring * @return key ring
* @throws IOException in case of an IO error * @throws IOException in case of an IO error
*/ */
@Nullable
public static PGPKeyRing readKeyRing(@Nonnull InputStream inputStream, int maxIterations) public static PGPKeyRing readKeyRing(@Nonnull InputStream inputStream, int maxIterations)
throws IOException { throws IOException {
PGPObjectFactory objectFactory = ImplementationFactory.getInstance().getPGPObjectFactory( PGPObjectFactory objectFactory = ImplementationFactory.getInstance().getPGPObjectFactory(
@ -198,6 +219,7 @@ public class KeyRingReader {
throw new IOException("Loop exceeded max iteration count."); throw new IOException("Loop exceeded max iteration count.");
} }
@Nullable
public static PGPPublicKeyRing readPublicKeyRing(@Nonnull InputStream inputStream) public static PGPPublicKeyRing readPublicKeyRing(@Nonnull InputStream inputStream)
throws IOException { throws IOException {
return readPublicKeyRing(inputStream, MAX_ITERATIONS); return readPublicKeyRing(inputStream, MAX_ITERATIONS);
@ -214,6 +236,7 @@ public class KeyRingReader {
* *
* @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
*/ */
@Nullable
public static PGPPublicKeyRing readPublicKeyRing(@Nonnull InputStream inputStream, int maxIterations) public static PGPPublicKeyRing readPublicKeyRing(@Nonnull InputStream inputStream, int maxIterations)
throws IOException { throws IOException {
PGPObjectFactory objectFactory = ImplementationFactory.getInstance().getPGPObjectFactory( PGPObjectFactory objectFactory = ImplementationFactory.getInstance().getPGPObjectFactory(
@ -236,6 +259,7 @@ public class KeyRingReader {
throw new IOException("Loop exceeded max iteration count."); throw new IOException("Loop exceeded max iteration count.");
} }
@Nonnull
public static PGPPublicKeyRingCollection readPublicKeyRingCollection(@Nonnull InputStream inputStream) public static PGPPublicKeyRingCollection readPublicKeyRingCollection(@Nonnull InputStream inputStream)
throws IOException { throws IOException {
return readPublicKeyRingCollection(inputStream, MAX_ITERATIONS); return readPublicKeyRingCollection(inputStream, MAX_ITERATIONS);
@ -252,6 +276,7 @@ public class KeyRingReader {
* *
* @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
*/ */
@Nonnull
public static PGPPublicKeyRingCollection readPublicKeyRingCollection(@Nonnull InputStream inputStream, int maxIterations) public static PGPPublicKeyRingCollection readPublicKeyRingCollection(@Nonnull InputStream inputStream, int maxIterations)
throws IOException { throws IOException {
PGPObjectFactory objectFactory = ImplementationFactory.getInstance().getPGPObjectFactory( PGPObjectFactory objectFactory = ImplementationFactory.getInstance().getPGPObjectFactory(
@ -283,6 +308,7 @@ public class KeyRingReader {
throw new IOException("Loop exceeded max iteration count."); throw new IOException("Loop exceeded max iteration count.");
} }
@Nullable
public static PGPSecretKeyRing readSecretKeyRing(@Nonnull InputStream inputStream) public static PGPSecretKeyRing readSecretKeyRing(@Nonnull InputStream inputStream)
throws IOException { throws IOException {
return readSecretKeyRing(inputStream, MAX_ITERATIONS); return readSecretKeyRing(inputStream, MAX_ITERATIONS);
@ -299,6 +325,7 @@ public class KeyRingReader {
* *
* @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
*/ */
@Nullable
public static PGPSecretKeyRing readSecretKeyRing(@Nonnull InputStream inputStream, int maxIterations) public static PGPSecretKeyRing readSecretKeyRing(@Nonnull InputStream inputStream, int maxIterations)
throws IOException { throws IOException {
InputStream decoderStream = ArmorUtils.getDecoderStream(inputStream); InputStream decoderStream = ArmorUtils.getDecoderStream(inputStream);
@ -322,6 +349,7 @@ public class KeyRingReader {
throw new IOException("Loop exceeded max iteration count."); throw new IOException("Loop exceeded max iteration count.");
} }
@Nonnull
public static PGPSecretKeyRingCollection readSecretKeyRingCollection(@Nonnull InputStream inputStream) public static PGPSecretKeyRingCollection readSecretKeyRingCollection(@Nonnull InputStream inputStream)
throws IOException { throws IOException {
return readSecretKeyRingCollection(inputStream, MAX_ITERATIONS); return readSecretKeyRingCollection(inputStream, MAX_ITERATIONS);
@ -338,6 +366,7 @@ public class KeyRingReader {
* *
* @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
*/ */
@Nonnull
public static PGPSecretKeyRingCollection readSecretKeyRingCollection(@Nonnull InputStream inputStream, public static PGPSecretKeyRingCollection readSecretKeyRingCollection(@Nonnull InputStream inputStream,
int maxIterations) int maxIterations)
throws IOException { throws IOException {
@ -370,6 +399,7 @@ public class KeyRingReader {
throw new IOException("Loop exceeded max iteration count."); throw new IOException("Loop exceeded max iteration count.");
} }
@Nonnull
public static PGPKeyRingCollection readKeyRingCollection(@Nonnull InputStream inputStream, boolean isSilent) public static PGPKeyRingCollection readKeyRingCollection(@Nonnull InputStream inputStream, boolean isSilent)
throws IOException, PGPException { throws IOException, PGPException {
return new PGPKeyRingCollection(inputStream, isSilent); return new PGPKeyRingCollection(inputStream, isSilent);