当前位置: 首页>>代码示例>>Java>>正文


Java OCSPReqBuilder类代码示例

本文整理汇总了Java中org.bouncycastle.cert.ocsp.OCSPReqBuilder的典型用法代码示例。如果您正苦于以下问题:Java OCSPReqBuilder类的具体用法?Java OCSPReqBuilder怎么用?Java OCSPReqBuilder使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


OCSPReqBuilder类属于org.bouncycastle.cert.ocsp包,在下文中一共展示了OCSPReqBuilder类的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: generateOCSPRequest

import org.bouncycastle.cert.ocsp.OCSPReqBuilder; //导入依赖的package包/类
/**
 * Generates an OCSP request using BouncyCastle.
 * @param issuerCert	certificate of the issues
 * @param serialNumber	serial number
 * @return	an OCSP request
 * @throws OCSPException
 * @throws IOException
 */
private static OCSPReq generateOCSPRequest(X509Certificate issuerCert, BigInteger serialNumber) throws OCSPException, IOException, OperatorException, CertificateEncodingException {
    //Add provider BC
    Security.addProvider(new org.bouncycastle.jce.provider.BouncyCastleProvider());
    
    JcaDigestCalculatorProviderBuilder digestCalculatorProviderBuilder = new JcaDigestCalculatorProviderBuilder();
    DigestCalculatorProvider digestCalculatorProvider = digestCalculatorProviderBuilder.build();
    DigestCalculator digestCalculator = digestCalculatorProvider.get(CertificateID.HASH_SHA1);
    // Generate the id for the certificate we are looking for
    CertificateID id = new CertificateID(digestCalculator, new JcaX509CertificateHolder(issuerCert), serialNumber);
    
    // basic request generation with nonce
    OCSPReqBuilder gen = new OCSPReqBuilder();
    
    gen.addRequest(id);
    
    // create details for nonce extension
    Extension ext = new Extension(OCSPObjectIdentifiers.id_pkix_ocsp_nonce, false, new DEROctetString(new DEROctetString(PdfEncryption.createDocumentId()).getEncoded()));
    gen.setRequestExtensions(new Extensions(new Extension[]{ext}));
    
    return gen.build();
}
 
开发者ID:albfernandez,项目名称:itext2,代码行数:30,代码来源:OcspClientBouncyCastle.java

示例2: generateOcspRequest

import org.bouncycastle.cert.ocsp.OCSPReqBuilder; //导入依赖的package包/类
private OCSPReq generateOcspRequest(X509Certificate issuerCert,
		BigInteger serialNumber) throws OCSPException, CertificateEncodingException, OperatorCreationException, IOException {

	BcDigestCalculatorProvider util = new BcDigestCalculatorProvider();
	
	// Generate the id for the certificate we are looking for
	CertificateID id = new CertificateID(util.get(  CertificateID.HASH_SHA1),
			new X509CertificateHolder(issuerCert.getEncoded()), serialNumber);
	OCSPReqBuilder ocspGen = new OCSPReqBuilder();
       
       ocspGen.addRequest(id);

	BigInteger nonce = BigInteger.valueOf(System.currentTimeMillis());
	Extension ext = new Extension(OCSPObjectIdentifiers.id_pkix_ocsp_nonce, true, new DEROctetString(nonce.toByteArray()));
       ocspGen.setRequestExtensions(new Extensions(new Extension[] { ext }));

       return ocspGen.build();
}
 
开发者ID:TremoloSecurity,项目名称:OpenUnison,代码行数:19,代码来源:OCSP.java

示例3: getOCSPReqBuilder

import org.bouncycastle.cert.ocsp.OCSPReqBuilder; //导入依赖的package包/类
private OCSPReqBuilder getOCSPReqBuilder(BigInteger serialNumber) throws Exception {
    // Generate the id for the certificate we are looking for
    CertificateID id = new CertificateID(
            new JcaDigestCalculatorProviderBuilder().setProvider("BC").build().get(CertificateID.HASH_SHA1),
            new X509CertificateHolder(issuingCertificate.getEncoded()),
            serialNumber
    );

    OCSPReqBuilder requestBuilder = new OCSPReqBuilder();

    requestBuilder.addRequest(id, new Extensions(new Extension[] { buildNonceExtension() }));

    // create nonce extension
    requestBuilder.setRequestExtensions(new Extensions(new Extension[] { buildNonceExtension() }));

    return requestBuilder;
}
 
开发者ID:wdawson,项目名称:revoker,代码行数:18,代码来源:OCSPResponderResourceTest.java

示例4: generateOCSPRequest

