Example usage for org.bouncycastle.openpgp PGPSecretKeyRing removeSecretKey

List of usage examples for org.bouncycastle.openpgp PGPSecretKeyRing removeSecretKey

Introduction

In this page you can find the example usage for org.bouncycastle.openpgp PGPSecretKeyRing removeSecretKey.

Prototype

public static PGPSecretKeyRing removeSecretKey(PGPSecretKeyRing secRing, PGPSecretKey secKey) 

Source Link

Document

Returns a new key ring with the secret key passed in removed from the key ring.

Usage

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   w  ww .j  a va  2  s .  c  om*/
 *
 * @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);
    }
}