1
package org.bouncycastle.ocsp;
3
import org.bouncycastle.asn1.ASN1Encodable;
4
import org.bouncycastle.asn1.ASN1Sequence;
5
import org.bouncycastle.asn1.DERObjectIdentifier;
6
import org.bouncycastle.asn1.ocsp.ResponseData;
7
import org.bouncycastle.asn1.ocsp.SingleResponse;
8
import org.bouncycastle.asn1.x509.X509Extension;
9
import org.bouncycastle.asn1.x509.X509Extensions;
11
import java.text.ParseException;
12
import java.util.Date;
13
import java.util.Enumeration;
14
import java.util.HashSet;
18
implements java.security.cert.X509Extension
28
public int getVersion()
30
return data.getVersion().getValue().intValue() + 1;
33
public RespID getResponderId()
35
return new RespID(data.getResponderID());
38
public Date getProducedAt()
42
return data.getProducedAt().getDate();
44
catch (ParseException e)
46
throw new IllegalStateException("ParseException:" + e.getMessage());
50
public SingleResp[] getResponses()
52
ASN1Sequence s = data.getResponses();
53
SingleResp[] rs = new SingleResp[s.size()];
55
for (int i = 0; i != rs.length; i++)
57
rs[i] = new SingleResp(SingleResponse.getInstance(s.getObjectAt(i)));
63
public X509Extensions getResponseExtensions()
65
return data.getResponseExtensions();
69
* RFC 2650 doesn't specify any critical extensions so we return true
70
* if any are encountered.
72
* @return true if any critical extensions are present.
74
public boolean hasUnsupportedCriticalExtension()
76
Set extns = getCriticalExtensionOIDs();
77
if (extns != null && !extns.isEmpty())
85
private Set getExtensionOIDs(boolean critical)
87
Set set = new HashSet();
88
X509Extensions extensions = this.getResponseExtensions();
90
if (extensions != null)
92
Enumeration e = extensions.oids();
94
while (e.hasMoreElements())
96
DERObjectIdentifier oid = (DERObjectIdentifier)e.nextElement();
97
X509Extension ext = extensions.getExtension(oid);
99
if (critical == ext.isCritical())
101
set.add(oid.getId());
109
public Set getCriticalExtensionOIDs()
111
return getExtensionOIDs(true);
114
public Set getNonCriticalExtensionOIDs()
116
return getExtensionOIDs(false);
119
public byte[] getExtensionValue(String oid)
121
X509Extensions exts = this.getResponseExtensions();
125
X509Extension ext = exts.getExtension(new DERObjectIdentifier(oid));
131
return ext.getValue().getEncoded(ASN1Encodable.DER);
135
throw new RuntimeException("error encoding " + e.toString());