List of usage examples for org.bouncycastle.openpgp PGPPublicKeyRing removePublicKey
public static PGPPublicKeyRing removePublicKey(PGPPublicKeyRing pubRing, PGPPublicKey pubKey)
From source file:com.google.gerrit.gpg.PublicKeyStoreTest.java
License:Apache License
@Test public void updateExisting() throws Exception { TestKey key5 = TestKey.key5();/*w w w.j a va 2 s.c o m*/ PGPPublicKeyRing keyRing = key5.getPublicKeyRing(); PGPPublicKey key = keyRing.getPublicKey(); store.add(keyRing); assertEquals(RefUpdate.Result.NEW, store.save(newCommitBuilder())); assertUserIds(store.get(key5.getKeyId()).iterator().next(), "Testuser Five <test5@example.com>", "foo:myId"); keyRing = PGPPublicKeyRing.removePublicKey(keyRing, key); key = PGPPublicKey.removeCertification(key, "foo:myId"); keyRing = PGPPublicKeyRing.insertPublicKey(keyRing, key); store.add(keyRing); assertEquals(RefUpdate.Result.FAST_FORWARD, store.save(newCommitBuilder())); Iterator<PGPPublicKeyRing> keyRings = store.get(key.getKeyID()).iterator(); keyRing = keyRings.next(); assertFalse(keyRings.hasNext()); assertUserIds(keyRing, "Testuser Five <test5@example.com>"); }
From source file:org.sufficientlysecure.keychain.pgp.UncachedKeyRing.java
License:Open Source License
/** This method removes a subkey in a keyring. * * This method essentially wraps PGP*KeyRing.remove*Key, where the keyring may be of either * the secret or public subclass./*from ww w . java 2 s .c o m*/ * * @return the resulting PGPKeyRing of the same type as the input */ private static PGPKeyRing removeSubKey(PGPKeyRing ring, PGPPublicKey key) { if (ring instanceof PGPPublicKeyRing) { return PGPPublicKeyRing.removePublicKey((PGPPublicKeyRing) ring, key); } else { PGPSecretKey sKey = ((PGPSecretKeyRing) ring).getSecretKey(key.getKeyID()); return PGPSecretKeyRing.removeSecretKey((PGPSecretKeyRing) ring, sKey); } }