001    /**
002     *
003     *  Licensed to the Apache Software Foundation (ASF) under one or more
004     *  contributor license agreements.  See the NOTICE file distributed with
005     *  this work for additional information regarding copyright ownership.
006     *  The ASF licenses this file to You under the Apache License, Version 2.0
007     *  (the "License"); you may not use this file except in compliance with
008     *  the License.  You may obtain a copy of the License at
009     *
010     *     http://www.apache.org/licenses/LICENSE-2.0
011     *
012     *  Unless required by applicable law or agreed to in writing, software
013     *  distributed under the License is distributed on an "AS IS" BASIS,
014     *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
015     *  See the License for the specific language governing permissions and
016     *  limitations under the License.
017     */
018    
019    package org.apache.geronimo.util.asn1.x509;
020    
021    import org.apache.geronimo.util.asn1.DERBitString;
022    
023    /**
024     * The ReasonFlags object.
025     * <pre>
026     * ReasonFlags ::= BIT STRING {
027     *      unused                  (0),
028     *      keyCompromise           (1),
029     *      cACompromise            (2),
030     *      affiliationChanged      (3),
031     *      superseded              (4),
032     *      cessationOfOperation    (5),
033     *      certificateHold         (6),
034     *      privilegeWithdrawn      (7),
035     *      aACompromise            (8) }
036     * </pre>
037     */
038    public class ReasonFlags
039        extends DERBitString
040    {
041        /**
042         * @deprecated use lower case version
043         */
044        public static final int UNUSED                  = (1 << 7);
045        /**
046         * @deprecated use lower case version
047         */
048        public static final int KEY_COMPROMISE          = (1 << 6);
049        /**
050         * @deprecated use lower case version
051         */
052        public static final int CA_COMPROMISE           = (1 << 5);
053        /**
054         * @deprecated use lower case version
055         */
056        public static final int AFFILIATION_CHANGED     = (1 << 4);
057        /**
058         * @deprecated use lower case version
059         */
060        public static final int SUPERSEDED              = (1 << 3);
061        /**
062         * @deprecated use lower case version
063         */
064        public static final int CESSATION_OF_OPERATION  = (1 << 2);
065        /**
066         * @deprecated use lower case version
067         */
068        public static final int CERTIFICATE_HOLD        = (1 << 1);
069        /**
070         * @deprecated use lower case version
071         */
072        public static final int PRIVILEGE_WITHDRAWN     = (1 << 0);
073        /**
074         * @deprecated use lower case version
075         */
076        public static final int AA_COMPROMISE           = (1 << 15);
077    
078        public static final int unused                  = (1 << 7);
079        public static final int keyCompromise           = (1 << 6);
080        public static final int cACompromise            = (1 << 5);
081        public static final int affiliationChanged      = (1 << 4);
082        public static final int superseded              = (1 << 3);
083        public static final int cessationOfOperation    = (1 << 2);
084        public static final int certificateHold         = (1 << 1);
085        public static final int privilegeWithdrawn      = (1 << 0);
086        public static final int aACompromise            = (1 << 15);
087    
088        /**
089         * @param reasons - the bitwise OR of the Key Reason flags giving the
090         * allowed uses for the key.
091         */
092        public ReasonFlags(
093            int reasons)
094        {
095            super(getBytes(reasons), getPadBits(reasons));
096        }
097    
098        public ReasonFlags(
099            DERBitString reasons)
100        {
101            super(reasons.getBytes(), reasons.getPadBits());
102        }
103    }