001package org.apache.commons.ssl.org.bouncycastle.asn1.misc;
002
003import org.apache.commons.ssl.org.bouncycastle.asn1.DERBitString;
004
005/**
006 * The NetscapeCertType object.
007 * <pre>
008 *    NetscapeCertType ::= BIT STRING {
009 *         SSLClient               (0),
010 *         SSLServer               (1),
011 *         S/MIME                  (2),
012 *         Object Signing          (3),
013 *         Reserved                (4),
014 *         SSL CA                  (5),
015 *         S/MIME CA               (6),
016 *         Object Signing CA       (7) }
017 * </pre>
018 */
019public class NetscapeCertType
020    extends DERBitString
021{
022    public static final int        sslClient        = (1 << 7); 
023    public static final int        sslServer        = (1 << 6);
024    public static final int        smime            = (1 << 5);
025    public static final int        objectSigning    = (1 << 4);
026    public static final int        reserved         = (1 << 3);
027    public static final int        sslCA            = (1 << 2);
028    public static final int        smimeCA          = (1 << 1);
029    public static final int        objectSigningCA  = (1 << 0);
030
031    /**
032     * Basic constructor.
033     * 
034     * @param usage - the bitwise OR of the Key Usage flags giving the
035     * allowed uses for the key.
036     * e.g. (X509NetscapeCertType.sslCA | X509NetscapeCertType.smimeCA)
037     */
038    public NetscapeCertType(
039        int usage)
040    {
041        super(getBytes(usage), getPadBits(usage));
042    }
043
044    public NetscapeCertType(
045        DERBitString usage)
046    {
047        super(usage.getBytes(), usage.getPadBits());
048    }
049
050    public String toString()
051    {
052        return "NetscapeCertType: 0x" + Integer.toHexString(data[0] & 0xff);
053    }
054}