KickJava   Java API By Example, From Geeks To Geeks.

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


1
2 package com.ca.commons.security.cert.extensions;
3
4 import com.ca.commons.security.asn1.*;
5
6 /**
7  * <pre>
8  * NetscapeCertType ::= BIT STRING
9  * {
10  * bit-0 SSL client - this cert is certified for SSL client authentication use
11  * bit-1 SSL server - this cert is certified for SSL server authentication use
12  * bit-2 S/MIME - this cert is certified for use by clients (New in PR3)
13  * bit-3 Object Signing - this cert is certified for signing objects such as Java applets and plugins(New in PR3)
14  * bit-4 Reserved - this bit is reserved for future use
15  * bit-5 SSL CA - this cert is certified for issuing certs for SSL use
16  * bit-6 S/MIME CA - this cert is certified for issuing certs for S/MIME use (New in PR3)
17  * bit-7 Object Signing CA - this cert is certified for issuing certs for Object Signing (New in PR3)
18  * }
19  * </pre>
20  *
21  * @author vbui
22  */

23 public class NetscapeCertType implements V3Extension
24 {
25     String JavaDoc value = null;
26
27     public void init(ASN1Object asn1object) throws Exception JavaDoc
28     {
29         if (!asn1object.isASN1Type(ASN1Type.BIT_STRING))
30             throw new Exception JavaDoc("Wrong ASN.1 type for NetscapeCertType");
31
32         byte[] o = (byte[]) asn1object.getValue();
33
34         StringBuffer JavaDoc buff = new StringBuffer JavaDoc();
35
36         if ((o[1] & (byte)0x80) != 0)
37             buff.append("SSL client, ");
38         if ((o[1] & (byte)0x40) != 0)
39             buff.append("SSL server, ");
40         if ((o[1] & (byte)0x20) != 0)
41             buff.append("S/MIME, ");
42         if ((o[1] & (byte)0x10) != 0)
43             buff.append("Object Signing, ");
44         if ((o[1] & (byte)0x08) != 0)
45             buff.append("Reserved, ");
46         if ((o[1] & (byte)0x04) != 0)
47             buff.append("SSL CA, ");
48         if ((o[1] & (byte)0x02) != 0)
49             buff.append("S/MIME CA, ");
50         if ((o[1] & (byte)0x01) != 0)
51             buff.append("Object Signing CA, ");
52
53         value = buff.toString();
54         if (value.endsWith(", "))
55             value = value.substring(0, value.length() - 2);
56     }
57
58     public String JavaDoc toString()
59     {
60         return value;
61     }
62 }
63
64
Popular Tags