KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > com > ca > commons > security > cert > extensions > AuthorityInfoAccess


1
2 package com.ca.commons.security.cert.extensions;
3
4 import com.ca.commons.security.asn1.*;
5
6 import java.util.Hashtable JavaDoc;
7
8 /**
9  * <pre>
10  * AuthorityInfoAccessSyntax ::=
11  * SEQUENCE SIZE (1..MAX) OF AccessDescription
12  *
13  * AccessDescription ::= SEQUENCE {
14  * accessMethod OBJECT IDENTIFIER,
15  * accessLocation GeneralName }
16  *
17  * On-line Certificate Status Protocol (1 3 6 1 5 5 7 48 1)
18  * </pre>
19  *
20  * @author vbui
21  */

22 public class AuthorityInfoAccess implements V3Extension
23 {
24     String JavaDoc value = null;
25
26     static Hashtable JavaDoc acc = new Hashtable JavaDoc();
27
28     static
29     {
30         acc.put(ASN1OID.authInfoAccessOCSP, "On-line Certificate Status Protocol");
31     }
32
33     public void init(ASN1Object asn1object) throws Exception JavaDoc
34     {
35         if (!asn1object.isASN1Type(ASN1Type.SEQUENCE))
36             throw new Exception JavaDoc("Wrong ASN.1 type for AuthorityInfoAccess");
37
38         for (int i = 0; i < asn1object.size(); i++)
39         {
40             if (!(asn1object.getComponent(i) instanceof Sequence))
41                 throw new Exception JavaDoc("AuthorityInfoAccess component is not sequence");
42
43             Sequence seq = (Sequence) asn1object.getComponent(i);
44             for (int j = 0; j < seq.size(); j++)
45             {
46                 ASN1Object nextComp = seq.getComponent(j);
47
48                 if (j == 0)
49                 {
50                     String JavaDoc accMethod = (String JavaDoc)acc.get(nextComp.getValue());
51                     if (accMethod == null) accMethod = "Unidentified";
52
53                     if (value == null)
54                         value = "Access Method: " + accMethod;
55                     else
56                         value = value + "\n" + "Access Method: " + accMethod;
57                 }
58                 else if (j == 1)
59                 {
60                     if (value == null)
61                         value = IssuerAltName.getGNameString(nextComp);
62                     else
63                         value = value + "\n" + IssuerAltName.getGNameString(nextComp);
64                 }
65             }
66         }
67     }
68
69     public String JavaDoc toString()
70     {
71         return value;
72     }
73 }
74
75
Popular Tags