KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > com > maverick > crypto > asn1 > misc > NetscapeCertType


1 /*
2  * SSL-Explorer
3  *
4  * Copyright (C) 2003-2006 3SP LTD. All Rights Reserved
5  *
6  * This program is free software; you can redistribute it and/or
7  * modify it under the terms of the GNU General Public License
8  * as published by the Free Software Foundation; either version 2 of
9  * the License, or (at your option) any later version.
10  * This program is distributed in the hope that it will be useful,
11  * but WITHOUT ANY WARRANTY; without even the implied warranty of
12  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13  * GNU General Public License for more details.
14  *
15  * You should have received a copy of the GNU General Public
16  * License along with this program; if not, write to the Free Software
17  * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
18  */

19             
20 package com.maverick.crypto.asn1.misc;
21
22 import com.maverick.crypto.asn1.*;
23
24 /**
25  * The NetscapeCertType object.
26  * <pre>
27  * NetscapeCertType ::= BIT STRING {
28  * SSLClient (0),
29  * SSLServer (1),
30  * S/MIME (2),
31  * Object Signing (3),
32  * Reserved (4),
33  * SSL CA (5),
34  * S/MIME CA (6),
35  * Object Signing CA (7) }
36  * </pre>
37  */

38 public class NetscapeCertType
39     extends DERBitString
40 {
41     public static final int sslClient = (1 << 7);
42     public static final int sslServer = (1 << 6);
43     public static final int smime = (1 << 5);
44     public static final int objectSigning = (1 << 4);
45     public static final int reserved = (1 << 3);
46     public static final int sslCA = (1 << 2);
47     public static final int smimeCA = (1 << 1);
48     public static final int objectSigningCA = (1 << 0);
49
50     /**
51      * Basic constructor.
52      *
53      * @param usage - the bitwise OR of the Key Usage flags giving the
54      * allowed uses for the key.
55      * e.g. (X509NetscapeCertType.sslCA | X509NetscapeCertType.smimeCA)
56      */

57     public NetscapeCertType(
58         int usage)
59     {
60         super(getBytes(usage), getPadBits(usage));
61     }
62
63     public NetscapeCertType(
64         DERBitString usage)
65     {
66         super(usage.getBytes(), usage.getPadBits());
67     }
68
69     public String JavaDoc toString()
70     {
71         return "NetscapeCertType: 0x" + Integer.toHexString(data[0] & 0xff);
72     }
73 }
74
Popular Tags