src/java.base/share/classes/sun/security/x509/ReasonFlags.java
author igerasim
Tue, 02 Oct 2018 10:19:07 -0700
changeset 51986 c1db377f6300
parent 47216 71c04702a3d5
permissions -rw-r--r--
8200381: Typos in javadoc - missing verb "be" and alike Reviewed-by: lancea, darcy, wetmore
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
     1
/*
29917
5edfc7a4ac68 8068720: Better certificate options checking
igerasim
parents: 25859
diff changeset
     2
 * Copyright (c) 1997, 2015, Oracle and/or its affiliates. All rights reserved.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
     3
 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
90ce3da70b43 Initial load
duke
parents:
diff changeset
     4
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
     5
 * This code is free software; you can redistribute it and/or modify it
90ce3da70b43 Initial load
duke
parents:
diff changeset
     6
 * under the terms of the GNU General Public License version 2 only, as
5506
202f599c92aa 6943119: Rebrand source copyright notices
ohair
parents: 2
diff changeset
     7
 * published by the Free Software Foundation.  Oracle designates this
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
     8
 * particular file as subject to the "Classpath" exception as provided
5506
202f599c92aa 6943119: Rebrand source copyright notices
ohair
parents: 2
diff changeset
     9
 * by Oracle in the LICENSE file that accompanied this code.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    10
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
    11
 * This code is distributed in the hope that it will be useful, but WITHOUT
90ce3da70b43 Initial load
duke
parents:
diff changeset
    12
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
90ce3da70b43 Initial load
duke
parents:
diff changeset
    13
 * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
90ce3da70b43 Initial load
duke
parents:
diff changeset
    14
 * version 2 for more details (a copy is included in the LICENSE file that
90ce3da70b43 Initial load
duke
parents:
diff changeset
    15
 * accompanied this code).
90ce3da70b43 Initial load
duke
parents:
diff changeset
    16
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
    17
 * You should have received a copy of the GNU General Public License version
90ce3da70b43 Initial load
duke
parents:
diff changeset
    18
 * 2 along with this work; if not, write to the Free Software Foundation,
90ce3da70b43 Initial load
duke
parents:
diff changeset
    19
 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    20
 *
5506
202f599c92aa 6943119: Rebrand source copyright notices
ohair
parents: 2
diff changeset
    21
 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
202f599c92aa 6943119: Rebrand source copyright notices
ohair
parents: 2
diff changeset
    22
 * or visit www.oracle.com if you need additional information or have any
202f599c92aa 6943119: Rebrand source copyright notices
ohair
parents: 2
diff changeset
    23
 * questions.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    24
 */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    25
90ce3da70b43 Initial load
duke
parents:
diff changeset
    26
package sun.security.x509;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    27
90ce3da70b43 Initial load
duke
parents:
diff changeset
    28
import java.io.IOException;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    29
import java.io.InputStream;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    30
import java.io.OutputStream;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    31
import java.util.Enumeration;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    32
90ce3da70b43 Initial load
duke
parents:
diff changeset
    33
import sun.security.util.*;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    34
90ce3da70b43 Initial load
duke
parents:
diff changeset
    35
/**
90ce3da70b43 Initial load
duke
parents:
diff changeset
    36
 * Represent the CRL Reason Flags.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    37
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
    38
 * <p>This extension, if present, defines the identifies
90ce3da70b43 Initial load
duke
parents:
diff changeset
    39
 * the reason for the certificate revocation.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    40
 * <p>The ASN.1 syntax for this is:
90ce3da70b43 Initial load
duke
parents:
diff changeset
    41
 * <pre>
90ce3da70b43 Initial load
duke
parents:
diff changeset
    42
 * ReasonFlags ::= BIT STRING {
90ce3da70b43 Initial load
duke
parents:
diff changeset
    43
 *    unused                  (0),
90ce3da70b43 Initial load
duke
parents:
diff changeset
    44
 *    keyCompromise           (1),
90ce3da70b43 Initial load
duke
parents:
diff changeset
    45
 *    cACompromise            (2),
90ce3da70b43 Initial load
duke
parents:
diff changeset
    46
 *    affiliationChanged      (3),
90ce3da70b43 Initial load
duke
parents:
diff changeset
    47
 *    superseded              (4),
90ce3da70b43 Initial load
duke
parents:
diff changeset
    48
 *    cessationOfOperation    (5),
90ce3da70b43 Initial load
duke
parents:
diff changeset
    49
 *    certificateHold         (6),
90ce3da70b43 Initial load
duke
parents:
diff changeset
    50
 *    privilegeWithdrawn      (7),
90ce3da70b43 Initial load
duke
parents:
diff changeset
    51
 *    aACompromise            (8) }
90ce3da70b43 Initial load
duke
parents:
diff changeset
    52
 * </pre>
90ce3da70b43 Initial load
duke
parents:
diff changeset
    53
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
    54
 * @author Hemma Prafullchandra
90ce3da70b43 Initial load
duke
parents:
diff changeset
    55
 */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    56
