1package org.bouncycastle.cert.ocsp;
2
3import java.util.Date;
4
5import org.bouncycastle.asn1.ASN1GeneralizedTime;
6import org.bouncycastle.asn1.ocsp.RevokedInfo;
7import org.bouncycastle.asn1.x509.CRLReason;
8
9/**
10 * wrapper for the RevokedInfo object
11 */
12public class RevokedStatus
13    implements CertificateStatus
14{
15    RevokedInfo info;
16
17    public RevokedStatus(
18        RevokedInfo info)
19    {
20        this.info = info;
21    }
22
23    public RevokedStatus(
24        Date        revocationDate,
25        int         reason)
26    {
27        this.info = new RevokedInfo(new ASN1GeneralizedTime(revocationDate), CRLReason.lookup(reason));
28    }
29
30    public Date getRevocationTime()
31    {
32        return OCSPUtils.extractDate(info.getRevocationTime());
33    }
34
35    public boolean hasRevocationReason()
36    {
37        return (info.getRevocationReason() != null);
38    }
39
40    /**
41     * return the revocation reason. Note: this field is optional, test for it
42     * with hasRevocationReason() first.
43     * @return the revocation reason value.
44     * @exception IllegalStateException if a reason is asked for and none is avaliable
45     */
46    public int getRevocationReason()
47    {
48        if (info.getRevocationReason() == null)
49        {
50            throw new IllegalStateException("attempt to get a reason where none is available");
51        }
52
53        return info.getRevocationReason().getValue().intValue();
54    }
55}
56