Class ArmorUtils


  • public final class ArmorUtils
    extends java.lang.Object
    • 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)  
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • 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. For PGPPublicKeyRingCollection(InputStream, KeyFingerPrintCalculator) or PGPSecretKeyRingCollection(InputStream, KeyFingerPrintCalculator) to read all PGPKeyRings properly, we apparently have to make sure that the InputStream that is given as constructor argument is a PGPUtil.BufferedInputStreamExt. Since PGPUtil.getDecoderStream(InputStream) will return an ArmoredInputStream 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