mirror of
https://github.com/pgpainless/pgpainless.git
synced 2024-12-22 19:08:00 +01:00
Use KeyReader class when reading public or secret keys
This commit is contained in:
parent
744c679e0c
commit
e5539a810d
3 changed files with 3 additions and 8 deletions
|
@ -14,7 +14,6 @@ import org.bouncycastle.bcpg.ArmoredOutputStream;
|
|||
import org.bouncycastle.openpgp.PGPException;
|
||||
import org.bouncycastle.openpgp.PGPSecretKeyRing;
|
||||
import org.bouncycastle.openpgp.PGPSecretKeyRingCollection;
|
||||
import org.pgpainless.PGPainless;
|
||||
import org.pgpainless.exception.MissingPassphraseException;
|
||||
import org.pgpainless.key.OpenPgpFingerprint;
|
||||
import org.pgpainless.key.protection.SecretKeyRingProtector;
|
||||
|
@ -54,7 +53,7 @@ public class ChangeKeyPasswordImpl implements ChangeKeyPassword {
|
|||
SecretKeyRingProtector newProtector = SecretKeyRingProtector.unlockAnyKeyWith(newPassphrase);
|
||||
PGPSecretKeyRingCollection secretKeyRingCollection;
|
||||
try {
|
||||
secretKeyRingCollection = PGPainless.readKeyRing().secretKeyRingCollection(inputStream);
|
||||
secretKeyRingCollection = KeyReader.readSecretKeys(inputStream, true);
|
||||
} catch (IOException e) {
|
||||
throw new SOPGPException.BadData(e);
|
||||
}
|
||||
|
|
|
@ -105,11 +105,7 @@ public class EncryptImpl implements Encrypt {
|
|||
@Override
|
||||
public Encrypt withCert(InputStream cert) throws SOPGPException.CertCannotEncrypt, SOPGPException.UnsupportedAsymmetricAlgo, SOPGPException.BadData {
|
||||
try {
|
||||
PGPPublicKeyRingCollection certificates = PGPainless.readKeyRing()
|
||||
.publicKeyRingCollection(cert);
|
||||
if (certificates.size() == 0) {
|
||||
throw new SOPGPException.BadData("No certificate data found.");
|
||||
}
|
||||
PGPPublicKeyRingCollection certificates = KeyReader.readPublicKeys(cert, true);
|
||||
encryptionOptions.addRecipients(certificates);
|
||||
} catch (KeyException.UnacceptableEncryptionKeyException e) {
|
||||
throw new SOPGPException.CertCannotEncrypt(e.getMessage(), e);
|
||||
|
|
|
@ -66,7 +66,7 @@ public class RevokeKeyImpl implements RevokeKey {
|
|||
public Ready keys(InputStream keys) throws SOPGPException.BadData {
|
||||
PGPSecretKeyRingCollection secretKeyRings;
|
||||
try {
|
||||
secretKeyRings = PGPainless.readKeyRing().secretKeyRingCollection(keys);
|
||||
secretKeyRings = KeyReader.readSecretKeys(keys, true);
|
||||
} catch (IOException e) {
|
||||
throw new SOPGPException.BadData("Cannot decode secret keys.", e);
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue