List of usage examples for org.bouncycastle.jce.provider BouncyCastleProvider BouncyCastleProvider
public BouncyCastleProvider()
From source file:eu.europa.ec.markt.dss.signature.cades.CAdESProfileBES.java
License:Open Source License
private Attribute makeSigningCertificateAttribute(SignatureParameters parameters) { try {// ww w . ja v a 2 s .co m MessageDigest dig = MessageDigest.getInstance(parameters.getDigestAlgorithm().getName(), new BouncyCastleProvider()); byte[] certHash = dig.digest(parameters.getSigningCertificate().getEncoded()); if (parameters.getDigestAlgorithm() == DigestAlgorithm.SHA1) { SigningCertificate sc = new SigningCertificate(new ESSCertID(certHash)); return new Attribute(PKCSObjectIdentifiers.id_aa_signingCertificate, new DERSet(sc)); } else { ESSCertIDv2 essCert = new ESSCertIDv2( new AlgorithmIdentifier(parameters.getDigestAlgorithm().getOid()), certHash); SigningCertificateV2 scv2 = new SigningCertificateV2(new ESSCertIDv2[] { essCert }); return new Attribute(PKCSObjectIdentifiers.id_aa_signingCertificateV2, new DERSet(scv2)); } } catch (NoSuchAlgorithmException e) { throw new RuntimeException(e); } catch (CertificateException e) { throw new RuntimeException(e); } }
From source file:eu.europa.ec.markt.dss.signature.cades.CAdESProfileC.java
License:Open Source License
/** * Create a reference to a X509Certificate * //from www. ja va 2 s.c o m * @param cert * @return * @throws NoSuchAlgorithmException * @throws CertificateEncodingException */ private OtherCertID makeOtherCertID(X509Certificate cert) throws NoSuchAlgorithmException, CertificateEncodingException { MessageDigest sha1digest = MessageDigest.getInstance(X509ObjectIdentifiers.id_SHA1.getId(), new BouncyCastleProvider()); byte[] d = sha1digest.digest(cert.getEncoded()); LOG.info(new DEROctetString(d).getDERObject().toString()); OtherHash hash = new OtherHash(sha1digest.digest(cert.getEncoded())); OtherCertID othercertid = new OtherCertID(new DERSequence(hash.getDERObject())); return othercertid; }
From source file:eu.europa.ec.markt.dss.signature.cades.CAdESProfileC.java
License:Open Source License
/** * Create a reference to a X509CRL/*from www . ja v a2 s . c om*/ * * @param crl * @return * @throws NoSuchAlgorithmException * @throws CRLException */ private CrlValidatedID makeCrlValidatedID(X509CRL crl) throws NoSuchAlgorithmException, CRLException { MessageDigest sha1digest = MessageDigest.getInstance(X509ObjectIdentifiers.id_SHA1.getId(), new BouncyCastleProvider()); OtherHash hash = new OtherHash(sha1digest.digest(crl.getEncoded())); BigInteger crlnumber; CrlIdentifier crlid; if (crl.getExtensionValue("2.5.29.20") != null) { crlnumber = new DERInteger(crl.getExtensionValue("2.5.29.20")).getPositiveValue(); crlid = new CrlIdentifier(new X500Name(crl.getIssuerX500Principal().getName()), new DERUTCTime(crl.getThisUpdate()), crlnumber); } else { crlid = new CrlIdentifier(new X500Name(crl.getIssuerX500Principal().getName()), new DERUTCTime(crl.getThisUpdate())); } CrlValidatedID crlvid = new CrlValidatedID(hash, crlid); return crlvid; }
From source file:eu.europa.ec.markt.dss.signature.cades.CAdESProfileC.java
License:Open Source License
/** * Create a reference on a OCSPResp/*from www. ja va 2 s . c o m*/ * * @param ocspResp * @return * @throws NoSuchAlgorithmException * @throws OCSPException * @throws IOException */ private OcspResponsesID makeOcspResponsesID(BasicOCSPResp ocspResp) throws NoSuchAlgorithmException, OCSPException, IOException { /* * We hash the complete response, this is not clear in the TS but the issue was addressed here: * http://lists.iaik.tugraz.at/pipermail/jce-general/2007-January/005914.html */ MessageDigest sha1digest = MessageDigest.getInstance(X509ObjectIdentifiers.id_SHA1.getId(), new BouncyCastleProvider()); byte[] digestValue = sha1digest.digest(ocspResp.getEncoded()); OtherHash hash = new OtherHash(digestValue); OcspResponsesID ocsprespid = new OcspResponsesID(new OcspIdentifier( ocspResp.getResponderId().toASN1Object(), new DERGeneralizedTime(ocspResp.getProducedAt())), hash); LOG.info("Incorporate OcspResponseId[hash=" + Hex.encodeHexString(digestValue) + ",producedAt=" + ocspResp.getProducedAt()); return ocsprespid; }
From source file:eu.europa.ec.markt.dss.validation.ocsp.OCSPCertificateVerifier.java
License:Open Source License
/** * Create a CertificateVerifier that will use the OCSP Source for checking revocation data. The default constructor * for OCSPCertificateVerifier.//from w w w. ja v a 2 s .c o m * * @param ocspSource */ public OCSPCertificateVerifier(OCSPSource ocspSource) { Security.addProvider(new BouncyCastleProvider()); this.ocspSource = ocspSource; }
From source file:eu.europa.ec.markt.dss.validation.ocsp.OnlineOCSPSource.java
License:Open Source License
/** * Create an OCSP source The default constructor for OnlineOCSPSource. */ public OnlineOCSPSource() { Security.addProvider(new BouncyCastleProvider()); }
From source file:eu.europa.ec.markt.dss.validation.tsl.TrustedListsCertificateSource.java
License:Open Source License
/** * The default constructor for TrustedListsCertificateSource. */ public TrustedListsCertificateSource() { Security.addProvider(new BouncyCastleProvider()); }
From source file:eu.europa.ec.markt.tlmanager.TLManager.java
License:Open Source License
/** * The main method./* www. j a va2 s .c o m*/ * * @param args the command line arguments */ public static void main(String args[]) { Security.addProvider(new BouncyCastleProvider()); initSwingPreferences(); MainFrame mf = new MainFrame(); mf.setVisible(true); }
From source file:eu.europa.ec.markt.tlmanager.view.certificate.CertificatePanel.java
License:Open Source License
private void loadCertificate(File file) { FileInputStream inputStream = null; Security.addProvider(new BouncyCastleProvider()); try {//from w w w.jav a 2 s . c om inputStream = new FileInputStream(file); X509Certificate cert = CertificateUtils.read(inputStream); certificateModel.setCertificate(cert); certificateModel.updateDigitalIdentity(); refresh(); } catch (Exception ex) { String message = uiKeys.getString("CertificatePanel.error.message"); JOptionPane.showMessageDialog(this, message, uiKeys.getString("CertificatePanel.error.title"), JOptionPane.INFORMATION_MESSAGE); LOG.log(Level.WARNING, message + " " + ex.getMessage(), ex); } }