Example usage for org.bouncycastle.asn1.tsp TimeStampResp getStatus

List of usage examples for org.bouncycastle.asn1.tsp TimeStampResp getStatus

Introduction

In this page you can find the example usage for org.bouncycastle.asn1.tsp TimeStampResp getStatus.

Prototype

public PKIStatusInfo getStatus() 

Source Link

Usage

From source file:ee.ria.xroad.proxy.messagelog.TimestamperUtil.java

License:Open Source License

static TimeStampResponse getTimestampResponse(InputStream in) throws Exception {
    TimeStampResp response = TimeStampResp.getInstance(new ASN1InputStream(in).readObject());

    if (response == null) {
        throw new RuntimeException("Could not read time-stamp response");
    }//from w w w  .  j  a v  a2  s  . c o m

    BigInteger status = response.getStatus().getStatus();

    log.trace("getTimestampDer() - TimeStampResp.status: {}", status);

    if (!PKIStatus.granted.getValue().equals(status) && !PKIStatus.grantedWithMods.getValue().equals(status)) {
        PKIFreeText statusString = response.getStatus().getStatusString();

        StringBuilder sb = new StringBuilder();

        for (int i = 0; i < statusString.size(); i++) {
            if (i > 0) {
                sb.append(", ");
            }

            sb.append("\"" + statusString.getStringAt(i) + "\"");
        }

        log.error("getTimestampDer() - TimeStampResp.status is not "
                + "\"granted\" neither \"grantedWithMods\": {}, {}", status, sb);

        throw new RuntimeException("TimeStampResp.status: " + status + ", .statusString: " + sb);
    }

    return new TimeStampResponse(response);
}