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


Java OCSPReq类代码示例

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


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

示例1: GenOcspReq

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

	OCSPReqGenerator ocspRequestGenerator = new OCSPReqGenerator();
	CertificateID certId = new CertificateID(CertificateID.HASH_SHA1,
			nextIssuer, nextCert.getSerialNumber());
	ocspRequestGenerator.addRequest(certId);

	BigInteger nonce = BigInteger.valueOf(System.currentTimeMillis());
	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,代码行数:21,代码来源:DerEncoder.java

示例2: testIrregularVersionReq

import org.bouncycastle.ocsp.OCSPReq; //导入依赖的package包/类
private void testIrregularVersionReq()
    throws Exception
{
    OCSPReq ocspRequest = new OCSPReq(irregReq);
    X509Certificate cert = ocspRequest.getCerts("BC")[0];
    if (!ocspRequest.verify(cert.getPublicKey(), "BC"))
    {
        fail("extra version encoding test failed");
    }
}
 
开发者ID:NoYouShutup,项目名称:CryptMeme,代码行数:11,代码来源:OCSPTest.java

示例3: sendRequest

import org.bouncycastle.ocsp.OCSPReq; //导入依赖的package包/类
/**
 * Sends the OCSP request to Notary and
 * retrieves the response
 * @param req OCSP request
 * @param httpFrom HTTP_FROM value (optional)
 * @returns OCSP response
 */
private OCSPResp sendRequest(OCSPReq req, String httpFrom, String format, String formatVer)
    throws DigiDocException 
{
	String responderUrl = ConfigManager.instance().
    	getProperty("DIGIDOC_OCSP_RESPONDER_URL");
	return sendRequestToUrl(req, responderUrl, httpFrom, format, formatVer);
}
 
开发者ID:aleksz,项目名称:driveddoc,代码行数:15,代码来源:FlexibleBouncyCastleNotaryFactory.java

示例4: xchangeOcsp

import org.bouncycastle.ocsp.OCSPReq; //导入依赖的package包/类
private OCSPResp xchangeOcsp(String ocspUrl, OCSPReq req)
		throws MalformedURLException, IOException, OCSPQueryException {
	URL url = new URL(ocspUrl);
	HttpURLConnection con = (HttpURLConnection) url.openConnection();

	con.setAllowUserInteraction(false);
	con.setDoInput(true);
	con.setDoOutput(true);
	con.setUseCaches(false);
	con.setInstanceFollowRedirects(false);
	con.setRequestMethod("POST"); //$NON-NLS-1$

	con
			.setRequestProperty(
					"Content-Length", Integer.toString(req //$NON-NLS-1$
									.getEncoded().length));
	con
			.setRequestProperty(
					"Content-Type", "application/ocsp-request"); //$NON-NLS-1$ //$NON-NLS-2$

	con.connect();
	OutputStream os = con.getOutputStream();
	os.write(req.getEncoded());
	os.close();

	if (con.getResponseCode() != HttpURLConnection.HTTP_OK) {
		throw new OCSPQueryException("Server did not respond with HTTP_OK(200) but with "
				+ con.getResponseCode());
	}

	if ((con.getContentType() == null)
			|| !con.getContentType().equals(
					"application/ocsp-response")) { //$NON-NLS-1$
		throw new OCSPQueryException("Response MIME type is not application/ocsp-response"); //$NON-NLS-1$
	}

	// Read response
	InputStream reader = con.getInputStream();

	int resplen = con.getContentLength();
	byte[] ocspResponseEncoded = new byte[resplen];

	int offset = 0;
	int bread;
	while ((resplen > 0)
			&& (bread = reader.read(ocspResponseEncoded, offset, resplen)) != -1) {
		offset += bread;
		resplen -= bread;
	}

	reader.close();
	con.disconnect();
	return new OCSPResp(ocspResponseEncoded);
}
 
开发者ID:bluecrystalsign,项目名称:signer-source,代码行数:55,代码来源:OcspValidatorImpl.java

示例5: GenOcspReq

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

return DerEncoder.GenOcspReq(nextCert, nextIssuer);
}
 
开发者ID:bluecrystalsign,项目名称:signer-source,代码行数:6,代码来源:OcspValidatorImpl.java


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