~brian-thomason/+junk/bouncycastle

« back to all changes in this revision

Viewing changes to src/org/bouncycastle/cert/ocsp/RevokedStatus.java

  • Committer: Brian Thomason
  • Date: 2011-12-20 17:20:32 UTC
  • Revision ID: brian.thomason@canonical.com-20111220172032-rdtm13jgdxtksacr
Initial import

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
package org.bouncycastle.cert.ocsp;
 
2
 
 
3
import java.util.Date;
 
4
 
 
5
import org.bouncycastle.asn1.DERGeneralizedTime;
 
6
import org.bouncycastle.asn1.ocsp.RevokedInfo;
 
7
import org.bouncycastle.asn1.x509.CRLReason;
 
8
 
 
9
/**
 
10
 * wrapper for the RevokedInfo object
 
11
 */
 
12
public 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 DERGeneralizedTime(revocationDate), new CRLReason(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
}