org.bouncycastle.asn1.ocsp.BasicOCSPResponse Java Examples

The following examples show how to use org.bouncycastle.asn1.ocsp.BasicOCSPResponse. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: CAdESTimestampSource.java    From dss with GNU Lesser General Public License v2.1 6 votes vote down vote up
@Override
protected List<Identifier> getEncapsulatedOCSPIdentifiers(CAdESAttribute unsignedAttribute) {
	List<Identifier> ocspIdentifiers = new ArrayList<>();
	ASN1Encodable asn1Object = unsignedAttribute.getASN1Object();
	RevocationValues revocationValues = DSSASN1Utils.getRevocationValues(asn1Object);
	if (revocationValues != null) {
		for (final BasicOCSPResponse basicOCSPResponse : revocationValues.getOcspVals()) {
			try {
				final BasicOCSPResp basicOCSPResp = new BasicOCSPResp(basicOCSPResponse);
				ocspIdentifiers.add(OCSPResponseBinary.build(basicOCSPResp));
			} catch (Exception e) {
				String errorMessage = "Unable to parse OCSP response binaries : {}";
				if (LOG.isDebugEnabled()) {
					LOG.warn(errorMessage, e.getMessage(), e);
				} else {
					LOG.warn(errorMessage, e.getMessage());
				}
			}
		}
	}
	return ocspIdentifiers;
}
 
Example #2
Source File: CMSOCSPSource.java    From dss with GNU Lesser General Public License v2.1 6 votes vote down vote up
private void collectRevocationValues(AttributeTable attributes, ASN1ObjectIdentifier revocationValueAttributes,
		RevocationOrigin origin) {

	final ASN1Encodable attValue = DSSASN1Utils.getAsn1Encodable(attributes, revocationValueAttributes);
	if (attValue !=null) {

		RevocationValues revocationValues = DSSASN1Utils.getRevocationValues(attValue);
		if (revocationValues != null) {
			for (final BasicOCSPResponse basicOCSPResponse : revocationValues.getOcspVals()) {
				final BasicOCSPResp basicOCSPResp = new BasicOCSPResp(basicOCSPResponse);
				OCSPResponseBinary ocspResponseIdentifier = OCSPResponseBinary.build(basicOCSPResp);
				addBinary(ocspResponseIdentifier, origin);
			}
		}
		/*
		 * TODO: should add also OtherRevVals, but: "The syntax and semantics of the
		 * other revocation values (OtherRevVals) are outside the scope of the present
		 * document. The definition of the syntax of the other form of revocation
		 * information is as identified by OtherRevRefType."
		 */
	}
}
 
Example #3
Source File: RevocationValues.java    From signer with GNU Lesser General Public License v3.0 5 votes vote down vote up
@Override
  public Attribute getValue() throws SignerException {
  	List<X509CRL> crlList = new ArrayList<X509CRL>();
  	ArrayList<CertificateList> crlVals = new ArrayList<CertificateList>();
  	List<BasicOCSPResponse> ocspVals = new ArrayList<BasicOCSPResponse>();
  	try {
  	
  		int chainSize = certificates.length -1;
  		for (int ix = 0; ix < chainSize; ix++ ){
  			X509Certificate cert = (X509Certificate) certificates[ix];
  			Collection<ICPBR_CRL> icpCrls = crlRepository.getX509CRL(cert);
  			for (ICPBR_CRL icpCrl : icpCrls) {
  				crlList.add(icpCrl.getCRL());
  			}				
  		}
  		if (crlList.isEmpty()){
  			throw new SignerException(cadesMessagesBundle.getString("error.crl.list.empty"));
  		}else{
  			for(X509CRL varCrl : crlList){
  				crlVals.add(CertificateList.getInstance(varCrl.getEncoded()));
  				
  				
  			}
  		}
  		CertificateList[] crlValuesArray = new CertificateList[crlVals.size()];
  		BasicOCSPResponse[] ocspValuesArray = new BasicOCSPResponse[ocspVals.size()];
  		//	OtherRevVals otherRevVals = new OtherRevVals(null);
  		//return new Attribute(new ASN1ObjectIdentifier(identifier),	new DERSet(null));
  		//org.bouncycastle.asn1.esf.RevocationValues revocationVals = new org.bouncycastle.asn1.esf.RevocationValues(crlVals.toArray(crlValuesArray), ocspVals.toArray(ocspValuesArray), null);
  		//org.bouncycastle.asn1.esf.RevocationValues revocationVals = new org.bouncycastle.asn1.esf.RevocationValues(crlVals.toArray(crlValuesArray), null, null);
  		return new Attribute(new ASN1ObjectIdentifier(identifier),new DERSet(new DERSequence(crlVals.toArray(crlValuesArray))));
  	} catch (Exception e) {
  		throw new SignerException(e.getMessage());
}
  }
 
Example #4
Source File: DSSASN1Utils.java    From dss with GNU Lesser General Public License v2.1 5 votes vote down vote up
public static byte[] getEncoded(BasicOCSPResp basicOCSPResp) {
	try {
		BasicOCSPResponse basicOCSPResponse = BasicOCSPResponse.getInstance(basicOCSPResp.getEncoded());
		return getDEREncoded(basicOCSPResponse);
	} catch (IOException e) {
		throw new DSSException(e);
	}
}
 
Example #5
Source File: XadesCSpecification.java    From freehealth-connector with GNU Affero General Public License v3.0 4 votes vote down vote up
private byte[] convertToOCSPResp(OCSPData data) throws IOException, OCSPException {
   BasicOCSPResp basicResp = new BasicOCSPResp(BasicOCSPResponse.getInstance(ASN1Primitive.fromByteArray(data.getOcspResponse())));
   return (new OCSPRespBuilder()).build(0, basicResp).getEncoded();
}
 
Example #6
Source File: XadesCSpecification.java    From freehealth-connector with GNU Affero General Public License v3.0 4 votes vote down vote up
private byte[] convertToOCSPResp(OCSPData data) throws IOException, OCSPException {
   BasicOCSPResp basicResp = new BasicOCSPResp(BasicOCSPResponse.getInstance(ASN1Primitive.fromByteArray(data.getOcspResponse())));
   return (new OCSPRespBuilder()).build(0, basicResp).getEncoded();
}
 
Example #7
Source File: XadesCSpecification.java    From freehealth-connector with GNU Affero General Public License v3.0 4 votes vote down vote up
private byte[] convertToOCSPResp(OCSPData data) throws IOException, OCSPException {
   BasicOCSPResp basicResp = new BasicOCSPResp(BasicOCSPResponse.getInstance(ASN1Primitive.fromByteArray(data.getOcspResponse())));
   return (new OCSPRespBuilder()).build(0, basicResp).getEncoded();
}
 
Example #8
Source File: XadesCSpecification.java    From freehealth-connector with GNU Affero General Public License v3.0 4 votes vote down vote up
private byte[] convertToOCSPResp(OCSPData data) throws IOException, OCSPException {
   BasicOCSPResp basicResp = new BasicOCSPResp(BasicOCSPResponse.getInstance(ASN1Primitive.fromByteArray(data.getOcspResponse())));
   return (new OCSPRespBuilder()).build(0, basicResp).getEncoded();
}
 
Example #9
Source File: XadesCSpecification.java    From freehealth-connector with GNU Affero General Public License v3.0 4 votes vote down vote up
private byte[] convertToOCSPResp(OCSPData data) throws IOException, OCSPException {
   BasicOCSPResp basicResp = new BasicOCSPResp(BasicOCSPResponse.getInstance(ASN1Primitive.fromByteArray(data.getOcspResponse())));
   return (new OCSPRespBuilder()).build(0, basicResp).getEncoded();
}