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 996984cbb5
commit 9812d4d78c
Signed by: vanitasvitae
GPG key ID: 62BEE9264BF17311

View file

@ -417,6 +417,7 @@ class ConsumerOptions {
* @param certificate certificate * @param certificate certificate
*/ */
@JvmOverloads @JvmOverloads
@Deprecated("Pass in an OpenPGPCertificate instead.")
fun addCertificate( fun addCertificate(
certificate: PGPPublicKeyRing, certificate: PGPPublicKeyRing,
implementation: OpenPGPImplementation = PGPainless.getInstance().implementation implementation: OpenPGPImplementation = PGPainless.getInstance().implementation
@ -424,6 +425,11 @@ class ConsumerOptions {
explicitCertificates.add(OpenPGPCertificate(certificate, implementation)) explicitCertificates.add(OpenPGPCertificate(certificate, implementation))
} }
/**
* Add a certificate as explicitly provided verification cert.
*
* @param certificate explicit verification cert
*/
fun addCertificate(certificate: OpenPGPCertificate) { fun addCertificate(certificate: OpenPGPCertificate) {
explicitCertificates.add(certificate) explicitCertificates.add(certificate)
} }
@ -445,14 +451,24 @@ class ConsumerOptions {
* @param keyId key id * @param keyId key id
* @return certificate * @return certificate
*/ */
@Deprecated("Pass in a KeyIdentifier instead.")
fun getCertificate(keyId: Long): OpenPGPCertificate? { fun getCertificate(keyId: Long): OpenPGPCertificate? {
return getCertificate(KeyIdentifier(keyId)) 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? { fun getCertificate(identifier: KeyIdentifier): OpenPGPCertificate? {
return explicitCertificates.firstOrNull { it.getKey(identifier) != null } return explicitCertificates.firstOrNull { it.getKey(identifier) != null }
} }
/** Find a certificate containing the issuer component key for the given [signature]. */
fun getCertificate(signature: PGPSignature): OpenPGPCertificate? = fun getCertificate(signature: PGPSignature): OpenPGPCertificate? =
explicitCertificates.firstOrNull { it.getSigningKeyFor(signature) != null } explicitCertificates.firstOrNull { it.getSigningKeyFor(signature) != null }
} }