Package org.pgpainless.util
Class ArmorUtils
- java.lang.Object
-
- org.pgpainless.util.ArmorUtils
-
public final class ArmorUtils extends java.lang.Object
-
-
Field Summary
Fields Modifier and Type Field Description static java.lang.String
HEADER_CHARSET
static java.lang.String
HEADER_COMMENT
static java.lang.String
HEADER_HASH
static java.lang.String
HEADER_MESSAGEID
static java.lang.String
HEADER_VERSION
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static void
addCommentHeader(org.bouncycastle.bcpg.ArmoredOutputStream armor, java.lang.String comment)
static void
addHashAlgorithmHeader(org.bouncycastle.bcpg.ArmoredOutputStream armor, HashAlgorithm hashAlgorithm)
static void
addMessageIdHeader(org.bouncycastle.bcpg.ArmoredOutputStream armor, java.lang.String messageId)
static org.bouncycastle.bcpg.ArmoredOutputStream
createArmoredOutputStreamFor(org.bouncycastle.openpgp.PGPKeyRing keyRing, java.io.OutputStream outputStream)
static java.util.List<java.lang.String>
getArmorHeaderValues(org.bouncycastle.bcpg.ArmoredInputStream armor, java.lang.String headerKey)
static java.util.List<java.lang.String>
getCharsetHeaderValues(org.bouncycastle.bcpg.ArmoredInputStream armor)
static java.util.List<java.lang.String>
getCommendHeaderValues(org.bouncycastle.bcpg.ArmoredInputStream armor)
static java.io.InputStream
getDecoderStream(java.io.InputStream inputStream)
Hacky workaround for #96.static java.util.List<HashAlgorithm>
getHashAlgorithms(org.bouncycastle.bcpg.ArmoredInputStream armor)
static java.util.List<java.lang.String>
getHashHeaderValues(org.bouncycastle.bcpg.ArmoredInputStream armor)
static java.util.List<java.lang.String>
getMessageIdHeaderValues(org.bouncycastle.bcpg.ArmoredInputStream armor)
static java.util.List<java.lang.String>
getVersionHeaderValues(org.bouncycastle.bcpg.ArmoredInputStream armor)
static org.bouncycastle.bcpg.ArmoredOutputStream
toAsciiArmoredStream(java.io.OutputStream outputStream, MultiMap<java.lang.String,java.lang.String> header)
static org.bouncycastle.bcpg.ArmoredOutputStream
toAsciiArmoredStream(org.bouncycastle.openpgp.PGPKeyRing keyRing, java.io.OutputStream outputStream)
static java.lang.String
toAsciiArmoredString(byte[] bytes)
static java.lang.String
toAsciiArmoredString(byte[] bytes, MultiMap<java.lang.String,java.lang.String> additionalHeaderValues)
static java.lang.String
toAsciiArmoredString(java.io.InputStream inputStream)
static java.lang.String
toAsciiArmoredString(java.io.InputStream inputStream, MultiMap<java.lang.String,java.lang.String> additionalHeaderValues)
static java.lang.String
toAsciiArmoredString(org.bouncycastle.openpgp.PGPPublicKeyRing publicKeys)
static java.lang.String
toAsciiArmoredString(org.bouncycastle.openpgp.PGPPublicKeyRingCollection publicKeyRings)
static java.lang.String
toAsciiArmoredString(org.bouncycastle.openpgp.PGPSecretKeyRing secretKeys)
static java.lang.String
toAsciiArmoredString(org.bouncycastle.openpgp.PGPSecretKeyRingCollection secretKeyRings)
-
-
-
Field Detail
-
HEADER_COMMENT
public static final java.lang.String HEADER_COMMENT
- See Also:
- Constant Field Values
-
HEADER_VERSION
public static final java.lang.String HEADER_VERSION
- See Also:
- Constant Field Values
-
HEADER_MESSAGEID
public static final java.lang.String HEADER_MESSAGEID
- See Also:
- Constant Field Values
-
HEADER_HASH
public static final java.lang.String HEADER_HASH
- See Also:
- Constant Field Values
-
HEADER_CHARSET
public static final java.lang.String HEADER_CHARSET
- See Also:
- Constant Field Values
-
-
Method Detail
-
toAsciiArmoredString
public static java.lang.String toAsciiArmoredString(org.bouncycastle.openpgp.PGPSecretKeyRing secretKeys) throws java.io.IOException
- Throws:
java.io.IOException
-
toAsciiArmoredString
public static java.lang.String toAsciiArmoredString(org.bouncycastle.openpgp.PGPPublicKeyRing publicKeys) throws java.io.IOException
- Throws:
java.io.IOException
-
toAsciiArmoredString
public static java.lang.String toAsciiArmoredString(org.bouncycastle.openpgp.PGPSecretKeyRingCollection secretKeyRings) throws java.io.IOException
- Throws:
java.io.IOException
-
toAsciiArmoredStream
public static org.bouncycastle.bcpg.ArmoredOutputStream toAsciiArmoredStream(org.bouncycastle.openpgp.PGPKeyRing keyRing, java.io.OutputStream outputStream)
-
toAsciiArmoredStream
public static org.bouncycastle.bcpg.ArmoredOutputStream toAsciiArmoredStream(java.io.OutputStream outputStream, MultiMap<java.lang.String,java.lang.String> header)
-
toAsciiArmoredString
public static java.lang.String toAsciiArmoredString(org.bouncycastle.openpgp.PGPPublicKeyRingCollection publicKeyRings) throws java.io.IOException
- Throws:
java.io.IOException
-
toAsciiArmoredString
public static java.lang.String toAsciiArmoredString(byte[] bytes) throws java.io.IOException
- Throws:
java.io.IOException
-
toAsciiArmoredString
public static java.lang.String toAsciiArmoredString(byte[] bytes, MultiMap<java.lang.String,java.lang.String> additionalHeaderValues) throws java.io.IOException
- Throws:
java.io.IOException
-
toAsciiArmoredString
public static java.lang.String toAsciiArmoredString(java.io.InputStream inputStream) throws java.io.IOException
- Throws:
java.io.IOException
-
addHashAlgorithmHeader
public static void addHashAlgorithmHeader(org.bouncycastle.bcpg.ArmoredOutputStream armor, HashAlgorithm hashAlgorithm)
-
addCommentHeader
public static void addCommentHeader(org.bouncycastle.bcpg.ArmoredOutputStream armor, java.lang.String comment)
-
addMessageIdHeader
public static void addMessageIdHeader(org.bouncycastle.bcpg.ArmoredOutputStream armor, java.lang.String messageId)
-
toAsciiArmoredString
public static java.lang.String toAsciiArmoredString(java.io.InputStream inputStream, MultiMap<java.lang.String,java.lang.String> additionalHeaderValues) throws java.io.IOException
- Throws:
java.io.IOException
-
createArmoredOutputStreamFor
public static org.bouncycastle.bcpg.ArmoredOutputStream createArmoredOutputStreamFor(org.bouncycastle.openpgp.PGPKeyRing keyRing, java.io.OutputStream outputStream)
-
getCommendHeaderValues
public static java.util.List<java.lang.String> getCommendHeaderValues(org.bouncycastle.bcpg.ArmoredInputStream armor)
-
getMessageIdHeaderValues
public static java.util.List<java.lang.String> getMessageIdHeaderValues(org.bouncycastle.bcpg.ArmoredInputStream armor)
-
getHashHeaderValues
public static java.util.List<java.lang.String> getHashHeaderValues(org.bouncycastle.bcpg.ArmoredInputStream armor)
-
getHashAlgorithms
public static java.util.List<HashAlgorithm> getHashAlgorithms(org.bouncycastle.bcpg.ArmoredInputStream armor)
-
getVersionHeaderValues
public static java.util.List<java.lang.String> getVersionHeaderValues(org.bouncycastle.bcpg.ArmoredInputStream armor)
-
getCharsetHeaderValues
public static java.util.List<java.lang.String> getCharsetHeaderValues(org.bouncycastle.bcpg.ArmoredInputStream armor)
-
getArmorHeaderValues
public static java.util.List<java.lang.String> getArmorHeaderValues(org.bouncycastle.bcpg.ArmoredInputStream armor, java.lang.String headerKey)
-
getDecoderStream
public static java.io.InputStream getDecoderStream(java.io.InputStream inputStream) throws java.io.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:
java.io.IOException
-
-