Package org.bouncycastle.openssl

Examples of org.bouncycastle.openssl.PEMWriter


                StringWriter stringWriter = new StringWriter();

                /*
                 * Write in PEM format (openssl support)
                 */
                PEMWriter pemFormatWriter = new PEMWriter(stringWriter);
                pemFormatWriter.writeObject(keypair.getPrivate());
                pemFormatWriter.close();
                fos.write(stringWriter.toString().getBytes());
            } catch (IOException ioe) {
                throw ioe;
            } finally {
                if (fos != null) {
View Full Code Here


            try {
                fos = new FileOutputStream(privateKeyFilePath);
                StringWriter stringWriter = new StringWriter();

                /* Write in PEM format (openssl support) */
                PEMWriter pemFormatWriter = new PEMWriter(stringWriter);
                pemFormatWriter.writeObject(keypair.getPrivate());
                pemFormatWriter.close();
                fos.write(stringWriter.toString().getBytes());
            } catch (IOException ioe) {
                throw ioe;
            } finally {
                if (fos != null) {
View Full Code Here

  @Override
  public byte[] getContent() {
    if (ser == null) {
      try {
        StringWriter sw = new StringWriter();
        PEMWriter pemWriter = new PEMWriter(sw);
        pemWriter.writeObject(cer.getCertificate());
        pemWriter.close();
        ser = sw.toString().getBytes("UTF-8");
      } catch (IOException e) {
        log.log(Level.SEVERE, "could not write PEM Serialisation");
      }
    }
View Full Code Here

                    PKCSObjectIdentifiers.signedData, sd));
        }
        else if (encoding.equalsIgnoreCase("PEM"))
        {
            ByteArrayOutputStream bOut = new ByteArrayOutputStream();
            PEMWriter             pWrt = new PEMWriter(new OutputStreamWriter(bOut));

            try
            {
                for (int i = 0; i != certificates.size(); i++)
                {
                    pWrt.writeObject(certificates.get(i));
                }
           
                pWrt.close();
            }
            catch (Exception e)
            {
                throw new CertificateEncodingException("can't encode certificate for PEM encoded path");
            }
View Full Code Here

                StringWriter stringWriter = new StringWriter();

                /*
                 * Write in PEM format (openssl support)
                 */
                PEMWriter pemFormatWriter = new PEMWriter(stringWriter);
                pemFormatWriter.writeObject(keypair.getPrivate());
                pemFormatWriter.close();
                fos.write(stringWriter.toString().getBytes());
            } catch (IOException ioe) {
                throw ioe;
            } finally {
                if (fos != null) {
View Full Code Here

                    PKCSObjectIdentifiers.signedData, sd));
        }
        else if (encoding.equalsIgnoreCase("PEM"))
        {
            ByteArrayOutputStream bOut = new ByteArrayOutputStream();
            PEMWriter             pWrt = new PEMWriter(new OutputStreamWriter(bOut));

            try
            {
                for (int i = 0; i != certificates.size(); i++)
                {
                    pWrt.writeObject(certificates.get(i));
                }
           
                pWrt.close();
            }
            catch (Exception e)
            {
                throw new CertificateEncodingException("can't encode certificate for PEM encoded path");
            }
View Full Code Here

        }
    }

    public static String toPem(KeyPair keyPair) throws IOException {
        StringWriter writer = new StringWriter();
        PEMWriter pemWriter = new PEMWriter(writer, BouncyCastleLoader.getName());
        try {
            pemWriter.writeObject(keyPair);
            pemWriter.flush();
            return writer.toString();
        } finally {
            IoUtils.safeClose(pemWriter);
        }
    }
View Full Code Here

    // }
    // }

    public static String serializePem(Object data) throws IOException {
        StringWriter writer = new StringWriter();
        try (PEMWriter pemWriter = new PEMWriter(writer)) {
            pemWriter.writeObject(data);
            pemWriter.flush();
            return writer.toString();
        }
    }
View Full Code Here

        PEMReader r = new PEMReader(new InputStreamReader(is));
        return (KeyPair) r.readObject();
    }

    protected void doWriteKeyPair(KeyPair kp, OutputStream os) throws Exception {
        PEMWriter w = new PEMWriter(new OutputStreamWriter(os));
        w.writeObject(kp);
        w.flush();
    }
View Full Code Here

            try {
                fos = new FileOutputStream(privateKeyFilePath);
                StringWriter stringWriter = new StringWriter();

                /* Write in PEM format (openssl support) */
                PEMWriter pemFormatWriter = new PEMWriter(stringWriter);
                pemFormatWriter.writeObject(keypair.getPrivate());
                pemFormatWriter.close();
                fos.write(stringWriter.toString().getBytes());
            } catch (IOException ioe) {
                throw ioe;
            } finally {
                if (fos != null) {
View Full Code Here

TOP

Related Classes of org.bouncycastle.openssl.PEMWriter

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.