Example usage for org.bouncycastle.tsp TSPValidationException getFailureCode

List of usage examples for org.bouncycastle.tsp TSPValidationException getFailureCode

Introduction

In this page you can find the example usage for org.bouncycastle.tsp TSPValidationException getFailureCode.

Prototype

public int getFailureCode() 

Source Link

Document

Return the failure code associated with this exception - if one is set.

Usage

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 .  java2  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;// w  ww  . j ava  2  s  .  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!");
    }
}