001package org.apache.commons.ssl.org.bouncycastle.asn1.x509;
002
003import org.apache.commons.ssl.org.bouncycastle.asn1.DERBitString;
004
005/**
006 * The ReasonFlags object.
007 * <pre>
008 * ReasonFlags ::= BIT STRING {
009 *      unused                  (0),
010 *      keyCompromise           (1),
011 *      cACompromise            (2),
012 *      affiliationChanged      (3),
013 *      superseded              (4),
014 *      cessationOfOperation    (5),
015 *      certificateHold         (6),
016 *      privilegeWithdrawn      (7),
017 *      aACompromise            (8) }
018 * </pre>
019 */
020public class ReasonFlags
021    extends DERBitString
022{
023    /**
024     * @deprecated use lower case version
025     */
026    public static final int UNUSED                  = (1 << 7);
027    /**
028     * @deprecated use lower case version
029     */
030    public static final int KEY_COMPROMISE          = (1 << 6);
031    /**
032     * @deprecated use lower case version
033     */
034    public static final int CA_COMPROMISE           = (1 << 5);
035    /**
036     * @deprecated use lower case version
037     */
038    public static final int AFFILIATION_CHANGED     = (1 << 4);
039    /**
040     * @deprecated use lower case version
041     */
042    public static final int SUPERSEDED              = (1 << 3);
043    /**
044     * @deprecated use lower case version
045     */
046    public static final int CESSATION_OF_OPERATION  = (1 << 2);
047    /**
048     * @deprecated use lower case version
049     */
050    public static final int CERTIFICATE_HOLD        = (1 << 1);
051    /**
052     * @deprecated use lower case version
053     */
054    public static final int PRIVILEGE_WITHDRAWN     = (1 << 0);
055    /**
056     * @deprecated use lower case version
057     */
058    public static final int AA_COMPROMISE           = (1 << 15);
059    
060    public static final int unused                  = (1 << 7);
061    public static final int keyCompromise           = (1 << 6);
062    public static final int cACompromise            = (1 << 5);
063    public static final int affiliationChanged      = (1 << 4);
064    public static final int superseded              = (1 << 3);
065    public static final int cessationOfOperation    = (1 << 2);
066    public static final int certificateHold         = (1 << 1);
067    public static final int privilegeWithdrawn      = (1 << 0);
068    public static final int aACompromise            = (1 << 15);
069
070    /**
071     * @param reasons - the bitwise OR of the Key Reason flags giving the
072     * allowed uses for the key.
073     */
074    public ReasonFlags(
075        int reasons)
076    {
077        super(getBytes(reasons), getPadBits(reasons));
078    }
079
080    public ReasonFlags(
081        DERBitString reasons)
082    {
083        super(reasons.getBytes(), reasons.getPadBits());
084    }
085}