List of usage examples for org.bouncycastle.asn1.tsp TimeStampResp TimeStampResp
public TimeStampResp(PKIStatusInfo pkiStatusInfo, ContentInfo timeStampToken)
From source file:org.votingsystem.signature.util.TimeStampResponseGenerator.java
License:Open Source License
/** @deprecated */ public TimeStampResponse generate(TimeStampRequest request, BigInteger serialNumber, Date genTime, String provider) throws NoSuchAlgorithmException, NoSuchProviderException, TSPException { TimeStampResp resp;// w w w . ja v a2 s . c o m PKIStatusInfo pkiStatusInfo; try { if (genTime == null) { throw new TSPValidationException("The time source is not available.", 512); } request.validate(this.acceptedAlgorithms, this.acceptedPolicies, this.acceptedExtensions, provider); this.status = 0; this.addStatusString("Operation OK"); PKIStatusInfo e = this.getPKIStatusInfo(); pkiStatusInfo = null; ContentInfo pkiStatusInfo1; try { ByteArrayInputStream ioEx = new ByteArrayInputStream(this.tokenGenerator .generate(request, serialNumber, genTime, provider).toCMSSignedData().getEncoded()); ASN1InputStream aIn = new ASN1InputStream(ioEx); pkiStatusInfo1 = ContentInfo.getInstance(aIn.readObject()); } catch (IOException var11) { throw new TSPException("Timestamp token received cannot be converted to ContentInfo", var11); } resp = new TimeStampResp(e, pkiStatusInfo1); } catch (TSPValidationException var12) { this.status = 2; this.setFailInfoField(var12.getFailureCode()); this.addStatusString(var12.getMessage()); pkiStatusInfo = this.getPKIStatusInfo(); resp = new TimeStampResp(pkiStatusInfo, (ContentInfo) null); } try { return new TimeStampResponse(resp); } catch (IOException var10) { throw new TSPException("created badly formatted response!"); } }
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;/*ww w .j a va 2s .co m*/ 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!"); } }
From source file:org.votingsystem.signature.util.TimeStampResponseGenerator.java
License:Open Source License
public TimeStampResponse generateFailResponse(int status, int failInfoField, String statusString) throws TSPException { this.status = status; this.setFailInfoField(failInfoField); if (statusString != null) { this.addStatusString(statusString); }//from www. ja va 2 s.c o m PKIStatusInfo pkiStatusInfo = this.getPKIStatusInfo(); TimeStampResp resp = new TimeStampResp(pkiStatusInfo, (ContentInfo) null); try { return new TimeStampResponse(resp); } catch (IOException var7) { throw new TSPException("created badly formatted response!"); } }