import org.bouncycastle.cert.ocsp.OCSPReqBuilder; //导入依赖的package包/类
private OCSPReq generateOCSPRequest(CertificateID certificateId) throws OCSPException, OperatorCreationException, CertificateEncodingException {
	OCSPReqBuilder ocspReqGenerator = new OCSPReqBuilder();

	ocspReqGenerator.addRequest(certificateId);

	OCSPReq ocspReq = ocspReqGenerator.build();
	return ocspReq;
}
 
开发者ID:GluuFederation,项目名称:oxAuth,代码行数:9,代码来源:OCSPCertificateVerifier.java

示例5: GenOcspReq

import org.bouncycastle.cert.ocsp.OCSPReqBuilder; //导入依赖的package包/类
public static OCSPReq GenOcspReq(X509Certificate nextCert,
			X509Certificate nextIssuer) throws OCSPException, OperatorCreationException, CertificateEncodingException, IOException {

		OCSPReqBuilder ocspRequestGenerator = new OCSPReqBuilder();
		DigestCalculatorProvider digCalcProv = new JcaDigestCalculatorProviderBuilder().setProvider("BC").build();

//		CertificateID certId = new CertificateID(
//				CertificateID.HASH_SHA1,
//				nextIssuer, nextCert.getSerialNumber()
//				);
		CertificateID certId = new CertificateID(digCalcProv.get(CertificateID.HASH_SHA1), 
				new X509CertificateHolder (nextIssuer.getEncoded()), nextCert.getSerialNumber());
//		CertificateID id = new CertificateID(digCalcProv.get(CertificateID.HASH_SHA1), testCert, BigInteger.valueOf(1));
		
		ocspRequestGenerator.addRequest(certId);

		BigInteger nonce = BigInteger.valueOf(System.currentTimeMillis());
		
		Extension ext = new Extension(OCSPObjectIdentifiers.id_pkix_ocsp_nonce, false, new DEROctetString(nonce.toByteArray()));
		ocspRequestGenerator.setRequestExtensions(new Extensions(new Extension[]{ext}));
		
		return ocspRequestGenerator.build();
		
//		Vector<DERObjectIdentifier> oids = new Vector<DERObjectIdentifier>();
//		Vector<X509Extension> values = new Vector<X509Extension>();
//
//		oids.add(OCSPObjectIdentifiers.id_pkix_ocsp_nonce);
//		values.add(new X509Extension(false, new DEROctetString(nonce
//				.toByteArray())));
//
//		ocspRequestGenerator.setRequestExtensions(new X509Extensions(oids,
//				values));
//		return ocspRequestGenerator.generate();
	}
 
开发者ID:bluecrystalsign,项目名称:signer-source,代码行数:35,代码来源:DerEncoder.java

示例6: buildOCSPRequest

import org.bouncycastle.cert.ocsp.OCSPReqBuilder; //导入依赖的package包/类
private byte[] buildOCSPRequest(final CertificateToken signCert, final CertificateToken issuerCert, Extension nonceExtension) throws
    DSSException {
  try {
    logger.debug("Building OCSP request");
    final CertificateID certId = DSSRevocationUtils.getOCSPCertificateID(signCert, issuerCert);
    final OCSPReqBuilder ocspReqBuilder = new OCSPReqBuilder();
    ocspReqBuilder.addRequest(certId);
    ocspReqBuilder.setRequestExtensions(new Extensions(nonceExtension));

    if (configuration.hasToBeOCSPRequestSigned()) {
      logger.info("Using signed OCSP request");
      JcaContentSignerBuilder signerBuilder = new JcaContentSignerBuilder("SHA1withRSA");

      if (!configuration.isOCSPSigningConfigurationAvailable()) {
        throw new ConfigurationException("Configuration needed for OCSP request signing is not complete.");
      }

      DSSPrivateKeyEntry keyEntry = getOCSPAccessCertificatePrivateKey();
      PrivateKey privateKey = ((KSPrivateKeyEntry) keyEntry).getPrivateKey();
      X509Certificate ocspSignerCert = keyEntry.getCertificate().getCertificate();

      ContentSigner contentSigner = signerBuilder.build(privateKey);
      X509CertificateHolder[] chain = {new X509CertificateHolder(ocspSignerCert.getEncoded())};
      GeneralName generalName = new GeneralName(new JcaX509CertificateHolder(ocspSignerCert).getSubject());
      ocspReqBuilder.setRequestorName(generalName);

      return ocspReqBuilder.build(contentSigner, chain).getEncoded();
    }
    return ocspReqBuilder.build().getEncoded();
  } catch (Exception e) {
    throw new DSSException(e);
  }
}
 
开发者ID:open-eid,项目名称:digidoc4j,代码行数:34,代码来源:SKOnlineOCSPSource.java


注:本文中的org.bouncycastle.cert.ocsp.OCSPReqBuilder类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。