diff options
author | David Hook <dgh@cryptoworkshop.com> | 2013-05-31 11:07:45 +0400 |
---|---|---|
committer | David Hook <dgh@cryptoworkshop.com> | 2013-05-31 11:07:45 +0400 |
commit | 2b976f5364cfdbc37d3086019d93483c983eb80b (patch) | |
tree | cb846af3fd1d43f9c2562a1fb2d06b997ad8f229 /core/src/main/java/org/bouncycastle/asn1/ocsp/RevokedInfo.java | |
parent | 5f714bd92fbd780d22406f4bc3681be005f6f04a (diff) |
initial reshuffle
Diffstat (limited to 'core/src/main/java/org/bouncycastle/asn1/ocsp/RevokedInfo.java')
-rw-r--r-- | core/src/main/java/org/bouncycastle/asn1/ocsp/RevokedInfo.java | 92 |
1 files changed, 92 insertions, 0 deletions
diff --git a/core/src/main/java/org/bouncycastle/asn1/ocsp/RevokedInfo.java b/core/src/main/java/org/bouncycastle/asn1/ocsp/RevokedInfo.java new file mode 100644 index 00000000..7279ae15 --- /dev/null +++ b/core/src/main/java/org/bouncycastle/asn1/ocsp/RevokedInfo.java @@ -0,0 +1,92 @@ +package org.bouncycastle.asn1.ocsp; + +import org.bouncycastle.asn1.ASN1EncodableVector; +import org.bouncycastle.asn1.ASN1GeneralizedTime; +import org.bouncycastle.asn1.ASN1Object; +import org.bouncycastle.asn1.ASN1Primitive; +import org.bouncycastle.asn1.ASN1Sequence; +import org.bouncycastle.asn1.ASN1TaggedObject; +import org.bouncycastle.asn1.DEREnumerated; +import org.bouncycastle.asn1.DERSequence; +import org.bouncycastle.asn1.DERTaggedObject; +import org.bouncycastle.asn1.x509.CRLReason; + +public class RevokedInfo + extends ASN1Object +{ + private ASN1GeneralizedTime revocationTime; + private CRLReason revocationReason; + + public RevokedInfo( + ASN1GeneralizedTime revocationTime, + CRLReason revocationReason) + { + this.revocationTime = revocationTime; + this.revocationReason = revocationReason; + } + + private RevokedInfo( + ASN1Sequence seq) + { + this.revocationTime = ASN1GeneralizedTime.getInstance(seq.getObjectAt(0)); + + if (seq.size() > 1) + { + this.revocationReason = CRLReason.getInstance(DEREnumerated.getInstance( + (ASN1TaggedObject)seq.getObjectAt(1), true)); + } + } + + public static RevokedInfo getInstance( + ASN1TaggedObject obj, + boolean explicit) + { + return getInstance(ASN1Sequence.getInstance(obj, explicit)); + } + + public static RevokedInfo getInstance( + Object obj) + { + if (obj instanceof RevokedInfo) + { + return (RevokedInfo)obj; + } + else if (obj != null) + { + return new RevokedInfo(ASN1Sequence.getInstance(obj)); + } + + return null; + } + + public ASN1GeneralizedTime getRevocationTime() + { + return revocationTime; + } + + public CRLReason getRevocationReason() + { + return revocationReason; + } + + /** + * Produce an object suitable for an ASN1OutputStream. + * <pre> + * RevokedInfo ::= SEQUENCE { + * revocationTime GeneralizedTime, + * revocationReason [0] EXPLICIT CRLReason OPTIONAL } + * </pre> + */ + public ASN1Primitive toASN1Primitive() + { + ASN1EncodableVector v = new ASN1EncodableVector(); + + v.add(revocationTime); + if (revocationReason != null) + { + v.add(new DERTaggedObject(true, 0, revocationReason)); + } + + return new DERSequence(v); + } +} |