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.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
|
||||||
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
|
||||||
|
@ -45,12 +46,16 @@ class CertifyUserIdImpl(private val api: PGPainless) : CertifyUserId {
|
||||||
var certificate = cert
|
var certificate = cert
|
||||||
keys.forEach { key ->
|
keys.forEach { key ->
|
||||||
userIds.forEach { userId ->
|
userIds.forEach { userId ->
|
||||||
certificate =
|
try {
|
||||||
api.generateCertification()
|
certificate =
|
||||||
.certifyUserId(userId, certificate)
|
api.generateCertification()
|
||||||
.withKey(key, protector)
|
.certifyUserId(userId, certificate)
|
||||||
.build()
|
.withKey(key, protector)
|
||||||
.certifiedCertificate
|
.build()
|
||||||
|
.certifiedCertificate
|
||||||
|
} catch (e: KeyException) {
|
||||||
|
throw SOPGPException.KeyCannotCertify(e)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue