jdk/src/share/classes/sun/security/x509/InhibitAnyPolicyExtension.java
author jjg
Mon, 15 Aug 2011 11:48:20 -0700
changeset 10336 0bb1999251f8
parent 5506 202f599c92aa
child 25522 10d789df41bb
permissions -rw-r--r--
7064075: Security libraries don't build with javac -Xlint:all,-deprecation -Werror Reviewed-by: xuelei, mullan Contributed-by: alexandre.boulgakov@oracle.com
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
     1
/*
10336
0bb1999251f8 7064075: Security libraries don't build with javac -Xlint:all,-deprecation -Werror
jjg
parents: 5506
diff changeset
     2
 * Copyright (c) 2000, 2011, 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.OutputStream;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    30
import java.util.Enumeration;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    31
90ce3da70b43 Initial load
duke
parents:
diff changeset
    32
import sun.security.util.Debug;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    33
import sun.security.util.DerOutputStream;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    34
import sun.security.util.DerValue;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    35
import sun.security.util.ObjectIdentifier;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    36
90ce3da70b43 Initial load
duke
parents:
diff changeset
    37
/**
90ce3da70b43 Initial load
duke
parents:
diff changeset
    38
 * This class represents the Inhibit Any-Policy Extension.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    39
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
    40
 * <p>The inhibit any-policy extension can be used in certificates issued
90ce3da70b43 Initial load
duke
parents:
diff changeset
    41
 * to CAs. The inhibit any-policy indicates that the special any-policy
90ce3da70b43 Initial load
duke
parents:
diff changeset
    42
 * OID, with the value {2 5 29 32 0}, is not considered an explicit
90ce3da70b43 Initial load
duke
parents:
diff changeset
    43
 * match for other certificate policies.  The value indicates the number
90ce3da70b43 Initial load
duke
parents:
diff changeset
    44
 * of additional certificates that may appear in the path before any-
90ce3da70b43 Initial load
duke
parents:
diff changeset
    45
 * policy is no longer permitted.  For example, a value of one indicates
90ce3da70b43 Initial load
duke
parents:
diff changeset
    46
 * that any-policy may be processed in certificates issued by the sub-
90ce3da70b43 Initial load
duke
parents:
diff changeset
    47
 * ject of this certificate, but not in additional certificates in the
90ce3da70b43 Initial load
duke
parents:
diff changeset
    48
 * path.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    49
 * <p>
90ce3da70b43 Initial load
duke
parents:
diff changeset
    50
 * This extension MUST be critical.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    51
 * <p>
90ce3da70b43 Initial load
duke
parents:
diff changeset
    52
 * The ASN.1 syntax for this extension is:
90ce3da70b43 Initial load
duke
parents:
diff changeset
    53
 * <code><pre>
90ce3da70b43 Initial load
duke
parents:
diff changeset
    54
 * id-ce-inhibitAnyPolicy OBJECT IDENTIFIER ::=  { id-ce 54 }
90ce3da70b43 Initial load
duke
parents:
diff changeset
    55
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
    56
 * InhibitAnyPolicy ::= SkipCerts
90ce3da70b43 Initial load
duke
parents:
diff changeset
    57
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
    58
 * SkipCerts ::= INTEGER (0..MAX)
90ce3da70b43 Initial load
duke
parents:
diff changeset
    59
 * </pre></code>
90ce3da70b43 Initial load
duke
parents:
diff changeset
    60
 * @author Anne Anderson
90ce3da70b43 Initial load
duke
parents:
diff changeset
    61
 * @see CertAttrSet
90ce3da70b43 Initial load
duke
parents:
diff changeset
    62
 * @see Extension
90ce3da70b43 Initial load
duke
parents:
diff changeset
    63
 */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    64
public class InhibitAnyPolicyExtension extends Extension
90ce3da70b43 Initial load
duke
parents:
diff changeset
    65
