@Test public void testX509CertificateFromPemSuppliedCertFactory() throws IOException, CertificateException { Pems.x509Certificate(ByteSource.wrap(CERTIFICATE.getBytes(Charsets.UTF_8)), CertificateFactory.getInstance("X.509")); }
public static X509Certificate x509Certificate(ByteSource supplier, @Nullable CertificateFactory certFactory) throws IOException, CertificateException { final CertificateFactory certs = certFactory != null ? certFactory : CertificateFactory.getInstance("X.509"); try { return fromPem( supplier, new PemProcessor<X509Certificate>(ImmutableMap.<String, PemProcessor.ResultParser<X509Certificate>> of( CERTIFICATE_X509_MARKER, new PemProcessor.ResultParser<X509Certificate>() { @Override public X509Certificate parseResult(byte[] bytes) throws IOException { try { return (X509Certificate) certs.generateCertificate(new ByteArrayInputStream(bytes)); } catch (CertificateException e) { throw new RuntimeException(e); } } }))); } catch (RuntimeException e) { propagateIfInstanceOf(e.getCause(), CertificateException.class); throw e; } }
Pems { public static X509Certificate x509Certificate(ByteSource supplier, @Nullable CertificateFactory certFactory) throws IOException, CertificateException { final CertificateFactory certs = certFactory != null ? certFactory : CertificateFactory.getInstance("X.509"); try { return fromPem( supplier, new PemProcessor<X509Certificate>(ImmutableMap.<String, PemProcessor.ResultParser<X509Certificate>> of( CERTIFICATE_X509_MARKER, new PemProcessor.ResultParser<X509Certificate>() { @Override public X509Certificate parseResult(byte[] bytes) throws IOException { try { return (X509Certificate) certs.generateCertificate(new ByteArrayInputStream(bytes)); } catch (CertificateException e) { throw new RuntimeException(e); } } }))); } catch (RuntimeException e) { propagateIfInstanceOf(e.getCause(), CertificateException.class); throw e; } } }
Pems { public static X509Certificate x509Certificate(ByteSource supplier, @Nullable CertificateFactory certFactory) throws IOException, CertificateException { final CertificateFactory certs = certFactory != null ? certFactory : CertificateFactory.getInstance("X.509"); try { return fromPem( supplier, new PemProcessor<X509Certificate>(ImmutableMap.<String, PemProcessor.ResultParser<X509Certificate>> of( CERTIFICATE_X509_MARKER, new PemProcessor.ResultParser<X509Certificate>() { @Override public X509Certificate parseResult(byte[] bytes) throws IOException { try { return (X509Certificate) certs.generateCertificate(new ByteArrayInputStream(bytes)); } catch (CertificateException e) { throw new RuntimeException(e); } } }))); } catch (RuntimeException e) { propagateIfInstanceOf(e.getCause(), CertificateException.class); throw e; } }  }
Pems { public static X509Certificate x509Certificate(ByteSource supplier, @Nullable CertificateFactory certFactory) throws IOException, CertificateException { final CertificateFactory certs = certFactory != null ? certFactory : CertificateFactory.getInstance("X.509"); try { return fromPem( supplier, new PemProcessor<X509Certificate>(ImmutableMap.<String, PemProcessor.ResultParser<X509Certificate>> of( CERTIFICATE_X509_MARKER, new PemProcessor.ResultParser<X509Certificate>() { @Override public X509Certificate parseResult(byte[] bytes) throws IOException { try { return (X509Certificate) certs.generateCertificate(new ByteArrayInputStream(bytes)); } catch (CertificateException e) { throw new RuntimeException(e); } } }))); } catch (RuntimeException e) { propagateIfInstanceOf(e.getCause(), CertificateException.class); throw e; } }  static T fromPem(ByteSource supplier, PemProcessor<T> processor); static KeySpec privateKeySpec(ByteSource supplier); static KeySpec privateKeySpec(String pem); static KeySpec publicKeySpec(ByteSource supplier); static KeySpec publicKeySpec(String pem); static X509Certificate x509Certificate(ByteSource supplier,
         @Nullable CertificateFactory certFactory); static X509Certificate x509Certificate(String pem); static String pem(X509Certificate cert); static String pem(PublicKey key); static String pem(PrivateKey key); }
Pems { public static X509Certificate x509Certificate(ByteSource supplier, @Nullable CertificateFactory certFactory) throws IOException, CertificateException { final CertificateFactory certs = certFactory != null ? certFactory : CertificateFactory.getInstance("X.509"); try { return fromPem( supplier, new PemProcessor<X509Certificate>(ImmutableMap.<String, PemProcessor.ResultParser<X509Certificate>> of( CERTIFICATE_X509_MARKER, new PemProcessor.ResultParser<X509Certificate>() { @Override public X509Certificate parseResult(byte[] bytes) throws IOException { try { return (X509Certificate) certs.generateCertificate(new ByteArrayInputStream(bytes)); } catch (CertificateException e) { throw new RuntimeException(e); } } }))); } catch (RuntimeException e) { propagateIfInstanceOf(e.getCause(), CertificateException.class); throw e; } }  static T fromPem(ByteSource supplier, PemProcessor<T> processor); static KeySpec privateKeySpec(ByteSource supplier); static KeySpec privateKeySpec(String pem); static KeySpec publicKeySpec(ByteSource supplier); static KeySpec publicKeySpec(String pem); static X509Certificate x509Certificate(ByteSource supplier,
         @Nullable CertificateFactory certFactory); static X509Certificate x509Certificate(String pem); static String pem(X509Certificate cert); static String pem(PublicKey key); static String pem(PrivateKey key); static final String PRIVATE_PKCS1_MARKER; static final String PRIVATE_PKCS8_MARKER; static final String CERTIFICATE_X509_MARKER; static final String PUBLIC_X509_MARKER; static final String PUBLIC_PKCS1_MARKER; static final String PROC_TYPE_ENCRYPTED; }