mirror of
https://github.com/pgpainless/pgpainless.git
synced 2024-11-26 14:22:05 +01:00
PGPException is not thrown during secret key reading
This commit is contained in:
parent
6251e01d57
commit
2bd71617bd
3 changed files with 22 additions and 22 deletions
|
@ -40,7 +40,7 @@ public class KeyRingReader {
|
|||
|
||||
public static final Charset UTF8 = Charset.forName("UTF-8");
|
||||
|
||||
public @Nonnull PGPPublicKeyRing publicKeyRing(@Nonnull InputStream inputStream) throws IOException {
|
||||
public PGPPublicKeyRing publicKeyRing(@Nonnull InputStream inputStream) throws IOException {
|
||||
return readPublicKeyRing(inputStream);
|
||||
}
|
||||
|
||||
|
@ -65,15 +65,15 @@ public class KeyRingReader {
|
|||
return publicKeyRingCollection(asciiArmored.getBytes(UTF8));
|
||||
}
|
||||
|
||||
public PGPSecretKeyRing secretKeyRing(@Nonnull InputStream inputStream) throws IOException, PGPException {
|
||||
public PGPSecretKeyRing secretKeyRing(@Nonnull InputStream inputStream) throws IOException {
|
||||
return readSecretKeyRing(inputStream);
|
||||
}
|
||||
|
||||
public PGPSecretKeyRing secretKeyRing(@Nonnull byte[] bytes) throws IOException, PGPException {
|
||||
public PGPSecretKeyRing secretKeyRing(@Nonnull byte[] bytes) throws IOException {
|
||||
return secretKeyRing(new ByteArrayInputStream(bytes));
|
||||
}
|
||||
|
||||
public PGPSecretKeyRing secretKeyRing(@Nonnull String asciiArmored) throws IOException, PGPException {
|
||||
public PGPSecretKeyRing secretKeyRing(@Nonnull String asciiArmored) throws IOException {
|
||||
return secretKeyRing(asciiArmored.getBytes(UTF8));
|
||||
}
|
||||
|
||||
|
|
|
@ -122,7 +122,7 @@ public class RejectWeakSymmetricAlgorithmDuringDecryption {
|
|||
static {
|
||||
try {
|
||||
secretKeys = PGPainless.readKeyRing().secretKeyRing(key);
|
||||
} catch (IOException | PGPException e) {
|
||||
} catch (IOException e) {
|
||||
fail("Secret key cannot be parsed.");
|
||||
}
|
||||
}
|
||||
|
|
|
@ -41,8 +41,11 @@ public class ExtractCertImpl implements ExtractCert {
|
|||
|
||||
@Override
|
||||
public Ready key(InputStream keyInputStream) throws IOException, SOPGPException.BadData {
|
||||
try {
|
||||
PGPSecretKeyRing key = PGPainless.readKeyRing().secretKeyRing(keyInputStream);
|
||||
if (key == null) {
|
||||
throw new SOPGPException.BadData(new PGPException("No key data found."));
|
||||
}
|
||||
|
||||
PGPPublicKeyRing cert = KeyRingUtils.publicKeyRingFrom(key);
|
||||
|
||||
return new Ready() {
|
||||
|
@ -56,8 +59,5 @@ public class ExtractCertImpl implements ExtractCert {
|
|||
}
|
||||
}
|
||||
};
|
||||
} catch (PGPException e) {
|
||||
throw new SOPGPException.BadData(e);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue