mirror of
https://github.com/pgpainless/pgpainless.git
synced 2025-09-09 18:29:39 +02:00
SOP certify-userid: Properly throw KeyCannotCertify exception
This commit is contained in:
parent
d540febc7f
commit
b7dedbd619
1 changed files with 11 additions and 6 deletions
|
@ -9,6 +9,7 @@ import java.io.OutputStream
|
|||
import org.bouncycastle.bcpg.PacketFormat
|
||||
import org.bouncycastle.openpgp.api.OpenPGPKey
|
||||
import org.pgpainless.PGPainless
|
||||
import org.pgpainless.exception.KeyException
|
||||
import org.pgpainless.util.ArmoredOutputStreamFactory
|
||||
import org.pgpainless.util.Passphrase
|
||||
import sop.Ready
|
||||
|
@ -45,12 +46,16 @@ class CertifyUserIdImpl(private val api: PGPainless) : CertifyUserId {
|
|||
var certificate = cert
|
||||
keys.forEach { key ->
|
||||
userIds.forEach { userId ->
|
||||
certificate =
|
||||
api.generateCertification()
|
||||
.certifyUserId(userId, certificate)
|
||||
.withKey(key, protector)
|
||||
.build()
|
||||
.certifiedCertificate
|
||||
try {
|
||||
certificate =
|
||||
api.generateCertification()
|
||||
.certifyUserId(userId, certificate)
|
||||
.withKey(key, protector)
|
||||
.build()
|
||||
.certifiedCertificate
|
||||
} catch (e: KeyException) {
|
||||
throw SOPGPException.KeyCannotCertify(e)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue