Package org.pgpainless.key.util
Class KeyRingUtils
- java.lang.Object
-
- org.pgpainless.key.util.KeyRingUtils
-
public class KeyRingUtils extends java.lang.Object
-
-
Constructor Summary
Constructors Constructor Description KeyRingUtils()
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static org.bouncycastle.openpgp.PGPPublicKeygetPrimaryPublicKeyFrom(org.bouncycastle.openpgp.PGPKeyRing keyRing)Return the primaryPGPPublicKeyfrom the provided key ring or null if it has none.static org.bouncycastle.openpgp.PGPSecretKeygetPrimarySecretKeyFrom(org.bouncycastle.openpgp.PGPSecretKeyRing secretKeys)Return the primaryPGPSecretKeyfrom the providedPGPSecretKeyRingor null if it has none.static org.bouncycastle.openpgp.PGPPublicKeyRingpublicKeyRingFrom(org.bouncycastle.openpgp.PGPSecretKeyRing secretKeys)Extract aPGPPublicKeyRingcontaining all public keys from the providedPGPSecretKeyRing.static org.bouncycastle.openpgp.PGPPublicKeyrequirePrimaryPublicKeyFrom(org.bouncycastle.openpgp.PGPKeyRing keyRing)Return the primaryPGPPublicKeyfrom the provided key ring.static org.bouncycastle.openpgp.PGPSecretKeyrequirePrimarySecretKeyFrom(org.bouncycastle.openpgp.PGPSecretKeyRing secretKeys)Return the primaryPGPSecretKeyfrom the providedPGPSecretKeyRing.static org.bouncycastle.openpgp.PGPPrivateKeyunlockSecretKey(org.bouncycastle.openpgp.PGPSecretKey secretKey, SecretKeyRingProtector protector)Unlock aPGPSecretKeyand return the resultingPGPPrivateKey.
-
-
-
Method Detail
-
requirePrimarySecretKeyFrom
public static org.bouncycastle.openpgp.PGPSecretKey requirePrimarySecretKeyFrom(org.bouncycastle.openpgp.PGPSecretKeyRing secretKeys)
Return the primaryPGPSecretKeyfrom the providedPGPSecretKeyRing. If it has no primary secret key, throw aNoSuchElementException.- Parameters:
secretKeys- secret keys- Returns:
- primary secret key
-
getPrimarySecretKeyFrom
public static org.bouncycastle.openpgp.PGPSecretKey getPrimarySecretKeyFrom(org.bouncycastle.openpgp.PGPSecretKeyRing secretKeys)
Return the primaryPGPSecretKeyfrom the providedPGPSecretKeyRingor null if it has none.- Parameters:
secretKeys- secret key ring- Returns:
- primary secret key
-
requirePrimaryPublicKeyFrom
public static org.bouncycastle.openpgp.PGPPublicKey requirePrimaryPublicKeyFrom(org.bouncycastle.openpgp.PGPKeyRing keyRing)
Return the primaryPGPPublicKeyfrom the provided key ring. Throws aNoSuchElementExceptionif the key ring has no primary public key.- Parameters:
keyRing- key ring- Returns:
- primary public key
-
getPrimaryPublicKeyFrom
public static org.bouncycastle.openpgp.PGPPublicKey getPrimaryPublicKeyFrom(org.bouncycastle.openpgp.PGPKeyRing keyRing)
Return the primaryPGPPublicKeyfrom the provided key ring or null if it has none.- Parameters:
keyRing- key ring- Returns:
- primary public key
-
publicKeyRingFrom
public static org.bouncycastle.openpgp.PGPPublicKeyRing publicKeyRingFrom(org.bouncycastle.openpgp.PGPSecretKeyRing secretKeys)
Extract aPGPPublicKeyRingcontaining all public keys from the providedPGPSecretKeyRing.- Parameters:
secretKeys- secret key ring- Returns:
- public key ring
-
unlockSecretKey
public static org.bouncycastle.openpgp.PGPPrivateKey unlockSecretKey(org.bouncycastle.openpgp.PGPSecretKey secretKey, SecretKeyRingProtector protector) throws org.bouncycastle.openpgp.PGPExceptionUnlock aPGPSecretKeyand return the resultingPGPPrivateKey.- Parameters:
secretKey- secret keyprotector- protector to unlock the secret key- Returns:
- private key
- Throws:
org.bouncycastle.openpgp.PGPException- if something goes wrong (eg. wrong passphrase)
-
-