@Test void writeCertificateData() throws IOException { CertificateUtils.writeCertificateData(rootProjectDir.getRoot(), "cert", "cert"); File certFile = new File(rootProjectDir.getRoot(), "cert" + PEM_CERT_FILE_EXTENSION); assertTrue(certFile.exists()); assertEquals(PEM_CERT_BEGIN_MARKER + LINE_SEPARATOR + "cert" + LINE_SEPARATOR + PEM_CERT_END_MARKER, FileUtils.readFileToString(certFile, Charset.defaultCharset())); }
public static void writeCertificateData(@NotNull final File certFolder, @NotNull final String certName, @NotNull final String certEncodedData) { String certFileName = buildCertificateFileName(certName); File certFile = new File(certFolder, certFileName); try (OutputStream fileStream = Files.newOutputStream(certFile.toPath())) { fileStream.write(prepareCertificateData(certEncodedData)); } catch (IOException e) { throw new CertificateUtilsException("Exception writing " + certFileName, e); } }
CertificateUtils { public static void writeCertificateData(@NotNull final File certFolder, @NotNull final String certName, @NotNull final String certEncodedData) { String certFileName = buildCertificateFileName(certName); File certFile = new File(certFolder, certFileName); try (OutputStream fileStream = Files.newOutputStream(certFile.toPath())) { fileStream.write(prepareCertificateData(certEncodedData)); } catch (IOException e) { throw new CertificateUtilsException("Exception writing " + certFileName, e); } } }
CertificateUtils { public static void writeCertificateData(@NotNull final File certFolder, @NotNull final String certName, @NotNull final String certEncodedData) { String certFileName = buildCertificateFileName(certName); File certFile = new File(certFolder, certFileName); try (OutputStream fileStream = Files.newOutputStream(certFile.toPath())) { fileStream.write(prepareCertificateData(certEncodedData)); } catch (IOException e) { throw new CertificateUtilsException("Exception writing " + certFileName, e); } } private  CertificateUtils(); }
CertificateUtils { public static void writeCertificateData(@NotNull final File certFolder, @NotNull final String certName, @NotNull final String certEncodedData) { String certFileName = buildCertificateFileName(certName); File certFile = new File(certFolder, certFileName); try (OutputStream fileStream = Files.newOutputStream(certFile.toPath())) { fileStream.write(prepareCertificateData(certEncodedData)); } catch (IOException e) { throw new CertificateUtilsException("Exception writing " + certFileName, e); } } private  CertificateUtils(); static CertificateFactory createX509CertificateFactory(); static Element buildCertDataFromFile(SupplierWithIO<InputStream> certFileLocation, Document document, CertificateFactory certificateFactory); static Element createCertDataElementFromCert(@NotNull X509Certificate cert, Document document); static Element createCertDataElementFromCert(String issuerName, BigInteger serialNumber, String subjectName, String encodedData, Document document); static void writeCertificateData(@NotNull final File certFolder, @NotNull final String certName, @NotNull final String certEncodedData); }
CertificateUtils { public static void writeCertificateData(@NotNull final File certFolder, @NotNull final String certName, @NotNull final String certEncodedData) { String certFileName = buildCertificateFileName(certName); File certFile = new File(certFolder, certFileName); try (OutputStream fileStream = Files.newOutputStream(certFile.toPath())) { fileStream.write(prepareCertificateData(certEncodedData)); } catch (IOException e) { throw new CertificateUtilsException("Exception writing " + certFileName, e); } } private  CertificateUtils(); static CertificateFactory createX509CertificateFactory(); static Element buildCertDataFromFile(SupplierWithIO<InputStream> certFileLocation, Document document, CertificateFactory certificateFactory); static Element createCertDataElementFromCert(@NotNull X509Certificate cert, Document document); static Element createCertDataElementFromCert(String issuerName, BigInteger serialNumber, String subjectName, String encodedData, Document document); static void writeCertificateData(@NotNull final File certFolder, @NotNull final String certName, @NotNull final String certEncodedData); static final String PEM_CERT_FILE_EXTENSION; static final String P12_CERT_FILE_EXTENSION; }