public class ReasonFlags {
90ce3da70b43 Initial load
duke
parents:
diff changeset
    57
90ce3da70b43 Initial load
duke
parents:
diff changeset
    58
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
    59
     * Reasons
90ce3da70b43 Initial load
duke
parents:
diff changeset
    60
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    61
    public static final String UNUSED = "unused";
90ce3da70b43 Initial load
duke
parents:
diff changeset
    62
    public static final String KEY_COMPROMISE = "key_compromise";
90ce3da70b43 Initial load
duke
parents:
diff changeset
    63
    public static final String CA_COMPROMISE = "ca_compromise";
90ce3da70b43 Initial load
duke
parents:
diff changeset
    64
    public static final String AFFILIATION_CHANGED = "affiliation_changed";
90ce3da70b43 Initial load
duke
parents:
diff changeset
    65
    public static final String SUPERSEDED = "superseded";
90ce3da70b43 Initial load
duke
parents:
diff changeset
    66
    public static final String CESSATION_OF_OPERATION
90ce3da70b43 Initial load
duke
parents:
diff changeset
    67
                                   = "cessation_of_operation";
90ce3da70b43 Initial load
duke
parents:
diff changeset
    68
    public static final String CERTIFICATE_HOLD = "certificate_hold";
90ce3da70b43 Initial load
duke
parents:
diff changeset
    69
    public static final String PRIVILEGE_WITHDRAWN = "privilege_withdrawn";
90ce3da70b43 Initial load
duke
parents:
diff changeset
    70
    public static final String AA_COMPROMISE = "aa_compromise";
90ce3da70b43 Initial load
duke
parents:
diff changeset
    71
32649
2ee9017c7597 8136583: Core libraries should use blessed modifier order
martin
parents: 29917
diff changeset
    72
    private static final String[] NAMES = {
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    73
        UNUSED,
90ce3da70b43 Initial load
duke
parents:
diff changeset
    74
        KEY_COMPROMISE,
90ce3da70b43 Initial load
duke
parents:
diff changeset
    75
        CA_COMPROMISE,
90ce3da70b43 Initial load
duke
parents:
diff changeset
    76
        AFFILIATION_CHANGED,
90ce3da70b43 Initial load
duke
parents:
diff changeset
    77
        SUPERSEDED,
90ce3da70b43 Initial load
duke
parents:
diff changeset
    78
        CESSATION_OF_OPERATION,
90ce3da70b43 Initial load
duke
parents:
diff changeset
    79
        CERTIFICATE_HOLD,
90ce3da70b43 Initial load
duke
parents:
diff changeset
    80
        PRIVILEGE_WITHDRAWN,
90ce3da70b43 Initial load
duke
parents:
diff changeset
    81
        AA_COMPROMISE,
90ce3da70b43 Initial load
duke
parents:
diff changeset
    82
    };
90ce3da70b43 Initial load
duke
parents:
diff changeset
    83
90ce3da70b43 Initial load
duke
parents:
diff changeset
    84
    private static int name2Index(String name) throws IOException {
90ce3da70b43 Initial load
duke
parents:
diff changeset
    85
        for( int i=0; i<NAMES.length; i++ ) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
    86
            if( NAMES[i].equalsIgnoreCase(name) ) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
    87
                return i;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    88
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
    89
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
    90
        throw new IOException("Name not recognized by ReasonFlags");
90ce3da70b43 Initial load
duke
parents:
diff changeset
    91
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
    92
90ce3da70b43 Initial load
duke
parents:
diff changeset
    93
    // Private data members
90ce3da70b43 Initial load
duke
parents:
diff changeset
    94
    private boolean[] bitString;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    95
90ce3da70b43 Initial load
duke
parents:
diff changeset
    96
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
    97
     * Check if bit is set.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    98
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
    99
     * @param position the position in the bit string to check.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   100
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   101
    private boolean isSet(int position) {
29917
5edfc7a4ac68 8068720: Better certificate options checking
igerasim
parents: 25859
diff changeset
   102
        return (position < bitString.length) &&
5edfc7a4ac68 8068720: Better certificate options checking
igerasim
parents: 25859
diff changeset
   103
                bitString[position];
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   104
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   105
90ce3da70b43 Initial load
duke
parents:
diff changeset
   106
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   107
     * Set the bit at the specified position.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   108
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   109
    private void set(int position, boolean val) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   110
        // enlarge bitString if necessary
90ce3da70b43 Initial load
duke
parents:
diff changeset
   111
        if (position >= bitString.length) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   112
            boolean[] tmp = new boolean[position+1];
90ce3da70b43 Initial load
duke
parents:
diff changeset
   113
            System.arraycopy(bitString, 0, tmp, 0, bitString.length);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   114
            bitString = tmp;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   115
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   116
        bitString[position] = val;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   117
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   118
90ce3da70b43 Initial load
duke
parents:
diff changeset
   119
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   120
     * Create a ReasonFlags with the passed bit settings.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   121
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   122
     * @param reasons the bits to be set for the ReasonFlags.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   123
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   124
    public ReasonFlags(byte[] reasons) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   125
        bitString = new BitArray(reasons.length*8, reasons).toBooleanArray();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   126
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   127
90ce3da70b43 Initial load
duke
parents:
diff changeset
   128
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   129
     * Create a ReasonFlags with the passed bit settings.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   130
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   131
     * @param reasons the bits to be set for the ReasonFlags.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   132
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   133
    public ReasonFlags(boolean[] reasons) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   134
        this.bitString = reasons;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   135
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   136
90ce3da70b43 Initial load
duke
parents:
diff changeset
   137
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   138
     * Create a ReasonFlags with the passed bit settings.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   139
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   140
     * @param reasons the bits to be set for the ReasonFlags.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   141
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   142
    public ReasonFlags(BitArray reasons) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   143
        this.bitString = reasons.toBooleanArray();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   144
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   145
90ce3da70b43 Initial load
duke
parents:
diff changeset
   146
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   147
     * Create the object from the passed DER encoded value.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   148
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   149
     * @param in the DerInputStream to read the ReasonFlags from.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   150
     * @exception IOException on decoding errors.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   151
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   152
    public ReasonFlags(DerInputStream in) throws IOException {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   153
        DerValue derVal = in.getDerValue();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   154
        this.bitString = derVal.getUnalignedBitString(true).toBooleanArray();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   155
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   156
90ce3da70b43 Initial load
duke
parents:
diff changeset
   157
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   158
     * Create the object from the passed DER encoded value.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   159
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   160
     * @param derVal the DerValue decoded from the stream.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   161
     * @exception IOException on decoding errors.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   162
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   163
    public ReasonFlags(DerValue derVal) throws IOException {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   164
        this.bitString = derVal.getUnalignedBitString(true).toBooleanArray();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   165
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   166
90ce3da70b43 Initial load
duke
parents:
diff changeset
   167
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   168
     * Returns the reason flags as a boolean array.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   169
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   170
    public boolean[] getFlags() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   171
        return bitString;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   172
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   173
90ce3da70b43 Initial load
duke
parents:
diff changeset
   174
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   175
     * Set the attribute value.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   176
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   177
    public void set(String name, Object obj) throws IOException {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   178
        if (!(obj instanceof Boolean)) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   179
            throw new IOException("Attribute must be of type Boolean.");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   180
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   181
        boolean val = ((Boolean)obj).booleanValue();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   182
        set(name2Index(name), val);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   183
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   184
90ce3da70b43 Initial load
duke
parents:
diff changeset
   185
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   186
     * Get the attribute value.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   187
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   188
    public Object get(String name) throws IOException {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   189
        return Boolean.valueOf(isSet(name2Index(name)));
90ce3da70b43 Initial load
duke
parents:
diff changeset
   190
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   191
90ce3da70b43 Initial load
duke
parents:
diff changeset
   192
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   193
     * Delete the attribute value.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   194
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   195
    public void delete(String name) throws IOException {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   196
        set(name, Boolean.FALSE);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   197
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   198
90ce3da70b43 Initial load
duke
parents:
diff changeset
   199
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   200
     * Returns a printable representation of the ReasonFlags.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   201
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   202
    public String toString() {
29917
5edfc7a4ac68 8068720: Better certificate options checking
igerasim
parents: 25859
diff changeset
   203
        StringBuilder sb = new StringBuilder("Reason Flags [\n");
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   204
29917
5edfc7a4ac68 8068720: Better certificate options checking
igerasim
parents: 25859
diff changeset
   205
        if (isSet(0)) {
5edfc7a4ac68 8068720: Better certificate options checking
igerasim
parents: 25859
diff changeset
   206
            sb.append("  Unused\n");
5edfc7a4ac68 8068720: Better certificate options checking
igerasim
parents: 25859
diff changeset
   207
        }
5edfc7a4ac68 8068720: Better certificate options checking
igerasim
parents: 25859
diff changeset
   208
        if (isSet(1)) {
5edfc7a4ac68 8068720: Better certificate options checking
igerasim
parents: 25859
diff changeset
   209
            sb.append("  Key Compromise\n");
5edfc7a4ac68 8068720: Better certificate options checking
igerasim
parents: 25859
diff changeset
   210
        }
5edfc7a4ac68 8068720: Better certificate options checking
igerasim
parents: 25859
diff changeset
   211
        if (isSet(2)) {
5edfc7a4ac68 8068720: Better certificate options checking
igerasim
parents: 25859
diff changeset
   212
            sb.append("  CA Compromise\n");
5edfc7a4ac68 8068720: Better certificate options checking
igerasim
parents: 25859
diff changeset
   213
        }
5edfc7a4ac68 8068720: Better certificate options checking
igerasim
parents: 25859
diff changeset
   214
        if (isSet(3)) {
5edfc7a4ac68 8068720: Better certificate options checking
igerasim
parents: 25859
diff changeset
   215
            sb.append("  Affiliation_Changed\n");
5edfc7a4ac68 8068720: Better certificate options checking
igerasim
parents: 25859
diff changeset
   216
        }
5edfc7a4ac68 8068720: Better certificate options checking
igerasim
parents: 25859
diff changeset
   217
        if (isSet(4)) {
5edfc7a4ac68 8068720: Better certificate options checking
igerasim
parents: 25859
diff changeset
   218
            sb.append("  Superseded\n");
5edfc7a4ac68 8068720: Better certificate options checking
igerasim
parents: 25859
diff changeset
   219
        }
5edfc7a4ac68 8068720: Better certificate options checking
igerasim
parents: 25859
diff changeset
   220
        if (isSet(5)) {
5edfc7a4ac68 8068720: Better certificate options checking
igerasim
parents: 25859
diff changeset
   221
            sb.append("  Cessation Of Operation\n");
5edfc7a4ac68 8068720: Better certificate options checking
igerasim
parents: 25859
diff changeset
   222
        }
5edfc7a4ac68 8068720: Better certificate options checking
igerasim
parents: 25859
diff changeset
   223
        if (isSet(6)) {
5edfc7a4ac68 8068720: Better certificate options checking
igerasim
parents: 25859
diff changeset
   224
            sb.append("  Certificate Hold\n");
5edfc7a4ac68 8068720: Better certificate options checking
igerasim
parents: 25859
diff changeset
   225
        }
5edfc7a4ac68 8068720: Better certificate options checking
igerasim
parents: 25859
diff changeset
   226
        if (isSet(7)) {
5edfc7a4ac68 8068720: Better certificate options checking
igerasim
parents: 25859
diff changeset
   227
            sb.append("  Privilege Withdrawn\n");
5edfc7a4ac68 8068720: Better certificate options checking
igerasim
parents: 25859
diff changeset
   228
        }
5edfc7a4ac68 8068720: Better certificate options checking
igerasim
parents: 25859
diff changeset
   229
        if (isSet(8)) {
5edfc7a4ac68 8068720: Better certificate options checking
igerasim
parents: 25859
diff changeset
   230
            sb.append("  AA Compromise\n");
5edfc7a4ac68 8068720: Better certificate options checking
igerasim
parents: 25859
diff changeset
   231
        }
5edfc7a4ac68 8068720: Better certificate options checking
igerasim
parents: 25859
diff changeset
   232
        sb.append("]\n");
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   233
29917
5edfc7a4ac68 8068720: Better certificate options checking
igerasim
parents: 25859
diff changeset
   234
        return sb.toString();
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   235
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   236
90ce3da70b43 Initial load
duke
parents:
diff changeset
   237
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   238
     * Write the extension to the DerOutputStream.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   239
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   240
     * @param out the DerOutputStream to write the extension to.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   241
     * @exception IOException on encoding errors.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   242
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   243
    public void encode(DerOutputStream out) throws IOException {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   244
        out.putTruncatedUnalignedBitString(new BitArray(this.bitString));
90ce3da70b43 Initial load
duke
parents:
diff changeset
   245
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   246
90ce3da70b43 Initial load
duke
parents:
diff changeset
   247
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   248
     * Return an enumeration of names of attributes existing within this
90ce3da70b43 Initial load
duke
parents:
diff changeset
   249
     * attribute.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   250
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   251
    public Enumeration<String> getElements () {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   252
        AttributeNameEnumeration elements = new AttributeNameEnumeration();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   253
        for( int i=0; i<NAMES.length; i++ ) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   254
            elements.addElement(NAMES[i]);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   255
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   256
        return (elements.elements());
90ce3da70b43 Initial load
duke
parents:
diff changeset
   257
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   258
}