Example usage for org.bouncycastle.asn1.ocsp SingleResponse SingleResponse

List of usage examples for org.bouncycastle.asn1.ocsp SingleResponse SingleResponse

Introduction

In this page you can find the example usage for org.bouncycastle.asn1.ocsp SingleResponse SingleResponse.

Prototype

public SingleResponse(CertID certID, CertStatus certStatus, ASN1GeneralizedTime thisUpdate,
            ASN1GeneralizedTime nextUpdate, Extensions singleExtensions) 

Source Link

Usage

From source file:org.jruby.ext.openssl.OCSPBasicResponse.java

License:Common Public License

@JRubyMethod(name = "add_status", rest = true)
public OCSPBasicResponse add_status(final ThreadContext context, IRubyObject[] args) {
    Ruby runtime = context.getRuntime();
    Arity.checkArgumentCount(runtime, args, 7, 7);

    IRubyObject certificateId = args[0];
    IRubyObject status = args[1];/*from ww w. ja v  a 2  s . c om*/
    IRubyObject reason = args[2];
    IRubyObject revocation_time = args[3];
    IRubyObject this_update = args[4];
    IRubyObject next_update = args[5];
    IRubyObject extensions = args[6];

    CertStatus certStatus = null;
    switch (RubyFixnum.fix2int((RubyFixnum) status)) {
    case 0:
        certStatus = new CertStatus();
        break;
    case 1:
        ASN1GeneralizedTime revTime = rubyIntOrTimeToGenTime(revocation_time);
        RevokedInfo revokedInfo = new RevokedInfo(revTime,
                CRLReason.lookup(RubyFixnum.fix2int((RubyFixnum) reason)));
        certStatus = new CertStatus(revokedInfo);
        break;
    case 2:
        certStatus = new CertStatus(2, DERNull.INSTANCE);
        break;
    default:
        break;
    }

    ASN1GeneralizedTime thisUpdate = rubyIntOrTimeToGenTime(this_update);
    ASN1GeneralizedTime nextUpdate = rubyIntOrTimeToGenTime(next_update);
    Extensions singleExtensions = convertRubyExtensions(extensions);
    CertID certID = ((OCSPCertificateId) certificateId).getCertID();

    SingleResponse ocspSingleResp = new SingleResponse(certID, certStatus, thisUpdate, nextUpdate,
            singleExtensions);
    OCSPSingleResponse rubySingleResp = new OCSPSingleResponse(runtime);
    try {
        rubySingleResp.initialize(context, RubyString.newString(runtime, ocspSingleResp.getEncoded()));
        singleResponses.add(rubySingleResp);
    } catch (IOException e) {
        throw newOCSPError(runtime, e);
    }

    return this;
}