Class PKCS8DERReader

  • All Implemented Interfaces:
    java.io.Closeable, java.lang.AutoCloseable, java.lang.Readable

    public class PKCS8DERReader
    extends org.bouncycastle.openssl.PEMParser
    This class extends the PEMParser class from the BC library. It is modified to read DER input, not the PEM (it can be considered a smart-hack) as otherwise BC's parsers code would need to be copied. It supports reading of the PKCS8 private key in DER form. It is assumed that the key is encrypted if a password is provided.

    This class interface is the readObject method.

    This implementation overrides the PemReader readPemObject method to actually read the DER. The Reader used by the PemReader is not used.

    Author:
    K. Benedyczak
    • Field Summary

      Fields 
      Modifier and Type Field Description
      protected boolean encrypted  
      protected java.io.InputStream is  
      • Fields inherited from class org.bouncycastle.openssl.PEMParser

        parsers, TYPE_ATTRIBUTE_CERTIFICATE, TYPE_CERTIFICATE, TYPE_CERTIFICATE_REQUEST, TYPE_CMS, TYPE_DSA_PRIVATE_KEY, TYPE_EC_PARAMETERS, TYPE_EC_PRIVATE_KEY, TYPE_ENCRYPTED_PRIVATE_KEY, TYPE_NEW_CERTIFICATE_REQUEST, TYPE_PKCS7, TYPE_PRIVATE_KEY, TYPE_PUBLIC_KEY, TYPE_RSA_PRIVATE_KEY, TYPE_RSA_PUBLIC_KEY, TYPE_TRUSTED_CERTIFICATE, TYPE_X509_CERTIFICATE, TYPE_X509_CRL
      • Fields inherited from class java.io.Reader

        lock
    • Constructor Summary

      Constructors 
      Constructor Description
      PKCS8DERReader​(java.io.InputStream is, boolean encrypted)  
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      org.bouncycastle.util.io.pem.PemObject readPemObject()
      Generate BC's PemObject from the input stream.
      • Methods inherited from class org.bouncycastle.openssl.PEMParser

        getSupportedTypes, readObject
      • Methods inherited from class java.io.BufferedReader

        close, lines, mark, markSupported, read, read, readLine, ready, reset, skip
      • Methods inherited from class java.io.Reader

        nullReader, read, read, transferTo
      • Methods inherited from class java.lang.Object

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

      • is

        protected java.io.InputStream is
      • encrypted

        protected boolean encrypted
    • Constructor Detail

      • PKCS8DERReader

        public PKCS8DERReader​(java.io.InputStream is,
                              boolean encrypted)
    • Method Detail

      • readPemObject

        public org.bouncycastle.util.io.pem.PemObject readPemObject()
                                                             throws java.io.IOException
        Generate BC's PemObject from the input stream. The object's type is fixed to encrypted or plain private key.
        Overrides:
        readPemObject in class org.bouncycastle.util.io.pem.PemReader
        Returns:
        the parsed PEM object
        Throws:
        java.io.IOException - IO exception