Search in sources :

Example 21 with ASN1GeneralizedTime

use of org.bouncycastle.asn1.ASN1GeneralizedTime in project jruby-openssl by jruby.

the class OCSPSingleResponse method check_validity.

@JRubyMethod(name = "check_validity", rest = true)
public IRubyObject check_validity(IRubyObject[] args) {
    Ruby runtime = getRuntime();
    int nsec, maxsec;
    Date thisUpdate, nextUpdate;
    if (Arity.checkArgumentCount(runtime, args, 0, 2) == 0) {
        nsec = 0;
        maxsec = -1;
    } else if (Arity.checkArgumentCount(runtime, args, 0, 2) == 1) {
        RubyFixnum rNsec = (RubyFixnum) args[0];
        nsec = (int) rNsec.getLongValue();
        maxsec = -1;
    } else {
        RubyFixnum rNsec = (RubyFixnum) args[0];
        RubyFixnum rMaxsec = (RubyFixnum) args[1];
        nsec = (int) rNsec.getLongValue();
        maxsec = (int) rMaxsec.getLongValue();
    }
    try {
        ASN1GeneralizedTime bcThisUpdate = bcSingleResponse.getThisUpdate();
        if (bcThisUpdate == null) {
            thisUpdate = null;
        } else {
            thisUpdate = bcThisUpdate.getDate();
        }
        ASN1GeneralizedTime bcNextUpdate = bcSingleResponse.getNextUpdate();
        if (bcNextUpdate == null) {
            nextUpdate = null;
        } else {
            nextUpdate = bcNextUpdate.getDate();
        }
    } catch (ParseException e) {
        throw newOCSPError(runtime, e);
    }
    return RubyBoolean.newBoolean(runtime, checkValidityImpl(thisUpdate, nextUpdate, nsec, maxsec));
}
Also used : ASN1GeneralizedTime(org.bouncycastle.asn1.ASN1GeneralizedTime) ParseException(java.text.ParseException) Ruby(org.jruby.Ruby) Date(java.util.Date) RubyFixnum(org.jruby.RubyFixnum) JRubyMethod(org.jruby.anno.JRubyMethod)

Aggregations

ASN1GeneralizedTime (org.bouncycastle.asn1.ASN1GeneralizedTime)20 Date (java.util.Date)11 DERPrintableString (org.bouncycastle.asn1.DERPrintableString)8 DERUTF8String (org.bouncycastle.asn1.DERUTF8String)8 ASN1Encodable (org.bouncycastle.asn1.ASN1Encodable)7 ASN1ObjectIdentifier (org.bouncycastle.asn1.ASN1ObjectIdentifier)7 ASN1OctetString (org.bouncycastle.asn1.ASN1OctetString)7 DERIA5String (org.bouncycastle.asn1.DERIA5String)7 DEROctetString (org.bouncycastle.asn1.DEROctetString)7 IOException (java.io.IOException)6 ASN1Sequence (org.bouncycastle.asn1.ASN1Sequence)6 ParseException (java.text.ParseException)5 DERBMPString (org.bouncycastle.asn1.DERBMPString)5 DERT61String (org.bouncycastle.asn1.DERT61String)5 ASN1String (org.bouncycastle.asn1.ASN1String)4 Extension (org.bouncycastle.asn1.x509.Extension)4 BigInteger (java.math.BigInteger)3 ArrayList (java.util.ArrayList)3 LinkedList (java.util.LinkedList)3 BadCertTemplateException (org.xipki.ca.api.BadCertTemplateException)3