List of usage examples for org.bouncycastle.openpgp PGPPublicKeyRingCollection removePublicKeyRing
public static PGPPublicKeyRingCollection removePublicKeyRing(PGPPublicKeyRingCollection ringCollection, PGPPublicKeyRing publicKeyRing)
From source file:org.jivesoftware.smackx.ox.OpenPgpContact.java
License:Apache License
/** * Return a {@link PGPPublicKeyRingCollection}, which contains all keys from {@code keys}, which are marked with the * {@link OpenPgpTrustStore.Trust} state of {@code trust}. * * @param keys {@link PGPPublicKeyRingCollection} * @param trust {@link OpenPgpTrustStore.Trust} * * @return all keys from {@code keys} with trust state {@code trust}. * * @throws IOException IO error//from w w w . j a va 2 s .c o m */ protected PGPPublicKeyRingCollection getPublicKeysOfTrustState(PGPPublicKeyRingCollection keys, OpenPgpTrustStore.Trust trust) throws IOException { if (keys == null) { return null; } Set<PGPPublicKeyRing> toRemove = new HashSet<>(); Iterator<PGPPublicKeyRing> iterator = keys.iterator(); while (iterator.hasNext()) { PGPPublicKeyRing ring = iterator.next(); OpenPgpV4Fingerprint fingerprint = new OpenPgpV4Fingerprint(ring); if (store.getTrust(getJid(), fingerprint) != trust) { toRemove.add(ring); } } for (PGPPublicKeyRing ring : toRemove) { keys = PGPPublicKeyRingCollection.removePublicKeyRing(keys, ring); } if (!keys.iterator().hasNext()) { return null; } return keys; }
From source file:org.jivesoftware.smackx.ox.store.abstr.AbstractOpenPgpKeyStore.java
License:Apache License
@Override public void deletePublicKeyRing(BareJid owner, OpenPgpV4Fingerprint fingerprint) throws IOException, PGPException { PGPPublicKeyRingCollection publicKeyRings = getPublicKeysOf(owner); if (publicKeyRings.contains(fingerprint.getKeyId())) { publicKeyRings = PGPPublicKeyRingCollection.removePublicKeyRing(publicKeyRings, publicKeyRings.getPublicKeyRing(fingerprint.getKeyId())); if (!publicKeyRings.iterator().hasNext()) { publicKeyRings = null;/*from w w w. j a va2s.c o m*/ } this.publicKeyRingCollections.put(owner, publicKeyRings); writePublicKeysOf(owner, publicKeyRings); } }
From source file:uk.co.platosys.dinigma.Lock.java
License:GNU General Public License
/** * Removes a lock. Use this method with caution! it removes all references to any public key referred to by the Lock argument. * This could include a key that has been added by way of another Lock. So remove carefully. * @param lock the Lock to be removed;/*from w w w. j a va 2s. c o m*/ * @return this Lock, but with the other Lock removed */ public Lock removeLock(Lock lock) throws MinigmaException { Iterator<PGPPublicKeyRing> keys = lock.getKeys(); try { while (keys.hasNext()) { PGPPublicKeyRing key = keys.next(); long keyID = key.getPublicKey().getKeyID(); if (!(publicKeys.contains(keyID))) { PGPPublicKeyRingCollection.removePublicKeyRing(publicKeys, key); } } } catch (Exception x) { throw new MinigmaException("Error concatenating Lock", x); } return this; }