List of usage examples for java.security.cert CertificateFactory generateCertificate
public final Certificate generateCertificate(InputStream inStream) throws CertificateException
From source file:Main.java
private static X509Certificate generateX509CertificateFromSignature(final Signature signature) throws CertificateException { CertificateFactory certificateFactory = CertificateFactory.getInstance("X.509"); ByteArrayInputStream inputStream = new ByteArrayInputStream(signature.toByteArray()); X509Certificate certificate = (X509Certificate) certificateFactory.generateCertificate(inputStream); return certificate; }
From source file:facturatron.facturacion.PAC.finkok.ClassicKeyLoader.java
/** * @param crtInputStream Flujo de entrada del archivo que representa la llave pblica codificada * en x509/*from w w w .j a va2s . c o m*/ * * @return Informacin de la llave pblica encapsulada en el objeto {@link X509Certificate} * * @throws KeyException Lanzada si la codificacin del certificado no es correcta. */ public static X509Certificate loadX509Certificate(InputStream crtInputStream) throws KeyException { CertificateFactory factory = null; X509Certificate x509Crt = null; try { factory = CertificateFactory.getInstance("X.509"); x509Crt = (X509Certificate) factory.generateCertificate(crtInputStream); } catch (CertificateException e) { throw new KeyException("Error al obtener el certificado x.509. La codificacin puede ser incorrecta.", e.getCause()); } return x509Crt; }
From source file:org.sinekartads.utils.X509Utils.java
public static X509Certificate rawX509CertificateFromEncoded(byte[] encoded) throws CertificateException { // Return the X509Certificate encoded by the given byte array X509Certificate x509Certificate; if (ArrayUtils.isNotEmpty(encoded)) { CertificateFactory cf = CertificateFactory.getInstance("X.509"); InputStream is = new ByteArrayInputStream(encoded); x509Certificate = (X509Certificate) cf.generateCertificate(is); } else {/*w w w .j av a2s. co m*/ x509Certificate = null; } return x509Certificate; }
From source file:org.zaproxy.zap.extension.dynssl.SslCertificateUtils.java
private static X509Certificate generateCertificateFromDER(byte[] certBytes) throws CertificateException { CertificateFactory factory = CertificateFactory.getInstance("X.509"); return (X509Certificate) factory.generateCertificate(new ByteArrayInputStream(certBytes)); }
From source file:bobs.mcapisignature.CertUtils.java
public static X509Certificate getX509CertificateFromB64(String certBase64) throws CertificateException { CertificateFactory cf = CertificateFactory.getInstance("X.509"); X509Certificate cert = (X509Certificate) cf .generateCertificate(new ByteArrayInputStream(Base64.decodeBase64(certBase64))); return cert;//ww w. j a va2s. c om }
From source file:bobs.mcapisignature.CertUtils.java
public static X509Certificate getX509Certificate(CERT_CONTEXT pcert) throws CertificateException { CertificateFactory cf = CertificateFactory.getInstance("X.509"); X509Certificate cert = (X509Certificate) cf .generateCertificate(new ByteArrayInputStream(certToBytes(pcert))); return cert;/*from ww w . ja v a2 s.c o m*/ }
From source file:io.fabric8.utils.cxf.WebClients.java
public static KeyStore createTrustStore(String caCertData, File caCertFile) throws Exception { try (InputStream pemInputStream = getInputStreamFromDataOrFile(caCertData, caCertFile)) { CertificateFactory certFactory = CertificateFactory.getInstance("X509"); X509Certificate cert = (X509Certificate) certFactory.generateCertificate(pemInputStream); KeyStore trustStore = KeyStore.getInstance("JKS"); trustStore.load(null);//from ww w. j a v a 2 s .c o m String alias = cert.getSubjectX500Principal().getName(); trustStore.setCertificateEntry(alias, cert); return trustStore; } }
From source file:org.waveprotocol.box.server.waveserver.testing.Certificates.java
/** * Returns {@link SignerInfo} for the (realcert, startcom) certificate chain. * @throws Exception if the certificates fail to be resolved properly *//*from w ww . ja va 2s . co m*/ public static SignerInfo getRealSignerInfo() throws Exception { CertificateFactory factory = CertificateFactory.getInstance("X.509"); X509Certificate realCert = (X509Certificate) factory .generateCertificate(new ByteArrayInputStream(REAL_CERTIFICATE.getBytes())); X509Certificate startCom = (X509Certificate) factory .generateCertificate(new ByteArrayInputStream(STARTCOM_CERT.getBytes())); return new SignerInfo(HashAlgorithm.SHA256, ImmutableList.of(realCert, startCom), REAL_DOMAIN); }
From source file:org.waveprotocol.box.server.waveserver.testing.Certificates.java
/** * Returns {@link SignerInfo} for the (example.com) certificate chain. * @throws Exception if the certificates fail to be resolved properly */// w w w . j a v a2 s. c o m public static SignerInfo getExampleSignerInfo() throws Exception { CertificateFactory factory = CertificateFactory.getInstance("X.509"); X509Certificate exampleCert = (X509Certificate) factory .generateCertificate(new ByteArrayInputStream(EXAMPLE_CERTIFICATE.getBytes())); return new SignerInfo(HashAlgorithm.SHA256, ImmutableList.of(exampleCert), EXAMPLE_DOMAIN); }
From source file:com.vmware.identity.rest.core.util.CertificateHelper.java
/** * Converts a PEM formatted string to a {@code X509Certificate} instance. * * @param pem PEM formatted string// ww w .ja v a2 s . co m * @return {@link X509Certificate} * @throws CertificateException If conversion fails */ public static X509Certificate convertToX509(String pem) throws CertificateException { if (pem == null) { return null; } CertificateFactory certFactory = CertificateFactory.getInstance(X509_CERT_TYPE); InputStream inputStream = new ByteArrayInputStream(pem.getBytes()); return (X509Certificate) certFactory.generateCertificate(inputStream); }