1
0
Fork 0
mirror of https://github.com/pgpainless/pgpainless.git synced 2024-11-26 22:32:07 +01:00

Rename user-id deletion methods

This commit is contained in:
Paul Schaub 2021-11-13 16:05:55 +01:00
parent 74609e0ef7
commit 021fd7846e
Signed by: vanitasvitae
GPG key ID: 62BEE9264BF17311
2 changed files with 5 additions and 5 deletions

View file

@ -167,7 +167,7 @@ public final class KeyRingUtils {
* @return modified secret keys * @return modified secret keys
*/ */
@Deprecated @Deprecated
public static PGPSecretKeyRing deleteUserIdFromSecretKeyRing(PGPSecretKeyRing secretKeys, String userId) { public static PGPSecretKeyRing deleteUserId(PGPSecretKeyRing secretKeys, String userId) {
PGPSecretKey secretKey = secretKeys.getSecretKey(); // user-ids are located on primary key only PGPSecretKey secretKey = secretKeys.getSecretKey(); // user-ids are located on primary key only
PGPPublicKey publicKey = secretKey.getPublicKey(); // user-ids are placed on the public key part PGPPublicKey publicKey = secretKey.getPublicKey(); // user-ids are placed on the public key part
publicKey = PGPPublicKey.removeCertification(publicKey, userId); publicKey = PGPPublicKey.removeCertification(publicKey, userId);
@ -191,7 +191,7 @@ public final class KeyRingUtils {
* @return modified secret keys * @return modified secret keys
*/ */
@Deprecated @Deprecated
public static PGPPublicKeyRing deleteUserIdFromPublicKeyRing(PGPPublicKeyRing publicKeys, String userId) { public static PGPPublicKeyRing deleteUserId(PGPPublicKeyRing publicKeys, String userId) {
PGPPublicKey publicKey = publicKeys.getPublicKey(); // user-ids are located on primary key only PGPPublicKey publicKey = publicKeys.getPublicKey(); // user-ids are located on primary key only
publicKey = PGPPublicKey.removeCertification(publicKey, userId); publicKey = PGPPublicKey.removeCertification(publicKey, userId);
if (publicKey == null) { if (publicKey == null) {

View file

@ -32,7 +32,7 @@ public class KeyRingUtilTest {
.done(); .done();
assertEquals(2, CollectionUtils.iteratorToList(secretKeys.getPublicKey().getUserIDs()).size()); assertEquals(2, CollectionUtils.iteratorToList(secretKeys.getPublicKey().getUserIDs()).size());
secretKeys = KeyRingUtils.deleteUserIdFromSecretKeyRing(secretKeys, "Bob"); secretKeys = KeyRingUtils.deleteUserId(secretKeys, "Bob");
assertEquals(1, CollectionUtils.iteratorToList(secretKeys.getPublicKey().getUserIDs()).size()); assertEquals(1, CollectionUtils.iteratorToList(secretKeys.getPublicKey().getUserIDs()).size());
} }
@ -49,7 +49,7 @@ public class KeyRingUtilTest {
PGPPublicKeyRing publicKeys = PGPainless.extractCertificate(secretKeys); PGPPublicKeyRing publicKeys = PGPainless.extractCertificate(secretKeys);
assertEquals(2, CollectionUtils.iteratorToList(publicKeys.getPublicKey().getUserIDs()).size()); assertEquals(2, CollectionUtils.iteratorToList(publicKeys.getPublicKey().getUserIDs()).size());
publicKeys = KeyRingUtils.deleteUserIdFromPublicKeyRing(publicKeys, "Alice"); publicKeys = KeyRingUtils.deleteUserId(publicKeys, "Alice");
assertEquals(1, CollectionUtils.iteratorToList(publicKeys.getPublicKey().getUserIDs()).size()); assertEquals(1, CollectionUtils.iteratorToList(publicKeys.getPublicKey().getUserIDs()).size());
} }
@ -61,6 +61,6 @@ public class KeyRingUtilTest {
.modernKeyRing("Alice", null); .modernKeyRing("Alice", null);
assertThrows(NoSuchElementException.class, assertThrows(NoSuchElementException.class,
() -> KeyRingUtils.deleteUserIdFromSecretKeyRing(secretKeys, "Charlie")); () -> KeyRingUtils.deleteUserId(secretKeys, "Charlie"));
} }
} }