Exemplo n.º 1
0
  private BasicOCSPResp buildBasicOCSPResp() throws OCSPResponseBuilderException {
    try {
      BasicOCSPRespBuilder gen =
          new BasicOCSPRespBuilder(new RespID(new X500Name(getResponderName())));

      if (getNonce() != null) {
        extensions.add(
            new OcspExt(
                OCSPObjectIdentifiers.id_pkix_ocsp_nonce, false, new DEROctetString(nonce)));
      }

      Extension[] extArray = new Extension[extensions.size()];
      int i = 0;
      for (OcspExt ext : extensions) {
        extArray[i++] = new Extension(ext.getOid(), ext.isIsCritical(), ext.getValue());
      }
      if (extArray.length > 0) {
        gen.setResponseExtensions(new Extensions(extArray));
      }

      for (OcspRespObject r : responses) {
        gen.addResponse(
            r.getCertId(),
            r.getCertStatus(),
            r.getThisUpdate(),
            r.getNextUpdate(),
            r.getExtensions());
      }

      ContentSigner contentSigner = /*new BufferingContentSigner(*/
          new JcaContentSignerBuilder(getSignatureAlgorithm())
              .setProvider("BC")
              .build(getIssuerPrivateKey()); // , 20480);

      BasicOCSPResp response = gen.build(contentSigner, getChain(), getProducedAt());
      return response;
    } catch (OCSPException ex) {
      throw new OCSPResponseBuilderException(ex);
    } catch (NoSuchAlgorithmException ex) {
      throw new OCSPResponseBuilderException(ex);
    } catch (NoSuchProviderException ex) {
      throw new OCSPResponseBuilderException(ex);
    } catch (OperatorCreationException ex) {
      throw new OCSPResponseBuilderException(ex);
    }
  }
Exemplo n.º 2
0
 public OCSPResponseBuilder addResponse(OcspRespObject response) {
   responses.add(response);
   return this;
 }