| 1 2 package com.ca.commons.security.cert.extensions; 3 4 5 import com.ca.commons.cbutil.CBParse; 6 import com.ca.commons.security.asn1.*; 7 8 import java.util.Hashtable ; 9 10 54 public class CertificatePolicies implements V3Extension 55 { 56 String value = null; 57 58 static Hashtable qualifierIDName = new Hashtable (); 59 60 static 61 { 62 qualifierIDName.put(ASN1OID.cpsOID, "CPS"); 63 } 64 65 public void init(ASN1Object asn1object) throws Exception  66 { 67 if (!asn1object.isASN1Type(ASN1Type.SEQUENCE)) 68 throw new Exception ("Wrong ASN.1 type for CertificatePolicies"); 69 70 for (int i = 0; i < asn1object.size(); i++) 71 { 72 if (!(asn1object.getComponent(i) instanceof Sequence)) 73 throw new Exception ("CertificatePolicies component is not sequence"); 74 75 Sequence seq = (Sequence) asn1object.getComponent(i); 76 for (int j = 0; j < seq.size(); j++) 77 { 78 ASN1Object nextComp = seq.getComponent(j); 79 80 if (j == 0) 81 { 82 String certPolicyID = nextComp.getValue().toString(); 83 84 if (value == null) 85 value = "Certificate Policy ID: " + certPolicyID; 86 else 87 value = value + "\n" + "Certificate Policy ID: " + certPolicyID; 88 } 89 else if (j == 1) 90 { 91 value = value + "\n" + " Qualifier Info: "; 92 93 if (!(nextComp instanceof Sequence)) 94 throw new Exception ("CertificatePolicies component.policyQualifierInfo is not sequence"); 95 96 nextComp = nextComp.getComponent(0); 97 98 String qualifierID = nextComp.getComponent(0).getValue().toString(); 99 if (qualifierIDName.get(qualifierID) != null) 100 { 101 qualifierID = (String ) qualifierIDName.get(qualifierID); 102 } 103 value = value + "\n" + " Qualifier ID: " + qualifierID; 104 105 ASN1Object qualifier = nextComp.getComponent(1); 106 if (qualifier.getValue() != null) 107 { 108 value = value + "\n" + " Qualifier: " + qualifier.getValue(); 109 } 110 else 111 { 112 value = value + "\n" + " Qualifier: " + CBParse.bytes2HexSplit(qualifier.getByteArray(), 4, 36); 113 } 114 } 115 } 116 } 117 } 118 119 public String toString() 120 { 121 return value; 122 } 123 } 124 125 | Popular Tags |