88import org .bouncycastle .asn1 .ASN1EncodableVector ;
99import org .bouncycastle .asn1 .ASN1Object ;
1010import org .bouncycastle .asn1 .ASN1ObjectIdentifier ;
11+ import org .bouncycastle .asn1 .ASN1OctetString ;
1112import org .bouncycastle .asn1 .ASN1Primitive ;
1213import org .bouncycastle .asn1 .ASN1Sequence ;
1314import org .bouncycastle .asn1 .ASN1TaggedObject ;
@@ -40,6 +41,11 @@ public static ASN1Encodable getExtensionParsedValue(Extensions extensions, ASN1O
4041 return null == extensions ? null : extensions .getExtensionParsedValue (oid );
4142 }
4243
44+ public static ASN1OctetString getExtensionValue (Extensions extensions , ASN1ObjectIdentifier oid )
45+ {
46+ return null == extensions ? null : extensions .getExtensionValue (oid );
47+ }
48+
4349 public static Extensions getInstance (
4450 ASN1TaggedObject obj ,
4551 boolean explicit )
@@ -141,8 +147,7 @@ public Enumeration oids()
141147 *
142148 * @return the extension if it's present, null otherwise.
143149 */
144- public Extension getExtension (
145- ASN1ObjectIdentifier oid )
150+ public Extension getExtension (ASN1ObjectIdentifier oid )
146151 {
147152 return (Extension )extensions .get (oid );
148153 }
@@ -155,14 +160,19 @@ public Extension getExtension(
155160 */
156161 public ASN1Encodable getExtensionParsedValue (ASN1ObjectIdentifier oid )
157162 {
158- Extension ext = this .getExtension (oid );
159-
160- if (ext != null )
161- {
162- return ext .getParsedValue ();
163- }
163+ Extension ext = getExtension (oid );
164+ return ext == null ? null : ext .getParsedValue ();
165+ }
164166
165- return null ;
167+ /**
168+ * return the value of the extension represented by the object identifier passed in.
169+ *
170+ * @return the value of the extension if it's present, null otherwise.
171+ */
172+ public ASN1OctetString getExtensionValue (ASN1ObjectIdentifier oid )
173+ {
174+ Extension ext = getExtension (oid );
175+ return ext == null ? null : ext .getExtnValue ();
166176 }
167177
168178 /**
@@ -229,6 +239,21 @@ public ASN1ObjectIdentifier[] getCriticalExtensionOIDs()
229239 return getExtensionOIDs (true );
230240 }
231241
242+ public boolean hasAnyCriticalExtensions ()
243+ {
244+ for (int i = 0 ; i != ordering .size (); i ++)
245+ {
246+ Object oid = ordering .elementAt (i );
247+
248+ if (((Extension )extensions .get (oid )).isCritical ())
249+ {
250+ return true ;
251+ }
252+ }
253+
254+ return false ;
255+ }
256+
232257 private ASN1ObjectIdentifier [] getExtensionOIDs (boolean isCritical )
233258 {
234259 Vector oidVec = new Vector ();
0 commit comments