List of usage examples for org.bouncycastle.asn1.x509 AlgorithmIdentifier toASN1Primitive
public ASN1Primitive toASN1Primitive()
From source file:eu.emi.security.authn.x509.helpers.proxy.X509v3CertificateBuilder.java
License:Open Source License
private X509Certificate sign(TBSCertificate toSign, AlgorithmIdentifier sigAlg, String sigAlgName, PrivateKey key, String provider, SecureRandom random) throws InvalidKeyException, NoSuchProviderException, NoSuchAlgorithmException, SignatureException, IOException, CertificateParsingException { byte[] signature = calculateSignature(sigAlgName, provider, key, random, toSign); ASN1EncodableVector v = new ASN1EncodableVector(); v.add(toSign);/*ww w . j av a2 s.c o m*/ v.add(sigAlg.toASN1Primitive()); v.add(new DERBitString(signature)); DERSequence derCertificate = new DERSequence(v); CertificateFactory factory; try { factory = CertificateFactory.getInstance("X.509"); ByteArrayInputStream bais = new ByteArrayInputStream(derCertificate.getEncoded(ASN1Encoding.DER)); return (X509Certificate) factory.generateCertificate(bais); } catch (CertificateException e) { throw new RuntimeException("The generated proxy " + "certificate was not parsed by the JDK", e); } }
From source file:org.jruby.ext.openssl.impl.Signed.java
License:LGPL
private ASN1Set digestAlgorithmsToASN1Set() { ASN1EncodableVector vector = new ASN1EncodableVector(); for (AlgorithmIdentifier ai : mdAlgs) { vector.add(ai.toASN1Primitive()); }//w w w .jav a 2 s. c om return new DERSet(vector); }