Class KeyRingReader


  • public class KeyRingReader
    extends java.lang.Object
    • Field Summary

      Fields 
      Modifier and Type Field Description
      static int MAX_ITERATIONS  
      static java.nio.charset.Charset UTF8  
    • Constructor Summary

      Constructors 
      Constructor Description
      KeyRingReader()  
    • Method Summary

      All Methods Static Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      org.bouncycastle.openpgp.PGPKeyRing keyRing​(byte[] bytes)
      Read a PGPKeyRing (either PGPSecretKeyRing or PGPPublicKeyRing) from the given byte array.
      org.bouncycastle.openpgp.PGPKeyRing keyRing​(java.io.InputStream inputStream)
      Read a PGPKeyRing (either PGPSecretKeyRing or PGPPublicKeyRing) from the given InputStream.
      org.bouncycastle.openpgp.PGPKeyRing keyRing​(java.lang.String asciiArmored)
      Read a PGPKeyRing (either PGPSecretKeyRing or PGPPublicKeyRing) from the given ASCII armored string.
      PGPKeyRingCollection keyRingCollection​(byte[] bytes, boolean isSilent)  
      PGPKeyRingCollection keyRingCollection​(java.io.InputStream inputStream, boolean isSilent)  
      PGPKeyRingCollection keyRingCollection​(java.lang.String asciiArmored, boolean isSilent)  
      org.bouncycastle.openpgp.PGPPublicKeyRing publicKeyRing​(byte[] bytes)  
      org.bouncycastle.openpgp.PGPPublicKeyRing publicKeyRing​(java.io.InputStream inputStream)  
      org.bouncycastle.openpgp.PGPPublicKeyRing publicKeyRing​(java.lang.String asciiArmored)  
      org.bouncycastle.openpgp.PGPPublicKeyRingCollection publicKeyRingCollection​(byte[] bytes)  
      org.bouncycastle.openpgp.PGPPublicKeyRingCollection publicKeyRingCollection​(java.io.InputStream inputStream)  
      org.bouncycastle.openpgp.PGPPublicKeyRingCollection publicKeyRingCollection​(java.lang.String asciiArmored)  
      static org.bouncycastle.openpgp.PGPKeyRing readKeyRing​(java.io.InputStream inputStream)
      Read a PGPKeyRing (either PGPSecretKeyRing or PGPPublicKeyRing) from the given InputStream.
      static org.bouncycastle.openpgp.PGPKeyRing readKeyRing​(java.io.InputStream inputStream, int maxIterations)
      Read a PGPKeyRing (either PGPSecretKeyRing or PGPPublicKeyRing) from the given InputStream.
      static PGPKeyRingCollection readKeyRingCollection​(java.io.InputStream inputStream, boolean isSilent)  
      static org.bouncycastle.openpgp.PGPPublicKeyRing readPublicKeyRing​(java.io.InputStream inputStream)  
      static org.bouncycastle.openpgp.PGPPublicKeyRing readPublicKeyRing​(java.io.InputStream inputStream, int maxIterations)
      Read a public key ring from the provided InputStream.
      static org.bouncycastle.openpgp.PGPPublicKeyRingCollection readPublicKeyRingCollection​(java.io.InputStream inputStream)  
      static org.bouncycastle.openpgp.PGPPublicKeyRingCollection readPublicKeyRingCollection​(java.io.InputStream inputStream, int maxIterations)
      Read a public key ring collection from the provided InputStream.
      static org.bouncycastle.openpgp.PGPSecretKeyRing readSecretKeyRing​(java.io.InputStream inputStream)  
      static org.bouncycastle.openpgp.PGPSecretKeyRing readSecretKeyRing​(java.io.InputStream inputStream, int maxIterations)
      Read a secret key ring from the provided InputStream.
      static org.bouncycastle.openpgp.PGPSecretKeyRingCollection readSecretKeyRingCollection​(java.io.InputStream inputStream)  
      static org.bouncycastle.openpgp.PGPSecretKeyRingCollection readSecretKeyRingCollection​(java.io.InputStream inputStream, int maxIterations)
      Read a secret key ring collection from the provided InputStream.
      org.bouncycastle.openpgp.PGPSecretKeyRing secretKeyRing​(byte[] bytes)  
      org.bouncycastle.openpgp.PGPSecretKeyRing secretKeyRing​(java.io.InputStream inputStream)  
      org.bouncycastle.openpgp.PGPSecretKeyRing secretKeyRing​(java.lang.String asciiArmored)  
      org.bouncycastle.openpgp.PGPSecretKeyRingCollection secretKeyRingCollection​(byte[] bytes)  
      org.bouncycastle.openpgp.PGPSecretKeyRingCollection secretKeyRingCollection​(java.io.InputStream inputStream)  
      org.bouncycastle.openpgp.PGPSecretKeyRingCollection secretKeyRingCollection​(java.lang.String asciiArmored)  
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Field Detail

      • UTF8

        public static final java.nio.charset.Charset UTF8
    • Constructor Detail

      • KeyRingReader

        public KeyRingReader()
    • Method Detail

      • keyRing

        @Nullable
        public org.bouncycastle.openpgp.PGPKeyRing keyRing​(@Nonnull
                                                           java.io.InputStream inputStream)
                                                    throws java.io.IOException
        Read a PGPKeyRing (either PGPSecretKeyRing or PGPPublicKeyRing) from the given InputStream.
        Parameters:
        inputStream - inputStream containing the OpenPGP key or certificate
        Returns:
        key ring
        Throws:
        java.io.IOException - in case of an IO error
      • keyRing

        @Nullable
        public org.bouncycastle.openpgp.PGPKeyRing keyRing​(@Nonnull
                                                           byte[] bytes)
                                                    throws java.io.IOException
        Read a PGPKeyRing (either PGPSecretKeyRing or PGPPublicKeyRing) from the given byte array.
        Parameters:
        bytes - byte array containing the OpenPGP key or certificate
        Returns:
        key ring
        Throws:
        java.io.IOException - in case of an IO error
      • keyRing

        @Nullable
        public org.bouncycastle.openpgp.PGPKeyRing keyRing​(@Nonnull
                                                           java.lang.String asciiArmored)
                                                    throws java.io.IOException
        Read a PGPKeyRing (either PGPSecretKeyRing or PGPPublicKeyRing) from the given ASCII armored string.
        Parameters:
        asciiArmored - ASCII armored OpenPGP key or certificate
        Returns:
        key ring
        Throws:
        java.io.IOException - in case of an IO error
      • publicKeyRing

        @Nullable
        public org.bouncycastle.openpgp.PGPPublicKeyRing publicKeyRing​(@Nonnull
                                                                       java.io.InputStream inputStream)
                                                                throws java.io.IOException
        Throws:
        java.io.IOException
      • publicKeyRing

        @Nullable
        public org.bouncycastle.openpgp.PGPPublicKeyRing publicKeyRing​(@Nonnull
                                                                       byte[] bytes)
                                                                throws java.io.IOException
        Throws:
        java.io.IOException
      • publicKeyRing

        @Nullable
        public org.bouncycastle.openpgp.PGPPublicKeyRing publicKeyRing​(@Nonnull
                                                                       java.lang.String asciiArmored)
                                                                throws java.io.IOException
        Throws:
        java.io.IOException
      • publicKeyRingCollection

        @Nonnull
        public org.bouncycastle.openpgp.PGPPublicKeyRingCollection publicKeyRingCollection​(@Nonnull
                                                                                           java.io.InputStream inputStream)
                                                                                    throws java.io.IOException
        Throws:
        java.io.IOException
      • publicKeyRingCollection

        @Nonnull
        public org.bouncycastle.openpgp.PGPPublicKeyRingCollection publicKeyRingCollection​(@Nonnull
                                                                                           byte[] bytes)
                                                                                    throws java.io.IOException
        Throws:
        java.io.IOException
      • publicKeyRingCollection

        @Nonnull
        public org.bouncycastle.openpgp.PGPPublicKeyRingCollection publicKeyRingCollection​(@Nonnull
                                                                                           java.lang.String asciiArmored)
                                                                                    throws java.io.IOException
        Throws:
        java.io.IOException
      • secretKeyRing

        @Nullable
        public org.bouncycastle.openpgp.PGPSecretKeyRing secretKeyRing​(@Nonnull
                                                                       java.io.InputStream inputStream)
                                                                throws java.io.IOException
        Throws:
        java.io.IOException
      • secretKeyRing

        @Nullable
        public org.bouncycastle.openpgp.PGPSecretKeyRing secretKeyRing​(@Nonnull
                                                                       byte[] bytes)
                                                                throws java.io.IOException
        Throws:
        java.io.IOException
      • secretKeyRing

        @Nullable
        public org.bouncycastle.openpgp.PGPSecretKeyRing secretKeyRing​(@Nonnull
                                                                       java.lang.String asciiArmored)
                                                                throws java.io.IOException
        Throws:
        java.io.IOException
      • secretKeyRingCollection

        @Nonnull
        public org.bouncycastle.openpgp.PGPSecretKeyRingCollection secretKeyRingCollection​(@Nonnull
                                                                                           java.io.InputStream inputStream)
                                                                                    throws java.io.IOException
        Throws:
        java.io.IOException
      • secretKeyRingCollection

        @Nonnull
        public org.bouncycastle.openpgp.PGPSecretKeyRingCollection secretKeyRingCollection​(@Nonnull
                                                                                           byte[] bytes)
                                                                                    throws java.io.IOException
        Throws:
        java.io.IOException
      • secretKeyRingCollection

        @Nonnull
        public org.bouncycastle.openpgp.PGPSecretKeyRingCollection secretKeyRingCollection​(@Nonnull
                                                                                           java.lang.String asciiArmored)
                                                                                    throws java.io.IOException
        Throws:
        java.io.IOException
      • keyRingCollection

        @Nonnull
        public PGPKeyRingCollection keyRingCollection​(@Nonnull
                                                      java.io.InputStream inputStream,
                                                      boolean isSilent)
                                               throws java.io.IOException,
                                                      org.bouncycastle.openpgp.PGPException
        Throws:
        java.io.IOException
        org.bouncycastle.openpgp.PGPException
      • keyRingCollection

        @Nonnull
        public PGPKeyRingCollection keyRingCollection​(@Nonnull
                                                      byte[] bytes,
                                                      boolean isSilent)
                                               throws java.io.IOException,
                                                      org.bouncycastle.openpgp.PGPException
        Throws:
        java.io.IOException
        org.bouncycastle.openpgp.PGPException
      • keyRingCollection

        @Nonnull
        public PGPKeyRingCollection keyRingCollection​(@Nonnull
                                                      java.lang.String asciiArmored,
                                                      boolean isSilent)
                                               throws java.io.IOException,
                                                      org.bouncycastle.openpgp.PGPException
        Throws:
        java.io.IOException
        org.bouncycastle.openpgp.PGPException
      • readKeyRing

        @Nullable
        public static org.bouncycastle.openpgp.PGPKeyRing readKeyRing​(@Nonnull
                                                                      java.io.InputStream inputStream)
                                                               throws java.io.IOException
        Read a PGPKeyRing (either PGPSecretKeyRing or PGPPublicKeyRing) from the given InputStream. This method will attempt to read at most MAX_ITERATIONS objects from the stream before aborting. The first PGPPublicKeyRing or PGPSecretKeyRing will be returned.
        Parameters:
        inputStream - inputStream containing the OpenPGP key or certificate
        Returns:
        key ring
        Throws:
        java.io.IOException - in case of an IO error
      • readKeyRing

        @Nullable
        public static org.bouncycastle.openpgp.PGPKeyRing readKeyRing​(@Nonnull
                                                                      java.io.InputStream inputStream,
                                                                      int maxIterations)
                                                               throws java.io.IOException
        Read a PGPKeyRing (either PGPSecretKeyRing or PGPPublicKeyRing) from the given InputStream. This method will attempt to read at most
        maxIterations
        objects from the stream before aborting. The first PGPPublicKeyRing or PGPSecretKeyRing will be returned.
        Parameters:
        inputStream - inputStream containing the OpenPGP key or certificate
        maxIterations - maximum number of objects that are read before the method will abort
        Returns:
        key ring
        Throws:
        java.io.IOException - in case of an IO error
      • readPublicKeyRing

        @Nullable
        public static org.bouncycastle.openpgp.PGPPublicKeyRing readPublicKeyRing​(@Nonnull
                                                                                  java.io.InputStream inputStream)
                                                                           throws java.io.IOException
        Throws:
        java.io.IOException
      • readPublicKeyRing

        @Nullable
        public static org.bouncycastle.openpgp.PGPPublicKeyRing readPublicKeyRing​(@Nonnull
                                                                                  java.io.InputStream inputStream,
                                                                                  int maxIterations)
                                                                           throws java.io.IOException
        Read a public key ring from the provided InputStream. If more than maxIterations PGP packets are encountered before a PGPPublicKeyRing is read, an IOException is thrown.
        Parameters:
        inputStream - input stream
        maxIterations - max iterations before abort
        Returns:
        public key ring
        Throws:
        java.io.IOException - in case of an IO error or exceeding of max iterations
      • readPublicKeyRingCollection

        @Nonnull
        public static org.bouncycastle.openpgp.PGPPublicKeyRingCollection readPublicKeyRingCollection​(@Nonnull
                                                                                                      java.io.InputStream inputStream)
                                                                                               throws java.io.IOException
        Throws:
        java.io.IOException
      • readPublicKeyRingCollection

        @Nonnull
        public static org.bouncycastle.openpgp.PGPPublicKeyRingCollection readPublicKeyRingCollection​(@Nonnull
                                                                                                      java.io.InputStream inputStream,
                                                                                                      int maxIterations)
                                                                                               throws java.io.IOException
        Read a public key ring collection from the provided InputStream. If more than maxIterations PGP packets are encountered before the stream is exhausted, an IOException is thrown.
        Parameters:
        inputStream - input stream
        maxIterations - max iterations before abort
        Returns:
        public key ring collection
        Throws:
        java.io.IOException - in case of an IO error or exceeding of max iterations
      • readSecretKeyRing

        @Nullable
        public static org.bouncycastle.openpgp.PGPSecretKeyRing readSecretKeyRing​(@Nonnull
                                                                                  java.io.InputStream inputStream)
                                                                           throws java.io.IOException
        Throws:
        java.io.IOException
      • readSecretKeyRing

        @Nullable
        public static org.bouncycastle.openpgp.PGPSecretKeyRing readSecretKeyRing​(@Nonnull
                                                                                  java.io.InputStream inputStream,
                                                                                  int maxIterations)
                                                                           throws java.io.IOException
        Read a secret key ring from the provided InputStream. If more than maxIterations PGP packets are encountered before a PGPSecretKeyRing is read, an IOException is thrown.
        Parameters:
        inputStream - input stream
        maxIterations - max iterations before abort
        Returns:
        public key ring
        Throws:
        java.io.IOException - in case of an IO error or exceeding of max iterations
      • readSecretKeyRingCollection

        @Nonnull
        public static org.bouncycastle.openpgp.PGPSecretKeyRingCollection readSecretKeyRingCollection​(@Nonnull
                                                                                                      java.io.InputStream inputStream)
                                                                                               throws java.io.IOException
        Throws:
        java.io.IOException
      • readSecretKeyRingCollection

        @Nonnull
        public static org.bouncycastle.openpgp.PGPSecretKeyRingCollection readSecretKeyRingCollection​(@Nonnull
                                                                                                      java.io.InputStream inputStream,
                                                                                                      int maxIterations)
                                                                                               throws java.io.IOException
        Read a secret key ring collection from the provided InputStream. If more than maxIterations PGP packets are encountered before the stream is exhausted, an IOException is thrown.
        Parameters:
        inputStream - input stream
        maxIterations - max iterations before abort
        Returns:
        secret key ring collection
        Throws:
        java.io.IOException - in case of an IO error or exceeding of max iterations
      • readKeyRingCollection

        @Nonnull
        public static PGPKeyRingCollection readKeyRingCollection​(@Nonnull
                                                                 java.io.InputStream inputStream,
                                                                 boolean isSilent)
                                                          throws java.io.IOException,
                                                                 org.bouncycastle.openpgp.PGPException
        Throws:
        java.io.IOException
        org.bouncycastle.openpgp.PGPException