KickJava   Java API By Example, From Geeks To Geeks.

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


1
2 package com.ca.commons.security.cert.extensions;
3
4 import java.util.Hashtable JavaDoc;
5 import com.ca.commons.security.asn1.*;
6
7 /**
8  * <pre>
9  * ExtKeyUsageSyntax ::= SEQUENCE SIZE (1..MAX) OF KeyPurposeId
10  *
11  * KeyPurposeId ::= OBJECT IDENTIFIER
12  *
13  * serverAuth (1 3 6 1 5 5 7 3 1) -- TLS Web server authentication
14  * clientAuth (1 3 6 1 5 5 7 3 2) -- TLS Web client authentication
15  * codeSigning (1 3 6 1 5 5 7 3 3) -- Code signing
16  * emailProtection (1 3 6 1 5 5 7 3 4) -- E-mail protection
17  * ipsecEndSystem (1 3 6 1 5 5 7 3 5) -- IP security end system
18  * ipsecTunnel (1 3 6 1 5 5 7 3 6) -- IP security tunnel termination
19  * ipsecUser (1 3 6 1 5 5 7 3 7) -- IP security user
20  * timeStamping (1 3 6 1 5 5 7 3 8) -- Timestamping
21  * OCSP Signing (1 3 6 1 5 5 7 3 9) -- OCSP Signing
22  * smartCard Logon (1 3 6 1 4 1 311 20 2 2) -- Smart Card Logon
23  * </pre>
24  *
25  * @author vbui
26  */

27 public class ExtendedKeyUsage implements V3Extension
28 {
29     String JavaDoc value = null;
30
31     public void init(ASN1Object asn1object) throws Exception JavaDoc
32     {
33         if (!asn1object.isASN1Type(ASN1Type.SEQUENCE))
34             throw new Exception JavaDoc("Wrong ASN.1 type for ExtendedKeyUsage");
35
36         for (int i = 0; i < asn1object.size(); i++)
37         {
38             Object JavaDoc pur = asn1object.getComponent(i).getValue();
39             if ( pur instanceof String JavaDoc ) { // if not, it's not in table !
40
String JavaDoc spur = (String JavaDoc) pur;
41                 spur = ASN1OID.getName(spur);
42                 if (spur != null) {
43                     if (value == null)
44                         value = spur;
45                     else
46                         value = value + "\n" + spur;
47                 }
48             }
49         }
50     }
51
52     public String JavaDoc toString()
53     {
54         return value;
55     }
56 }
57
58
Popular Tags