Java Code Examples for org.bouncycastle.jce.provider.X509CertParser#engineInit()

The following examples show how to use org.bouncycastle.jce.provider.X509CertParser#engineInit() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: PdfPKCS7.java    From itext2 with GNU Lesser General Public License v3.0 6 votes vote down vote up
/**
 * Verifies a signature using the sub-filter adbe.x509.rsa_sha1.
 * @param contentsKey the /Contents key
 * @param certsKey the /Cert key
 * @param provider the provider or <code>null</code> for the default provider
 */    
public PdfPKCS7(byte[] contentsKey, byte[] certsKey, String provider) {
    try {
        this.provider = provider;
        X509CertParser cr = new X509CertParser();
        cr.engineInit(new ByteArrayInputStream(certsKey));
        certs = cr.engineReadAll();
        signCerts = certs;
        signCert = (X509Certificate)certs.iterator().next();
        crls = new ArrayList();
        ASN1InputStream in = new ASN1InputStream(new ByteArrayInputStream(contentsKey));
        digest = ((DEROctetString)in.readObject()).getOctets();
        if (provider == null)
            sig = Signature.getInstance("SHA1withRSA");
        else
            sig = Signature.getInstance("SHA1withRSA", provider);
        sig.initVerify(signCert.getPublicKey());
    }
    catch (Exception e) {
        throw new ExceptionConverter(e);
    }
}
 
Example 2
Source File: Acme.java    From acme-client with Apache License 2.0 5 votes vote down vote up
private X509Certificate extractCertificate(final String[] domains, InputStream inputStream)
		throws StreamParsingException {
	X509CertParser certParser = new X509CertParser();
	certParser.engineInit(inputStream);
	X509Certificate certificate = (X509Certificate) certParser.engineRead();
	certificateStorage.saveCertificate(domains, certificate);
	return certificate;
}
 
Example 3
Source File: Denominator.java    From denominator with Apache License 2.0 5 votes vote down vote up
@Override
public Object apply(Object input) {
  if (input instanceof String && input.toString().contains("BEGIN CERTIFICATE")) {
    try {
      X509CertParser x509CertParser = new X509CertParser();
      x509CertParser.engineInit(new ByteArrayInputStream(input.toString().getBytes()));
      return x509CertParser.engineRead();
    } catch (Exception ex) {
      return input;
    }
  }
  return input;
}