1package org.bouncycastle.asn1.misc;
2
3import org.bouncycastle.asn1.DERBitString;
4
5/**
6 * The NetscapeCertType object.
7 * <pre>
8 *    NetscapeCertType ::= BIT STRING {
9 *         SSLClient               (0),
10 *         SSLServer               (1),
11 *         S/MIME                  (2),
12 *         Object Signing          (3),
13 *         Reserved                (4),
14 *         SSL CA                  (5),
15 *         S/MIME CA               (6),
16 *         Object Signing CA       (7) }
17 * </pre>
18 */
19public class NetscapeCertType
20    extends DERBitString
21{
22    public static final int        sslClient        = (1 << 7);
23    public static final int        sslServer        = (1 << 6);
24    public static final int        smime            = (1 << 5);
25    public static final int        objectSigning    = (1 << 4);
26    public static final int        reserved         = (1 << 3);
27    public static final int        sslCA            = (1 << 2);
28    public static final int        smimeCA          = (1 << 1);
29    public static final int        objectSigningCA  = (1 << 0);
30
31    /**
32     * Basic constructor.
33     *
34     * @param usage - the bitwise OR of the Key Usage flags giving the
35     * allowed uses for the key.
36     * e.g. (X509NetscapeCertType.sslCA | X509NetscapeCertType.smimeCA)
37     */
38    public NetscapeCertType(
39        int usage)
40    {
41        super(getBytes(usage), getPadBits(usage));
42    }
43
44    public NetscapeCertType(
45        DERBitString usage)
46    {
47        super(usage.getBytes(), usage.getPadBits());
48    }
49
50    public String toString()
51    {
52        return "NetscapeCertType: 0x" + Integer.toHexString(data[0] & 0xff);
53    }
54}
55