implements CertAttrSet<String> {
90ce3da70b43 Initial load
duke
parents:
diff changeset
    66
90ce3da70b43 Initial load
duke
parents:
diff changeset
    67
    private static final Debug debug = Debug.getInstance("certpath");
90ce3da70b43 Initial load
duke
parents:
diff changeset
    68
90ce3da70b43 Initial load
duke
parents:
diff changeset
    69
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
    70
     * Identifier for this attribute, to be used with the
90ce3da70b43 Initial load
duke
parents:
diff changeset
    71
     * get, set, delete methods of Certificate, x509 type.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    72
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    73
    public static final String IDENT = "x509.info.extensions.InhibitAnyPolicy";
90ce3da70b43 Initial load
duke
parents:
diff changeset
    74
90ce3da70b43 Initial load
duke
parents:
diff changeset
    75
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
    76
     * Object identifier for "any-policy"
90ce3da70b43 Initial load
duke
parents:
diff changeset
    77
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    78
    public static ObjectIdentifier AnyPolicy_Id;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    79
    static {
90ce3da70b43 Initial load
duke
parents:
diff changeset
    80
        try {
90ce3da70b43 Initial load
duke
parents:
diff changeset
    81
            AnyPolicy_Id = new ObjectIdentifier("2.5.29.32.0");
90ce3da70b43 Initial load
duke
parents:
diff changeset
    82
        } catch (IOException ioe) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
    83
            // Should not happen
90ce3da70b43 Initial load
duke
parents:
diff changeset
    84
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
    85
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
    86
90ce3da70b43 Initial load
duke
parents:
diff changeset
    87
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
    88
     * Attribute names.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    89
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    90
    public static final String NAME = "InhibitAnyPolicy";
90ce3da70b43 Initial load
duke
parents:
diff changeset
    91
    public static final String SKIP_CERTS = "skip_certs";
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 int skipCerts = Integer.MAX_VALUE;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    95
90ce3da70b43 Initial load
duke
parents:
diff changeset
    96
    // Encode this extension value
90ce3da70b43 Initial load
duke
parents:
diff changeset
    97
    private void encodeThis() throws IOException {
90ce3da70b43 Initial load
duke
parents:
diff changeset
    98
        DerOutputStream out = new DerOutputStream();
90ce3da70b43 Initial load
duke
parents:
diff changeset
    99
        out.putInteger(skipCerts);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   100
        this.extensionValue = out.toByteArray();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   101
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   102
90ce3da70b43 Initial load
duke
parents:
diff changeset
   103
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   104
     * Default constructor for this object.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   105
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   106
     * @param skipCerts specifies the depth of the certification path.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   107
     *                  Use value of -1 to request unlimited depth.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   108
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   109
    public InhibitAnyPolicyExtension(int skipCerts) throws IOException {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   110
        if (skipCerts < -1)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   111
            throw new IOException("Invalid value for skipCerts");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   112
        if (skipCerts == -1)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   113
            this.skipCerts = Integer.MAX_VALUE;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   114
        else
90ce3da70b43 Initial load
duke
parents:
diff changeset
   115
            this.skipCerts = skipCerts;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   116
        this.extensionId = PKIXExtensions.InhibitAnyPolicy_Id;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   117
        critical = true;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   118
        encodeThis();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   119
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   120
90ce3da70b43 Initial load
duke
parents:
diff changeset
   121
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   122
     * Create the extension from the passed DER encoded value of the same.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   123
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   124
     * @param critical criticality flag to use.  Must be true for this
90ce3da70b43 Initial load
duke
parents:
diff changeset
   125
     *                 extension.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   126
     * @param value a byte array holding the DER-encoded extension value.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   127
     * @exception ClassCastException if value is not an array of bytes
90ce3da70b43 Initial load
duke
parents:
diff changeset
   128
     * @exception IOException on error.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   129
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   130
    public InhibitAnyPolicyExtension(Boolean critical, Object value)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   131
        throws IOException {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   132
90ce3da70b43 Initial load
duke
parents:
diff changeset
   133
        this.extensionId = PKIXExtensions.InhibitAnyPolicy_Id;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   134
90ce3da70b43 Initial load
duke
parents:
diff changeset
   135
        if (!critical.booleanValue())
90ce3da70b43 Initial load
duke
parents:
diff changeset
   136
            throw new IOException("Criticality cannot be false for " +
90ce3da70b43 Initial load
duke
parents:
diff changeset
   137
                                  "InhibitAnyPolicy");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   138
        this.critical = critical.booleanValue();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   139
90ce3da70b43 Initial load
duke
parents:
diff changeset
   140
        this.extensionValue = (byte[]) value;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   141
        DerValue val = new DerValue(this.extensionValue);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   142
        if (val.tag != DerValue.tag_Integer)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   143
            throw new IOException("Invalid encoding of InhibitAnyPolicy: "
90ce3da70b43 Initial load
duke
parents:
diff changeset
   144
                                  + "data not integer");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   145
90ce3da70b43 Initial load
duke
parents:
diff changeset
   146
        if (val.data == null)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   147
            throw new IOException("Invalid encoding of InhibitAnyPolicy: "
90ce3da70b43 Initial load
duke
parents:
diff changeset
   148
                                  + "null data");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   149
        int skipCertsValue = val.getInteger();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   150
        if (skipCertsValue < -1)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   151
            throw new IOException("Invalid value for skipCerts");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   152
        if (skipCertsValue == -1) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   153
            this.skipCerts = Integer.MAX_VALUE;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   154
        } else {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   155
            this.skipCerts = skipCertsValue;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   156
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   157
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   158
90ce3da70b43 Initial load
duke
parents:
diff changeset
   159
     /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   160
      * Return user readable form of extension.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   161
      */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   162
     public String toString() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   163
         String s = super.toString() + "InhibitAnyPolicy: " + skipCerts + "\n";
90ce3da70b43 Initial load
duke
parents:
diff changeset
   164
         return s;
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
      * Encode this extension value to the output stream.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   169
      *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   170
      * @param out the DerOutputStream to encode the extension to.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   171
      */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   172
     public void encode(OutputStream out) throws IOException {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   173
         DerOutputStream tmp = new DerOutputStream();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   174
         if (extensionValue == null) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   175
             this.extensionId = PKIXExtensions.InhibitAnyPolicy_Id;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   176
             critical = true;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   177
             encodeThis();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   178
         }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   179
         super.encode(tmp);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   180
90ce3da70b43 Initial load
duke
parents:
diff changeset
   181
         out.write(tmp.toByteArray());
90ce3da70b43 Initial load
duke
parents:
diff changeset
   182
     }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   183
90ce3da70b43 Initial load
duke
parents:
diff changeset
   184
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   185
     * Set the attribute value.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   186
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   187
     * @param name name of attribute to set. Must be SKIP_CERTS.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   188
     * @param obj  value to which attribute is to be set.  Must be Integer
90ce3da70b43 Initial load
duke
parents:
diff changeset
   189
     *             type.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   190
     * @throws IOException on error
90ce3da70b43 Initial load
duke
parents:
diff changeset
   191
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   192
    public void set(String name, Object obj) throws IOException {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   193
        if (name.equalsIgnoreCase(SKIP_CERTS)) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   194
            if (!(obj instanceof Integer))
90ce3da70b43 Initial load
duke
parents:
diff changeset
   195
                throw new IOException("Attribute value should be of type Integer.");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   196
            int skipCertsValue = ((Integer)obj).intValue();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   197
            if (skipCertsValue < -1)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   198
                throw new IOException("Invalid value for skipCerts");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   199
            if (skipCertsValue == -1) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   200
                skipCerts = Integer.MAX_VALUE;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   201
            } else {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   202
                skipCerts = skipCertsValue;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   203
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   204
        } else
90ce3da70b43 Initial load
duke
parents:
diff changeset
   205
            throw new IOException("Attribute name not recognized by " +
90ce3da70b43 Initial load
duke
parents:
diff changeset
   206
                                  "CertAttrSet:InhibitAnyPolicy.");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   207
        encodeThis();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   208
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   209
90ce3da70b43 Initial load
duke
parents:
diff changeset
   210
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   211
     * Get the attribute value.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   212
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   213
     * @param name name of attribute to get.  Must be SKIP_CERTS.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   214
     * @returns value of the attribute.  In this case it will be of type
90ce3da70b43 Initial load
duke
parents:
diff changeset
   215
     *          Integer.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   216
     * @throws IOException on error
90ce3da70b43 Initial load
duke
parents:
diff changeset
   217
     */
10336
0bb1999251f8 7064075: Security libraries don't build with javac -Xlint:all,-deprecation -Werror
jjg
parents: 5506
diff changeset
   218
    public Integer get(String name) throws IOException {
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   219
        if (name.equalsIgnoreCase(SKIP_CERTS))
90ce3da70b43 Initial load
duke
parents:
diff changeset
   220
            return (new Integer(skipCerts));
90ce3da70b43 Initial load
duke
parents:
diff changeset
   221
        else
90ce3da70b43 Initial load
duke
parents:
diff changeset
   222
            throw new IOException("Attribute name not recognized by " +
90ce3da70b43 Initial load
duke
parents:
diff changeset
   223
                                  "CertAttrSet:InhibitAnyPolicy.");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   224
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   225
90ce3da70b43 Initial load
duke
parents:
diff changeset
   226
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   227
     * Delete the attribute value.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   228
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   229
     * @param name name of attribute to delete. Must be SKIP_CERTS.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   230
     * @throws IOException on error.  In this case, IOException will always be
90ce3da70b43 Initial load
duke
parents:
diff changeset
   231
     *                     thrown, because the only attribute, SKIP_CERTS, is
90ce3da70b43 Initial load
duke
parents:
diff changeset
   232
     *                     required.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   233
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   234
    public void delete(String name) throws IOException {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   235
        if (name.equalsIgnoreCase(SKIP_CERTS))
90ce3da70b43 Initial load
duke
parents:
diff changeset
   236
            throw new IOException("Attribute " + SKIP_CERTS +
90ce3da70b43 Initial load
duke
parents:
diff changeset
   237
                                  " may not be deleted.");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   238
        else
90ce3da70b43 Initial load
duke
parents:
diff changeset
   239
            throw new IOException("Attribute name not recognized by " +
90ce3da70b43 Initial load
duke
parents:
diff changeset
   240
                                  "CertAttrSet:InhibitAnyPolicy.");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   241
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   242
90ce3da70b43 Initial load
duke
parents:
diff changeset
   243
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   244
     * Return an enumeration of names of attributes existing within this
90ce3da70b43 Initial load
duke
parents:
diff changeset
   245
     * attribute.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   246
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   247
     * @returns enumeration of elements
90ce3da70b43 Initial load
duke
parents:
diff changeset
   248
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   249
    public Enumeration<String> getElements() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   250
        AttributeNameEnumeration elements = new AttributeNameEnumeration();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   251
        elements.addElement(SKIP_CERTS);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   252
        return (elements.elements());
90ce3da70b43 Initial load
duke
parents:
diff changeset
   253
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   254
90ce3da70b43 Initial load
duke
parents:
diff changeset
   255
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   256
     * Return the name of this attribute.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   257
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   258
     * @returns name of attribute.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   259
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   260
    public String getName() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   261
        return (NAME);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   262
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   263
}