@Override
public OCSPResponse generate(final OCSPRequest request) {
try {
BouncyCastleOCSPRequest bcRequest = new BouncyCastleOCSPRequest(request);
OCSPReq ocspReq = new OCSPReq(request.getRequest());
SubjectPublicKeyInfo keyInfo = SubjectPublicKeyInfo.getInstance(bcRequest.getIssuerCertificate().getPublicKey().getEncoded());
JcaDigestCalculatorProviderBuilder digestCalculatorProviderBuilder = new JcaDigestCalculatorProviderBuilder();
digestCalculatorProviderBuilder.setProvider(BouncyCastleProviderHelper.PROVIDER_NAME);
DigestCalculatorProvider digestCalculatorProvider = digestCalculatorProviderBuilder.build();
DigestCalculator digestCalculator = digestCalculatorProvider.get(CertificateID.HASH_SHA1);
BasicOCSPRespBuilder builder = new BasicOCSPRespBuilder(keyInfo, digestCalculator);
Extension ocspNonce = ocspReq.getExtension(OCSPObjectIdentifiers.id_pkix_ocsp_nonce);
if (ocspNonce != null) {
builder.setResponseExtensions(new Extensions(new Extension[] { ocspNonce }));
}
Req[] list = ocspReq.getRequestList();
for (Req req : list) {
CertificateID certificateID = req.getCertID();
BigInteger serialNumber = certificateID.getSerialNumber();
RevokeReason reason = request.getValidator().validate(serialNumber);