mirror of
https://github.com/pgpainless/pgpainless.git
synced 2025-09-09 18:29:39 +02:00
GnuPGDummyKeyUtil: Migrate to KeyIdentifier
This commit is contained in:
parent
bca4ddcb6f
commit
74c821c1e8
1 changed files with 18 additions and 5 deletions
|
@ -4,6 +4,7 @@
|
||||||
|
|
||||||
package org.gnupg;
|
package org.gnupg;
|
||||||
|
|
||||||
|
import org.bouncycastle.bcpg.KeyIdentifier;
|
||||||
import org.bouncycastle.bcpg.PublicKeyPacket;
|
import org.bouncycastle.bcpg.PublicKeyPacket;
|
||||||
import org.bouncycastle.bcpg.S2K;
|
import org.bouncycastle.bcpg.S2K;
|
||||||
import org.bouncycastle.bcpg.SecretKeyPacket;
|
import org.bouncycastle.bcpg.SecretKeyPacket;
|
||||||
|
@ -132,7 +133,7 @@ public final class GnuPGDummyKeyUtil {
|
||||||
|
|
||||||
List<PGPSecretKey> secretKeyList = new ArrayList<>();
|
List<PGPSecretKey> secretKeyList = new ArrayList<>();
|
||||||
for (PGPSecretKey secretKey : keys) {
|
for (PGPSecretKey secretKey : keys) {
|
||||||
if (!filter.filter(secretKey.getKeyID())) {
|
if (!filter.filter(secretKey.getKeyIdentifier())) {
|
||||||
// No conversion, do not modify subkey
|
// No conversion, do not modify subkey
|
||||||
secretKeyList.add(secretKey);
|
secretKeyList.add(secretKey);
|
||||||
continue;
|
continue;
|
||||||
|
@ -177,10 +178,10 @@ public final class GnuPGDummyKeyUtil {
|
||||||
/**
|
/**
|
||||||
* Return true, if the given key should be selected, false otherwise.
|
* Return true, if the given key should be selected, false otherwise.
|
||||||
*
|
*
|
||||||
* @param keyId id of the key
|
* @param keyIdentifier id of the key
|
||||||
* @return select
|
* @return select
|
||||||
*/
|
*/
|
||||||
boolean filter(long keyId);
|
boolean filter(KeyIdentifier keyIdentifier);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Select any key.
|
* Select any key.
|
||||||
|
@ -196,9 +197,21 @@ public final class GnuPGDummyKeyUtil {
|
||||||
*
|
*
|
||||||
* @param onlyKeyId only acceptable key id
|
* @param onlyKeyId only acceptable key id
|
||||||
* @return filter
|
* @return filter
|
||||||
|
* @deprecated use {@link #only(KeyIdentifier)} instead.
|
||||||
*/
|
*/
|
||||||
|
@Deprecated
|
||||||
static KeyFilter only(long onlyKeyId) {
|
static KeyFilter only(long onlyKeyId) {
|
||||||
return keyId -> keyId == onlyKeyId;
|
return only(new KeyIdentifier(onlyKeyId));
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Select only the given keyIdentifier.
|
||||||
|
*
|
||||||
|
* @param onlyKeyIdentifier only acceptable key identifier
|
||||||
|
* @return filter
|
||||||
|
*/
|
||||||
|
static KeyFilter only(KeyIdentifier onlyKeyIdentifier) {
|
||||||
|
return keyIdentifier -> keyIdentifier.matches(onlyKeyIdentifier);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -207,7 +220,7 @@ public final class GnuPGDummyKeyUtil {
|
||||||
* @param ids set of acceptable keyIds
|
* @param ids set of acceptable keyIds
|
||||||
* @return filter
|
* @return filter
|
||||||
*/
|
*/
|
||||||
static KeyFilter selected(Collection<Long> ids) {
|
static KeyFilter selected(Collection<KeyIdentifier> ids) {
|
||||||
// noinspection Convert2MethodRef
|
// noinspection Convert2MethodRef
|
||||||
return keyId -> ids.contains(keyId);
|
return keyId -> ids.contains(keyId);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue