1
0
Fork 0
mirror of https://github.com/pgpainless/pgpainless.git synced 2025-09-09 18:29:39 +02:00

Certify-UserId: Throw proper exception on unbound user-id

This commit is contained in:
Paul Schaub 2025-04-10 13:51:52 +02:00
parent 148af79794
commit 168c884f27
Signed by: vanitasvitae
GPG key ID: 62BEE9264BF17311

View file

@ -9,11 +9,10 @@ import java.io.OutputStream
import org.bouncycastle.bcpg.PacketFormat import org.bouncycastle.bcpg.PacketFormat
import org.bouncycastle.openpgp.api.OpenPGPKey import org.bouncycastle.openpgp.api.OpenPGPKey
import org.pgpainless.PGPainless import org.pgpainless.PGPainless
import org.pgpainless.exception.KeyException.UnboundUserIdException
import org.pgpainless.key.OpenPgpFingerprint
import org.pgpainless.util.ArmoredOutputStreamFactory import org.pgpainless.util.ArmoredOutputStreamFactory
import org.pgpainless.util.Passphrase import org.pgpainless.util.Passphrase
import sop.Ready import sop.Ready
import sop.exception.SOPGPException
import sop.operation.CertifyUserId import sop.operation.CertifyUserId
class CertifyUserIdImpl(private val api: PGPainless) : CertifyUserId { class CertifyUserIdImpl(private val api: PGPainless) : CertifyUserId {
@ -39,10 +38,7 @@ class CertifyUserIdImpl(private val api: PGPainless) : CertifyUserId {
// Check for non-bound user-ids // Check for non-bound user-ids
userIds userIds
.find { cert.getUserId(it)?.isBound != true } .find { cert.getUserId(it)?.isBound != true }
?.let { ?.let { throw SOPGPException.CertUserIdNoMatch(cert.fingerprint) }
throw UnboundUserIdException(
OpenPgpFingerprint.Companion.of(cert), it, null, null)
}
} }
} }
.forEach { cert -> .forEach { cert ->