mirror of
https://github.com/pgpainless/pgpainless.git
synced 2025-12-10 14:21:09 +01:00
Add KeyRingInfo.isUsableForEncryption()
This commit is contained in:
parent
afad3fc747
commit
5b9e72d42c
2 changed files with 118 additions and 1 deletions
|
|
@ -1009,6 +1009,25 @@ public class KeyRingInfo {
|
|||
return new KeyAccessor.SubKey(this, new SubkeyIdentifier(keys, keyId)).getPreferredCompressionAlgorithms();
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns true, if the certificate has at least one usable encryption subkey.
|
||||
*
|
||||
* @return true if usable for encryption
|
||||
*/
|
||||
public boolean isUsableForEncryption() {
|
||||
return isUsableForEncryption(EncryptionPurpose.ANY);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns true, if the certificate has at least one usable encryption subkey for the given purpose.
|
||||
*
|
||||
* @param purpose purpose of encryption
|
||||
* @return true if usable for encryption
|
||||
*/
|
||||
public boolean isUsableForEncryption(@Nonnull EncryptionPurpose purpose) {
|
||||
return !getEncryptionSubkeys(purpose).isEmpty();
|
||||
}
|
||||
|
||||
private KeyAccessor getKeyAccessor(@Nullable String userId, long keyID) {
|
||||
if (getPublicKey(keyID) == null) {
|
||||
throw new NoSuchElementException("No subkey with key id " + Long.toHexString(keyID) + " found on this key.");
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue