| 1 2 package com.ca.commons.security.cert.extensions; 3 4 import com.ca.commons.security.asn1.*; 5 6 15 public class BasicConstraints implements V3Extension 16 { 17 String value = null; 18 19 public int pathLenConstraint = -1; 20 21 public void init(ASN1Object asn1object) throws Exception  22 { 23 if (!asn1object.isASN1Type(ASN1Type.SEQUENCE)) 24 throw new Exception ("Wrong ASN.1 type for BasicConstraints"); 25 26 if (asn1object.size() == 0) 27 { 28 value = "CA: False\nPath Length Constraint: None"; 29 return; 30 } 31 32 if (asn1object.size() >= 1) 33 { 34 Object ca = asn1object.getComponent(0).getValue(); 35 if (!(ca instanceof Boolean )) 36 throw new Exception ("Wrong ASN.1 type for BasicConstraints.cA"); 37 38 value = "CA: " + ca; 39 } 40 41 if (asn1object.size() >= 2) 42 { 43 Object pathLen = asn1object.getComponent(1).getValue(); 44 value = value + "\nPath Length Constraint: " + pathLen; 45 try 46 { 47 int len = Integer.parseInt(pathLen.toString()); 48 if (len >= 0) pathLenConstraint = len; 49 } 50 catch (NumberFormatException ex) 51 { 52 } 54 } 55 else 56 { 57 value = value + "\nPath Length Constraint: None"; 58 } 59 } 60 61 public String toString() 62 { 63 return value; 64 } 65 } 66 67 | Popular Tags |