Package org.pgpainless.util
Class ArmorUtils
- java.lang.Object
-
- org.pgpainless.util.ArmorUtils
-
public final class ArmorUtils extends Object
-
-
Field Summary
Fields Modifier and Type Field Description static String
HEADER_CHARSET
static String
HEADER_COMMENT
static String
HEADER_HASH
static String
HEADER_MESSAGEID
static String
HEADER_VERSION
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static void
addCommentHeader(org.bouncycastle.bcpg.ArmoredOutputStream armor, String comment)
static void
addHashAlgorithmHeader(org.bouncycastle.bcpg.ArmoredOutputStream armor, HashAlgorithm hashAlgorithm)
static void
addMessageIdHeader(org.bouncycastle.bcpg.ArmoredOutputStream armor, String messageId)
static org.bouncycastle.bcpg.ArmoredOutputStream
createArmoredOutputStreamFor(org.bouncycastle.openpgp.PGPKeyRing keyRing, OutputStream outputStream)
static List<String>
getArmorHeaderValues(org.bouncycastle.bcpg.ArmoredInputStream armor, String headerKey)
static List<String>
getCharsetHeaderValues(org.bouncycastle.bcpg.ArmoredInputStream armor)
static List<String>
getCommentHeaderValues(org.bouncycastle.bcpg.ArmoredInputStream armor)
static InputStream
getDecoderStream(InputStream inputStream)
Hacky workaround for #96.static List<HashAlgorithm>
getHashAlgorithms(org.bouncycastle.bcpg.ArmoredInputStream armor)
static List<String>
getHashHeaderValues(org.bouncycastle.bcpg.ArmoredInputStream armor)
static List<String>
getMessageIdHeaderValues(org.bouncycastle.bcpg.ArmoredInputStream armor)
static List<String>
getVersionHeaderValues(org.bouncycastle.bcpg.ArmoredInputStream armor)
static org.bouncycastle.bcpg.ArmoredOutputStream
toAsciiArmoredStream(OutputStream outputStream, MultiMap<String,String> header)
static org.bouncycastle.bcpg.ArmoredOutputStream
toAsciiArmoredStream(org.bouncycastle.openpgp.PGPKeyRing keyRing, OutputStream outputStream)
static String
toAsciiArmoredString(byte[] bytes)
static String
toAsciiArmoredString(byte[] bytes, MultiMap<String,String> additionalHeaderValues)
static String
toAsciiArmoredString(InputStream inputStream)
static String
toAsciiArmoredString(InputStream inputStream, MultiMap<String,String> additionalHeaderValues)
static String
toAsciiArmoredString(org.bouncycastle.openpgp.PGPPublicKeyRing publicKeys)
static String
toAsciiArmoredString(org.bouncycastle.openpgp.PGPPublicKeyRingCollection publicKeyRings)
static String
toAsciiArmoredString(org.bouncycastle.openpgp.PGPSecretKeyRing secretKeys)
static String
toAsciiArmoredString(org.bouncycastle.openpgp.PGPSecretKeyRingCollection secretKeyRings)
-
-
-
Field Detail
-
HEADER_COMMENT
public static final String HEADER_COMMENT
- See Also:
- Constant Field Values
-
HEADER_VERSION
public static final String HEADER_VERSION
- See Also:
- Constant Field Values
-
HEADER_MESSAGEID
public static final String HEADER_MESSAGEID
- See Also:
- Constant Field Values
-
HEADER_HASH
public static final String HEADER_HASH
- See Also:
- Constant Field Values
-
HEADER_CHARSET
public static final String HEADER_CHARSET
- See Also:
- Constant Field Values
-
-
Method Detail
-
toAsciiArmoredString
public static String toAsciiArmoredString(org.bouncycastle.openpgp.PGPSecretKeyRing secretKeys) throws IOException
- Throws:
IOException
-
toAsciiArmoredString
public static String toAsciiArmoredString(org.bouncycastle.openpgp.PGPPublicKeyRing publicKeys) throws IOException
- Throws:
IOException
-
toAsciiArmoredString
public static String toAsciiArmoredString(org.bouncycastle.openpgp.PGPSecretKeyRingCollection secretKeyRings) throws IOException
- Throws:
IOException
-
toAsciiArmoredStream
public static org.bouncycastle.bcpg.ArmoredOutputStream toAsciiArmoredStream(org.bouncycastle.openpgp.PGPKeyRing keyRing, OutputStream outputStream)
-
toAsciiArmoredStream
public static org.bouncycastle.bcpg.ArmoredOutputStream toAsciiArmoredStream(OutputStream outputStream, MultiMap<String,String> header)
-
toAsciiArmoredString
public static String toAsciiArmoredString(org.bouncycastle.openpgp.PGPPublicKeyRingCollection publicKeyRings) throws IOException
- Throws:
IOException
-
toAsciiArmoredString
public static String toAsciiArmoredString(byte[] bytes) throws IOException
- Throws:
IOException
-
toAsciiArmoredString
public static String toAsciiArmoredString(byte[] bytes, MultiMap<String,String> additionalHeaderValues) throws IOException
- Throws:
IOException
-
toAsciiArmoredString
public static String toAsciiArmoredString(InputStream inputStream) throws IOException
- Throws:
IOException
-
addHashAlgorithmHeader
public static void addHashAlgorithmHeader(org.bouncycastle.bcpg.ArmoredOutputStream armor, HashAlgorithm hashAlgorithm)
-
addCommentHeader
public static void addCommentHeader(org.bouncycastle.bcpg.ArmoredOutputStream armor, String comment)
-
addMessageIdHeader
public static void addMessageIdHeader(org.bouncycastle.bcpg.ArmoredOutputStream armor, String messageId)
-
toAsciiArmoredString
public static String toAsciiArmoredString(InputStream inputStream, MultiMap<String,String> additionalHeaderValues) throws IOException
- Throws:
IOException
-
createArmoredOutputStreamFor
public static org.bouncycastle.bcpg.ArmoredOutputStream createArmoredOutputStreamFor(org.bouncycastle.openpgp.PGPKeyRing keyRing, OutputStream outputStream)
-
getCommentHeaderValues
public static List<String> getCommentHeaderValues(org.bouncycastle.bcpg.ArmoredInputStream armor)
-
getMessageIdHeaderValues
public static List<String> getMessageIdHeaderValues(org.bouncycastle.bcpg.ArmoredInputStream armor)
-
getHashHeaderValues
public static List<String> getHashHeaderValues(org.bouncycastle.bcpg.ArmoredInputStream armor)
-
getHashAlgorithms
public static List<HashAlgorithm> getHashAlgorithms(org.bouncycastle.bcpg.ArmoredInputStream armor)
-
getVersionHeaderValues
public static List<String> getVersionHeaderValues(org.bouncycastle.bcpg.ArmoredInputStream armor)
-
getCharsetHeaderValues
public static List<String> getCharsetHeaderValues(org.bouncycastle.bcpg.ArmoredInputStream armor)
-
getArmorHeaderValues
public static List<String> getArmorHeaderValues(org.bouncycastle.bcpg.ArmoredInputStream armor, String headerKey)
-
getDecoderStream
public static InputStream getDecoderStream(InputStream inputStream) throws IOException
Hacky workaround for #96. ForPGPPublicKeyRingCollection(InputStream, KeyFingerPrintCalculator)
orPGPSecretKeyRingCollection(InputStream, KeyFingerPrintCalculator)
to read all PGPKeyRings properly, we apparently have to make sure that theInputStream
that is given as constructor argument is a PGPUtil.BufferedInputStreamExt. SincePGPUtil.getDecoderStream(InputStream)
will return anArmoredInputStream
if the underlying input stream contains armored data, we have to nest two method calls to make sure that the end-result is a PGPUtil.BufferedInputStreamExt. This is a hacky solution.- Parameters:
inputStream
- input stream- Returns:
- BufferedInputStreamExt
- Throws:
IOException
-
-