summaryrefslogtreecommitdiffstats
path: root/bcpkix/src/main/java/org/bouncycastle/cert/ocsp/RevokedStatus.java
diff options
context:
space:
mode:
authorKenny Root <kroot@google.com>2016-02-12 17:52:48 -0800
committerKenny Root <kroot@google.com>2016-04-01 15:11:50 -0700
commitb50b4a37e3d49e05b024c189c026bef7ea290ca8 (patch)
treedddb7cc2ca0ad39dc34adc66a286f533c8560c9a /bcpkix/src/main/java/org/bouncycastle/cert/ocsp/RevokedStatus.java
parent7e9eddda2517732b58cc2f95f33ba668309ef0f7 (diff)
downloadandroid_external_bouncycastle-b50b4a37e3d49e05b024c189c026bef7ea290ca8.tar.gz
android_external_bouncycastle-b50b4a37e3d49e05b024c189c026bef7ea290ca8.tar.bz2
android_external_bouncycastle-b50b4a37e3d49e05b024c189c026bef7ea290ca8.zip
Add OCSP files for testing purposes
Testing OCSP support needs some ASN.1 creation utilities. Bouncycastle has them, but we don't want to bloat up the built-in libraries. Add some new targets that will allow us to enable OCSP testing in the core-tests module without spreading it elsewhere. (cherry picked from commit 4eb438010b8024cfa97cdad1906a8e6963a16f5b) Bug: 27812109 Change-Id: I4a75fc0d5186c70a764baa751ceab75d1a44539d
Diffstat (limited to 'bcpkix/src/main/java/org/bouncycastle/cert/ocsp/RevokedStatus.java')
-rw-r--r--bcpkix/src/main/java/org/bouncycastle/cert/ocsp/RevokedStatus.java55
1 files changed, 55 insertions, 0 deletions
diff --git a/bcpkix/src/main/java/org/bouncycastle/cert/ocsp/RevokedStatus.java b/bcpkix/src/main/java/org/bouncycastle/cert/ocsp/RevokedStatus.java
new file mode 100644
index 0000000..d349f07
--- /dev/null
+++ b/bcpkix/src/main/java/org/bouncycastle/cert/ocsp/RevokedStatus.java
@@ -0,0 +1,55 @@
+package org.bouncycastle.cert.ocsp;
+
+import java.util.Date;
+
+import org.bouncycastle.asn1.ASN1GeneralizedTime;
+import org.bouncycastle.asn1.ocsp.RevokedInfo;
+import org.bouncycastle.asn1.x509.CRLReason;
+
+/**
+ * wrapper for the RevokedInfo object
+ */
+public class RevokedStatus
+ implements CertificateStatus
+{
+ RevokedInfo info;
+
+ public RevokedStatus(
+ RevokedInfo info)
+ {
+ this.info = info;
+ }
+
+ public RevokedStatus(
+ Date revocationDate,
+ int reason)
+ {
+ this.info = new RevokedInfo(new ASN1GeneralizedTime(revocationDate), CRLReason.lookup(reason));
+ }
+
+ public Date getRevocationTime()
+ {
+ return OCSPUtils.extractDate(info.getRevocationTime());
+ }
+
+ public boolean hasRevocationReason()
+ {
+ return (info.getRevocationReason() != null);
+ }
+
+ /**
+ * return the revocation reason. Note: this field is optional, test for it
+ * with hasRevocationReason() first.
+ * @return the revocation reason value.
+ * @exception IllegalStateException if a reason is asked for and none is avaliable
+ */
+ public int getRevocationReason()
+ {
+ if (info.getRevocationReason() == null)
+ {
+ throw new IllegalStateException("attempt to get a reason where none is available");
+ }
+
+ return info.getRevocationReason().getValue().intValue();
+ }
+}