public boolean[] getKeyUsage() {
boolean[] res = null;
byte[] ext_value;
DERDecoder dec;
ByteArrayInputStream bais;
ASN1BitString bits;
String ku_oid = "2.5.29.15";
// get the extension "key usage"
ext_value = getExtensionValue(ku_oid);
// is it present?
if (ext_value != null) {
// read the extension value through a byte array input stream
bais = new ByteArrayInputStream(ext_value);
try {
// build outer sequence
bits = new ASN1BitString();
dec = new DERDecoder(bais);
/*
* Replaced the construct dec.readX(X) by the correct use of
* X.decode(dec). The latter takes into consideration any
* special decoding steps (such as optimizations) done by the
* decoded class in its decode method. Not of importance with a
* bitstring, but in other classes. --volker roth
*/
bits.decode(dec);
bais.close();
res = bits.getBits();
} catch (Exception e) {
System.out.println("Internal Error.Shouldnt happen");
e.printStackTrace();
}
}