Created
July 26, 2014 14:27
-
-
Save jordanbaucke/0a677057cc95cfe77be4 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public static PGPSecretKey readSecretKey(InputStream input) throws IOException, PGPException { | |
PGPSecretKeyRingCollection pgpSec = new PGPSecretKeyRingCollection( | |
PGPUtil.getDecoderStream(input)); | |
Iterator keyRingIter = pgpSec.getKeyRings(); | |
while (keyRingIter.hasNext()) { | |
PGPSecretKeyRing keyRing = (PGPSecretKeyRing) keyRingIter.next(); | |
Iterator keyIter = keyRing.getSecretKeys(); | |
while (keyIter.hasNext()) { | |
PGPSecretKey key = (PGPSecretKey) keyIter.next(); | |
if (key.isSigningKey()) { | |
return key; | |
} | |
} | |
} | |
throw new IllegalArgumentException( | |
"Can't find signing key in key ring."); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment