mirror of
https://github.com/pgpainless/pgpainless.git
synced 2024-11-23 04:42:06 +01:00
Rename user-id deletion methods
This commit is contained in:
parent
74609e0ef7
commit
021fd7846e
2 changed files with 5 additions and 5 deletions
|
@ -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) {
|
||||||
|
|
|
@ -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"));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue