List of usage examples for org.bouncycastle.tsp TimeStampRequest validate
public void validate(Set algorithms, Set policies, Set extensions) throws TSPException
From source file:org.votingsystem.signature.util.TimeStampResponseGenerator.java
License:Open Source License
public TimeStampResponse generate(TimeStampRequest request, BigInteger serialNumber, Date genTime) throws TSPException { this.statusStrings = new ASN1EncodableVector(); TimeStampResp resp;/*from w w w. ja v a2s .com*/ PKIStatusInfo pkiStatusInfo; try { if (genTime == null) { throw new TSPValidationException("The time source is not available.", 512); } request.validate(this.acceptedAlgorithms, this.acceptedPolicies, this.acceptedExtensions); this.status = 0; this.addStatusString("Operation Okay"); PKIStatusInfo e = this.getPKIStatusInfo(); pkiStatusInfo = null; ContentInfo pkiStatusInfo1; try { ByteArrayInputStream ioEx = new ByteArrayInputStream(this.tokenGenerator .generate(request, serialNumber, genTime).toCMSSignedData().getEncoded()); ASN1InputStream aIn = new ASN1InputStream(ioEx); pkiStatusInfo1 = ContentInfo.getInstance(aIn.readObject()); } catch (IOException var10) { throw new TSPException("Timestamp token received cannot be converted to ContentInfo", var10); } resp = new TimeStampResp(e, pkiStatusInfo1); } catch (TSPValidationException var11) { this.status = 2; this.setFailInfoField(var11.getFailureCode()); this.addStatusString(var11.getMessage()); pkiStatusInfo = this.getPKIStatusInfo(); resp = new TimeStampResp(pkiStatusInfo, (ContentInfo) null); } try { return new TimeStampResponse(resp); } catch (IOException var9) { throw new TSPException("created badly formatted response!"); } }