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

Add some missing documentation to ConsumerOptions

This commit is contained in:
Paul Schaub 2025-02-28 14:13:48 +01:00
parent 62d6b7d5ab
commit 415f528490
Signed by: vanitasvitae
GPG key ID: 62BEE9264BF17311

View file

@ -417,6 +417,7 @@ class ConsumerOptions {
* @param certificate certificate
*/
@JvmOverloads
@Deprecated("Pass in an OpenPGPCertificate instead.")
fun addCertificate(
certificate: PGPPublicKeyRing,
implementation: OpenPGPImplementation = PGPainless.getInstance().implementation
@ -424,6 +425,11 @@ class ConsumerOptions {
explicitCertificates.add(OpenPGPCertificate(certificate, implementation))
}
/**
* Add a certificate as explicitly provided verification cert.
*
* @param certificate explicit verification cert
*/
fun addCertificate(certificate: OpenPGPCertificate) {
explicitCertificates.add(certificate)
}
@ -445,14 +451,24 @@ class ConsumerOptions {
* @param keyId key id
* @return certificate
*/
@Deprecated("Pass in a KeyIdentifier instead.")
fun getCertificate(keyId: Long): OpenPGPCertificate? {
return getCertificate(KeyIdentifier(keyId))
}
/**
* Return a certificate which contains a component key for the given [identifier]. This
* method first checks all explicitly provided verification certs and if no cert is found it
* consults the certificate stores.
*
* @param identifier key identifier
* @return certificate or null if no match is found
*/
fun getCertificate(identifier: KeyIdentifier): OpenPGPCertificate? {
return explicitCertificates.firstOrNull { it.getKey(identifier) != null }
}
/** Find a certificate containing the issuer component key for the given [signature]. */
fun getCertificate(signature: PGPSignature): OpenPGPCertificate? =
explicitCertificates.firstOrNull { it.getSigningKeyFor(signature) != null }
}