jdk/src/share/classes/java/security/cert/CertPathValidatorException.java
author xuelei
Wed, 20 Jan 2010 21:38:37 +0800
changeset 4807 2521b7dcf505
parent 4512 b3ed7ecf8f55
child 5506 202f599c92aa
permissions -rw-r--r--
6862064: incorrect implementation of PKIXParameters.clone() Reviewed-by: weijun, mullan
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
     1
/*
1238
6d1f4b722acd 6465942: Add problem identification facility to the CertPathValidator framework
mullan
parents: 2
diff changeset
     2
 * Copyright 2000-2008 Sun Microsystems, Inc.  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
90ce3da70b43 Initial load
duke
parents:
diff changeset
     7
 * published by the Free Software Foundation.  Sun designates this
90ce3da70b43 Initial load
duke
parents:
diff changeset
     8
 * particular file as subject to the "Classpath" exception as provided
90ce3da70b43 Initial load
duke
parents:
diff changeset
     9
 * by Sun in the LICENSE file that accompanied this code.
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
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
    21
 * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
90ce3da70b43 Initial load
duke
parents:
diff changeset
    22
 * CA 95054 USA or visit www.sun.com if you need additional information or
90ce3da70b43 Initial load
duke
parents:
diff changeset
    23
 * have any questions.
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 java.security.cert;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    27
1238
6d1f4b722acd 6465942: Add problem identification facility to the CertPathValidator framework
mullan
parents: 2
diff changeset
    28
import java.io.InvalidObjectException;
6d1f4b722acd 6465942: Add problem identification facility to the CertPathValidator framework
mullan
parents: 2
diff changeset
    29
import java.io.IOException;
6d1f4b722acd 6465942: Add problem identification facility to the CertPathValidator framework
mullan
parents: 2
diff changeset
    30
import java.io.ObjectInputStream;
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    31
import java.security.GeneralSecurityException;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    32
90ce3da70b43 Initial load
duke
parents:
diff changeset
    33
/**
90ce3da70b43 Initial load
duke
parents:
diff changeset
    34
 * An exception indicating one of a variety of problems encountered when
90ce3da70b43 Initial load
duke
parents:
diff changeset
    35
 * validating a certification path.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    36
 * <p>
90ce3da70b43 Initial load
duke
parents:
diff changeset
    37
 * A <code>CertPathValidatorException</code> provides support for wrapping
90ce3da70b43 Initial load
duke
parents:
diff changeset
    38
 * exceptions. The {@link #getCause getCause} method returns the throwable,
90ce3da70b43 Initial load
duke
parents:
diff changeset
    39
 * if any, that caused this exception to be thrown.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    40
 * <p>
90ce3da70b43 Initial load
duke
parents:
diff changeset
    41
 * A <code>CertPathValidatorException</code> may also include the
1238
6d1f4b722acd 6465942: Add problem identification facility to the CertPathValidator framework
mullan
parents: 2
diff changeset
    42
 * certification path that was being validated when the exception was thrown,
6d1f4b722acd 6465942: Add problem identification facility to the CertPathValidator framework
mullan
parents: 2
diff changeset
    43
 * the index of the certificate in the certification path that caused the
6d1f4b722acd 6465942: Add problem identification facility to the CertPathValidator framework
mullan
parents: 2
diff changeset
    44
 * exception to be thrown, and the reason that caused the failure. Use the
6d1f4b722acd 6465942: Add problem identification facility to the CertPathValidator framework
mullan
parents: 2
diff changeset
    45
 * {@link #getCertPath getCertPath}, {@link #getIndex getIndex}, and
6d1f4b722acd 6465942: Add problem identification facility to the CertPathValidator framework
mullan
parents: 2
diff changeset
    46
 * {@link #getReason getReason} methods to retrieve this information.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    47
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
    48
 * <p>
90ce3da70b43 Initial load
duke
parents:
diff changeset
    49
 * <b>Concurrent Access</b>
90ce3da70b43 Initial load
duke
parents:
diff changeset
    50
 * <p>
90ce3da70b43 Initial load
duke
parents:
diff changeset
    51
 * Unless otherwise specified, the methods defined in this class are not
90ce3da70b43 Initial load
duke
parents:
diff changeset
    52
 * thread-safe. Multiple threads that need to access a single
90ce3da70b43 Initial load
duke
parents:
diff changeset
    53
 * object concurrently should synchronize amongst themselves and
90ce3da70b43 Initial load
duke
parents:
diff changeset
    54
 * provide the necessary locking. Multiple threads each manipulating
90ce3da70b43 Initial load
duke
parents:
diff changeset
    55
 * separate objects need not synchronize.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    56
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
    57
 * @see CertPathValidator
90ce3da70b43 Initial load
duke
parents:
diff changeset
    58
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
    59
 * @since       1.4
90ce3da70b43 Initial load
duke
parents:
diff changeset
    60
 * @author      Yassir Elley
90ce3da70b43 Initial load
duke
parents:
diff changeset
    61
 */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    62
public class CertPathValidatorException extends GeneralSecurityException {
90ce3da70b43 Initial load
duke
parents:
diff changeset
    63
90ce3da70b43 Initial load
duke
parents:
diff changeset
    64
    private static final long serialVersionUID = -3083180014971893139L;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    65
90ce3da70b43 Initial load
duke
parents:
diff changeset
    66
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
    67
     * @serial the index of the certificate in the certification path
90ce3da70b43 Initial load
duke
parents:
diff changeset
    68
     * that caused the exception to be thrown
90ce3da70b43 Initial load
duke
parents:
diff changeset
    69
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    70
    private int index = -1;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    71
90ce3da70b43 Initial load
duke
parents:
diff changeset
    72
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
    73
     * @serial the <code>CertPath</code> that was being validated when
90ce3da70b43 Initial load
duke
parents:
diff changeset
    74
     * the exception was thrown
90ce3da70b43 Initial load
duke
parents:
diff changeset
    75
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    76
    private CertPath certPath;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    77
90ce3da70b43 Initial load
duke
parents:
diff changeset
    78
    /**
1238
6d1f4b722acd 6465942: Add problem identification facility to the CertPathValidator framework
mullan
parents: 2
diff changeset
    79
     * @serial the reason the validation failed
6d1f4b722acd 6465942: Add problem identification facility to the CertPathValidator framework
mullan
parents: 2
diff changeset
    80
     */
6d1f4b722acd 6465942: Add problem identification facility to the CertPathValidator framework
mullan
parents: 2
diff changeset
    81
    private Reason reason = BasicReason.UNSPECIFIED;
6d1f4b722acd 6465942: Add problem identification facility to the CertPathValidator framework
mullan
parents: 2
diff changeset
    82
6d1f4b722acd 6465942: Add problem identification facility to the CertPathValidator framework
mullan
parents: 2
diff changeset
    83
    /**
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    84
     * Creates a <code>CertPathValidatorException</code> with
90ce3da70b43 Initial load
duke
parents:
diff changeset
    85
     * no detail message.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    86
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    87
    public CertPathValidatorException() {
1238
6d1f4b722acd 6465942: Add problem identification facility to the CertPathValidator framework
mullan
parents: 2
diff changeset
    88
        this(null, null);
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    89
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
    90
90ce3da70b43 Initial load
duke
parents:
diff changeset
    91
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
    92
     * Creates a <code>CertPathValidatorException</code> with the given
90ce3da70b43 Initial load
duke
parents:
diff changeset
    93
     * detail message. A detail message is a <code>String</code> that
90ce3da70b43 Initial load
duke
parents:
diff changeset
    94
     * describes this particular exception.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    95
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
    96
     * @param msg the detail message
90ce3da70b43 Initial load
duke
parents:
diff changeset
    97
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    98
    public CertPathValidatorException(String msg) {
1238
6d1f4b722acd 6465942: Add problem identification facility to the CertPathValidator framework
mullan
parents: 2
diff changeset
    99
        this(msg, null);
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   100
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   101
90ce3da70b43 Initial load
duke
parents:
diff changeset
   102
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   103
     * Creates a <code>CertPathValidatorException</code> that wraps the
90ce3da70b43 Initial load
duke
parents:
diff changeset
   104
     * specified throwable. This allows any exception to be converted into a
90ce3da70b43 Initial load
duke
parents:
diff changeset
   105
     * <code>CertPathValidatorException</code>, while retaining information
90ce3da70b43 Initial load
duke
parents:
diff changeset
   106
     * about the wrapped exception, which may be useful for debugging. The
90ce3da70b43 Initial load
duke
parents:
diff changeset
   107
     * detail message is set to (<code>cause==null ? null : cause.toString()
90ce3da70b43 Initial load
duke
parents:
diff changeset
   108
     * </code>) (which typically contains the class and detail message of
90ce3da70b43 Initial load
duke
parents:
diff changeset
   109
     * cause).
90ce3da70b43 Initial load
duke
parents:
diff changeset
   110
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   111
     * @param cause the cause (which is saved for later retrieval by the
90ce3da70b43 Initial load
duke
parents:
diff changeset
   112
     * {@link #getCause getCause()} method). (A <code>null</code> value is
90ce3da70b43 Initial load
duke
parents:
diff changeset
   113
     * permitted, and indicates that the cause is nonexistent or unknown.)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   114
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   115
    public CertPathValidatorException(Throwable cause) {
1569
54e1de48703e 6765046: CertPathValidatorException(Throwable).getMessage() always returns null since b37
mullan
parents: 1238
diff changeset
   116
        this((cause == null ? null : cause.toString()), cause);
2
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
     * Creates a <code>CertPathValidatorException</code> with the specified
90ce3da70b43 Initial load
duke
parents:
diff changeset
   121
     * detail message and cause.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   122
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   123
     * @param msg the detail message
90ce3da70b43 Initial load
duke
parents:
diff changeset
   124
     * @param cause the cause (which is saved for later retrieval by the
90ce3da70b43 Initial load
duke
parents:
diff changeset
   125
     * {@link #getCause getCause()} method). (A <code>null</code> value is
90ce3da70b43 Initial load
duke
parents:
diff changeset
   126
     * permitted, and indicates that the cause is nonexistent or unknown.)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   127
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   128
    public CertPathValidatorException(String msg, Throwable cause) {
1238
6d1f4b722acd 6465942: Add problem identification facility to the CertPathValidator framework
mullan
parents: 2
diff changeset
   129
        this(msg, cause, null, -1);
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   130
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   131
90ce3da70b43 Initial load
duke
parents:
diff changeset
   132
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   133
     * Creates a <code>CertPathValidatorException</code> with the specified
90ce3da70b43 Initial load
duke
parents:
diff changeset
   134
     * detail message, cause, certification path, and index.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   135
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   136
     * @param msg the detail message (or <code>null</code> if none)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   137
     * @param cause the cause (or <code>null</code> if none)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   138
     * @param certPath the certification path that was in the process of
90ce3da70b43 Initial load
duke
parents:
diff changeset
   139
     * being validated when the error was encountered
90ce3da70b43 Initial load
duke
parents:
diff changeset
   140
     * @param index the index of the certificate in the certification path
90ce3da70b43 Initial load
duke
parents:
diff changeset
   141
     * that caused the error (or -1 if not applicable). Note that
90ce3da70b43 Initial load
duke
parents:
diff changeset
   142
     * the list of certificates in a <code>CertPath</code> is zero based.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   143
     * @throws IndexOutOfBoundsException if the index is out of range
90ce3da70b43 Initial load
duke
parents:
diff changeset
   144
     * <code>(index < -1 || (certPath != null && index >=
90ce3da70b43 Initial load
duke
parents:
diff changeset
   145
     * certPath.getCertificates().size())</code>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   146
     * @throws IllegalArgumentException if <code>certPath</code> is
90ce3da70b43 Initial load
duke
parents:
diff changeset
   147
     * <code>null</code> and <code>index</code> is not -1
90ce3da70b43 Initial load
duke
parents:
diff changeset
   148
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   149
    public CertPathValidatorException(String msg, Throwable cause,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   150
            CertPath certPath, int index) {
1238
6d1f4b722acd 6465942: Add problem identification facility to the CertPathValidator framework
mullan
parents: 2
diff changeset
   151
        this(msg, cause, certPath, index, BasicReason.UNSPECIFIED);
6d1f4b722acd 6465942: Add problem identification facility to the CertPathValidator framework
mullan
parents: 2
diff changeset
   152
    }
6d1f4b722acd 6465942: Add problem identification facility to the CertPathValidator framework
mullan
parents: 2
diff changeset
   153
6d1f4b722acd 6465942: Add problem identification facility to the CertPathValidator framework
mullan
parents: 2
diff changeset
   154
    /**
6d1f4b722acd 6465942: Add problem identification facility to the CertPathValidator framework
mullan
parents: 2
diff changeset
   155
     * Creates a <code>CertPathValidatorException</code> with the specified
6d1f4b722acd 6465942: Add problem identification facility to the CertPathValidator framework
mullan
parents: 2
diff changeset
   156
     * detail message, cause, certification path, index, and reason.
6d1f4b722acd 6465942: Add problem identification facility to the CertPathValidator framework
mullan
parents: 2
diff changeset
   157
     *
6d1f4b722acd 6465942: Add problem identification facility to the CertPathValidator framework
mullan
parents: 2
diff changeset
   158
     * @param msg the detail message (or <code>null</code> if none)
6d1f4b722acd 6465942: Add problem identification facility to the CertPathValidator framework
mullan
parents: 2
diff changeset
   159
     * @param cause the cause (or <code>null</code> if none)
6d1f4b722acd 6465942: Add problem identification facility to the CertPathValidator framework
mullan
parents: 2
diff changeset
   160
     * @param certPath the certification path that was in the process of
6d1f4b722acd 6465942: Add problem identification facility to the CertPathValidator framework
mullan
parents: 2
diff changeset
   161
     * being validated when the error was encountered
6d1f4b722acd 6465942: Add problem identification facility to the CertPathValidator framework
mullan
parents: 2
diff changeset
   162
     * @param index the index of the certificate in the certification path
6d1f4b722acd 6465942: Add problem identification facility to the CertPathValidator framework
mullan
parents: 2
diff changeset
   163
     * that caused the error (or -1 if not applicable). Note that
6d1f4b722acd 6465942: Add problem identification facility to the CertPathValidator framework
mullan
parents: 2
diff changeset
   164
     * the list of certificates in a <code>CertPath</code> is zero based.
6d1f4b722acd 6465942: Add problem identification facility to the CertPathValidator framework
mullan
parents: 2
diff changeset
   165
     * @param reason the reason the validation failed
6d1f4b722acd 6465942: Add problem identification facility to the CertPathValidator framework
mullan
parents: 2
diff changeset
   166
     * @throws IndexOutOfBoundsException if the index is out of range
6d1f4b722acd 6465942: Add problem identification facility to the CertPathValidator framework
mullan
parents: 2
diff changeset
   167
     * <code>(index < -1 || (certPath != null && index >=
6d1f4b722acd 6465942: Add problem identification facility to the CertPathValidator framework
mullan
parents: 2
diff changeset
   168
     * certPath.getCertificates().size())</code>
6d1f4b722acd 6465942: Add problem identification facility to the CertPathValidator framework
mullan
parents: 2
diff changeset
   169
     * @throws IllegalArgumentException if <code>certPath</code> is
6d1f4b722acd 6465942: Add problem identification facility to the CertPathValidator framework
mullan
parents: 2
diff changeset
   170
     * <code>null</code> and <code>index</code> is not -1
6d1f4b722acd 6465942: Add problem identification facility to the CertPathValidator framework
mullan
parents: 2
diff changeset
   171
     * @throws NullPointerException if <code>reason</code> is <code>null</code>
6d1f4b722acd 6465942: Add problem identification facility to the CertPathValidator framework
mullan
parents: 2
diff changeset
   172
     *
6d1f4b722acd 6465942: Add problem identification facility to the CertPathValidator framework
mullan
parents: 2
diff changeset
   173
     * @since 1.7
6d1f4b722acd 6465942: Add problem identification facility to the CertPathValidator framework
mullan
parents: 2
diff changeset
   174
     */
6d1f4b722acd 6465942: Add problem identification facility to the CertPathValidator framework
mullan
parents: 2
diff changeset
   175
    public CertPathValidatorException(String msg, Throwable cause,
6d1f4b722acd 6465942: Add problem identification facility to the CertPathValidator framework
mullan
parents: 2
diff changeset
   176
            CertPath certPath, int index, Reason reason) {
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   177
        super(msg, cause);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   178
        if (certPath == null && index != -1) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   179
            throw new IllegalArgumentException();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   180
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   181
        if (index < -1 ||
90ce3da70b43 Initial load
duke
parents:
diff changeset
   182
            (certPath != null && index >= certPath.getCertificates().size())) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   183
            throw new IndexOutOfBoundsException();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   184
        }
1238
6d1f4b722acd 6465942: Add problem identification facility to the CertPathValidator framework
mullan
parents: 2
diff changeset
   185
        if (reason == null) {
6d1f4b722acd 6465942: Add problem identification facility to the CertPathValidator framework
mullan
parents: 2
diff changeset
   186
            throw new NullPointerException("reason can't be null");
6d1f4b722acd 6465942: Add problem identification facility to the CertPathValidator framework
mullan
parents: 2
diff changeset
   187
        }
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   188
        this.certPath = certPath;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   189
        this.index = index;
1238
6d1f4b722acd 6465942: Add problem identification facility to the CertPathValidator framework
mullan
parents: 2
diff changeset
   190
        this.reason = reason;
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   191
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   192
90ce3da70b43 Initial load
duke
parents:
diff changeset
   193
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   194
     * Returns the certification path that was being validated when
90ce3da70b43 Initial load
duke
parents:
diff changeset
   195
     * the exception was thrown.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   196
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   197
     * @return the <code>CertPath</code> that was being validated when
90ce3da70b43 Initial load
duke
parents:
diff changeset
   198
     * the exception was thrown (or <code>null</code> if not specified)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   199
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   200
    public CertPath getCertPath() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   201
        return this.certPath;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   202
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   203
90ce3da70b43 Initial load
duke
parents:
diff changeset
   204
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   205
     * Returns the index of the certificate in the certification path
90ce3da70b43 Initial load
duke
parents:
diff changeset
   206
     * that caused the exception to be thrown. Note that the list of
90ce3da70b43 Initial load
duke
parents:
diff changeset
   207
     * certificates in a <code>CertPath</code> is zero based. If no
90ce3da70b43 Initial load
duke
parents:
diff changeset
   208
     * index has been set, -1 is returned.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   209
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   210
     * @return the index that has been set, or -1 if none has been set
90ce3da70b43 Initial load
duke
parents:
diff changeset
   211
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   212
    public int getIndex() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   213
        return this.index;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   214
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   215
1238
6d1f4b722acd 6465942: Add problem identification facility to the CertPathValidator framework
mullan
parents: 2
diff changeset
   216
    /**
6d1f4b722acd 6465942: Add problem identification facility to the CertPathValidator framework
mullan
parents: 2
diff changeset
   217
     * Returns the reason that the validation failed. The reason is
6d1f4b722acd 6465942: Add problem identification facility to the CertPathValidator framework
mullan
parents: 2
diff changeset
   218
     * associated with the index of the certificate returned by
4512
b3ed7ecf8f55 6909563: Javadoc build warnings in rmi, security, management
darcy
parents: 1569
diff changeset
   219
     * {@link #getIndex}.
1238
6d1f4b722acd 6465942: Add problem identification facility to the CertPathValidator framework
mullan
parents: 2
diff changeset
   220
     *
6d1f4b722acd 6465942: Add problem identification facility to the CertPathValidator framework
mullan
parents: 2
diff changeset
   221
     * @return the reason that the validation failed, or
6d1f4b722acd 6465942: Add problem identification facility to the CertPathValidator framework
mullan
parents: 2
diff changeset
   222
     *    <code>BasicReason.UNSPECIFIED</code> if a reason has not been
6d1f4b722acd 6465942: Add problem identification facility to the CertPathValidator framework
mullan
parents: 2
diff changeset
   223
     *    specified
6d1f4b722acd 6465942: Add problem identification facility to the CertPathValidator framework
mullan
parents: 2
diff changeset
   224
     *
6d1f4b722acd 6465942: Add problem identification facility to the CertPathValidator framework
mullan
parents: 2
diff changeset
   225
     * @since 1.7
6d1f4b722acd 6465942: Add problem identification facility to the CertPathValidator framework
mullan
parents: 2
diff changeset
   226
     */
6d1f4b722acd 6465942: Add problem identification facility to the CertPathValidator framework
mullan
parents: 2
diff changeset
   227
    public Reason getReason() {
6d1f4b722acd 6465942: Add problem identification facility to the CertPathValidator framework
mullan
parents: 2
diff changeset
   228
        return this.reason;
6d1f4b722acd 6465942: Add problem identification facility to the CertPathValidator framework
mullan
parents: 2
diff changeset
   229
    }
6d1f4b722acd 6465942: Add problem identification facility to the CertPathValidator framework
mullan
parents: 2
diff changeset
   230
6d1f4b722acd 6465942: Add problem identification facility to the CertPathValidator framework
mullan
parents: 2
diff changeset
   231
    private void readObject(ObjectInputStream stream)
6d1f4b722acd 6465942: Add problem identification facility to the CertPathValidator framework
mullan
parents: 2
diff changeset
   232
        throws ClassNotFoundException, IOException {
6d1f4b722acd 6465942: Add problem identification facility to the CertPathValidator framework
mullan
parents: 2
diff changeset
   233
        stream.defaultReadObject();
6d1f4b722acd 6465942: Add problem identification facility to the CertPathValidator framework
mullan
parents: 2
diff changeset
   234
        if (reason == null) {
6d1f4b722acd 6465942: Add problem identification facility to the CertPathValidator framework
mullan
parents: 2
diff changeset
   235
            reason = BasicReason.UNSPECIFIED;
6d1f4b722acd 6465942: Add problem identification facility to the CertPathValidator framework
mullan
parents: 2
diff changeset
   236
        }
6d1f4b722acd 6465942: Add problem identification facility to the CertPathValidator framework
mullan
parents: 2
diff changeset
   237
        if (certPath == null && index != -1) {
6d1f4b722acd 6465942: Add problem identification facility to the CertPathValidator framework
mullan
parents: 2
diff changeset
   238
            throw new InvalidObjectException("certpath is null and index != -1");
6d1f4b722acd 6465942: Add problem identification facility to the CertPathValidator framework
mullan
parents: 2
diff changeset
   239
        }
6d1f4b722acd 6465942: Add problem identification facility to the CertPathValidator framework
mullan
parents: 2
diff changeset
   240
        if (index < -1 ||
6d1f4b722acd 6465942: Add problem identification facility to the CertPathValidator framework
mullan
parents: 2
diff changeset
   241
            (certPath != null && index >= certPath.getCertificates().size())) {
6d1f4b722acd 6465942: Add problem identification facility to the CertPathValidator framework
mullan
parents: 2
diff changeset
   242
            throw new InvalidObjectException("index out of range");
6d1f4b722acd 6465942: Add problem identification facility to the CertPathValidator framework
mullan
parents: 2
diff changeset
   243
        }
6d1f4b722acd 6465942: Add problem identification facility to the CertPathValidator framework
mullan
parents: 2
diff changeset
   244
    }
6d1f4b722acd 6465942: Add problem identification facility to the CertPathValidator framework
mullan
parents: 2
diff changeset
   245
6d1f4b722acd 6465942: Add problem identification facility to the CertPathValidator framework
mullan
parents: 2
diff changeset
   246
    /**
6d1f4b722acd 6465942: Add problem identification facility to the CertPathValidator framework
mullan
parents: 2
diff changeset
   247
     * The reason the validation algorithm failed.
6d1f4b722acd 6465942: Add problem identification facility to the CertPathValidator framework
mullan
parents: 2
diff changeset
   248
     *
6d1f4b722acd 6465942: Add problem identification facility to the CertPathValidator framework
mullan
parents: 2
diff changeset
   249
     * @since 1.7
6d1f4b722acd 6465942: Add problem identification facility to the CertPathValidator framework
mullan
parents: 2
diff changeset
   250
     */
6d1f4b722acd 6465942: Add problem identification facility to the CertPathValidator framework
mullan
parents: 2
diff changeset
   251
    public static interface Reason extends java.io.Serializable { }
6d1f4b722acd 6465942: Add problem identification facility to the CertPathValidator framework
mullan
parents: 2
diff changeset
   252
6d1f4b722acd 6465942: Add problem identification facility to the CertPathValidator framework
mullan
parents: 2
diff changeset
   253
6d1f4b722acd 6465942: Add problem identification facility to the CertPathValidator framework
mullan
parents: 2
diff changeset
   254
    /**
6d1f4b722acd 6465942: Add problem identification facility to the CertPathValidator framework
mullan
parents: 2
diff changeset
   255
     * The BasicReason enumerates the potential reasons that a certification
6d1f4b722acd 6465942: Add problem identification facility to the CertPathValidator framework
mullan
parents: 2
diff changeset
   256
     * path of any type may be invalid.
6d1f4b722acd 6465942: Add problem identification facility to the CertPathValidator framework
mullan
parents: 2
diff changeset
   257
     *
6d1f4b722acd 6465942: Add problem identification facility to the CertPathValidator framework
mullan
parents: 2
diff changeset
   258
     * @since 1.7
6d1f4b722acd 6465942: Add problem identification facility to the CertPathValidator framework
mullan
parents: 2
diff changeset
   259
     */
6d1f4b722acd 6465942: Add problem identification facility to the CertPathValidator framework
mullan
parents: 2
diff changeset
   260
    public static enum BasicReason implements Reason {
6d1f4b722acd 6465942: Add problem identification facility to the CertPathValidator framework
mullan
parents: 2
diff changeset
   261
        /**
6d1f4b722acd 6465942: Add problem identification facility to the CertPathValidator framework
mullan
parents: 2
diff changeset
   262
         * Unspecified reason.
6d1f4b722acd 6465942: Add problem identification facility to the CertPathValidator framework
mullan
parents: 2
diff changeset
   263
         */
6d1f4b722acd 6465942: Add problem identification facility to the CertPathValidator framework
mullan
parents: 2
diff changeset
   264
        UNSPECIFIED,
6d1f4b722acd 6465942: Add problem identification facility to the CertPathValidator framework
mullan
parents: 2
diff changeset
   265
6d1f4b722acd 6465942: Add problem identification facility to the CertPathValidator framework
mullan
parents: 2
diff changeset
   266
        /**
6d1f4b722acd 6465942: Add problem identification facility to the CertPathValidator framework
mullan
parents: 2
diff changeset
   267
         * The certificate is expired.
6d1f4b722acd 6465942: Add problem identification facility to the CertPathValidator framework
mullan
parents: 2
diff changeset
   268
         */
6d1f4b722acd 6465942: Add problem identification facility to the CertPathValidator framework
mullan
parents: 2
diff changeset
   269
        EXPIRED,
6d1f4b722acd 6465942: Add problem identification facility to the CertPathValidator framework
mullan
parents: 2
diff changeset
   270
6d1f4b722acd 6465942: Add problem identification facility to the CertPathValidator framework
mullan
parents: 2
diff changeset
   271
        /**
6d1f4b722acd 6465942: Add problem identification facility to the CertPathValidator framework
mullan
parents: 2
diff changeset
   272
         * The certificate is not yet valid.
6d1f4b722acd 6465942: Add problem identification facility to the CertPathValidator framework
mullan
parents: 2
diff changeset
   273
         */
6d1f4b722acd 6465942: Add problem identification facility to the CertPathValidator framework
mullan
parents: 2
diff changeset
   274
        NOT_YET_VALID,
6d1f4b722acd 6465942: Add problem identification facility to the CertPathValidator framework
mullan
parents: 2
diff changeset
   275
6d1f4b722acd 6465942: Add problem identification facility to the CertPathValidator framework
mullan
parents: 2
diff changeset
   276
        /**
6d1f4b722acd 6465942: Add problem identification facility to the CertPathValidator framework
mullan
parents: 2
diff changeset
   277
         * The certificate is revoked.
6d1f4b722acd 6465942: Add problem identification facility to the CertPathValidator framework
mullan
parents: 2
diff changeset
   278
         */
6d1f4b722acd 6465942: Add problem identification facility to the CertPathValidator framework
mullan
parents: 2
diff changeset
   279
        REVOKED,
6d1f4b722acd 6465942: Add problem identification facility to the CertPathValidator framework
mullan
parents: 2
diff changeset
   280
6d1f4b722acd 6465942: Add problem identification facility to the CertPathValidator framework
mullan
parents: 2
diff changeset
   281
        /**
6d1f4b722acd 6465942: Add problem identification facility to the CertPathValidator framework
mullan
parents: 2
diff changeset
   282
         * The revocation status of the certificate could not be determined.
6d1f4b722acd 6465942: Add problem identification facility to the CertPathValidator framework
mullan
parents: 2
diff changeset
   283
         */
6d1f4b722acd 6465942: Add problem identification facility to the CertPathValidator framework
mullan
parents: 2
diff changeset
   284
        UNDETERMINED_REVOCATION_STATUS,
6d1f4b722acd 6465942: Add problem identification facility to the CertPathValidator framework
mullan
parents: 2
diff changeset
   285
6d1f4b722acd 6465942: Add problem identification facility to the CertPathValidator framework
mullan
parents: 2
diff changeset
   286
        /**
6d1f4b722acd 6465942: Add problem identification facility to the CertPathValidator framework
mullan
parents: 2
diff changeset
   287
         * The signature is invalid.
6d1f4b722acd 6465942: Add problem identification facility to the CertPathValidator framework
mullan
parents: 2
diff changeset
   288
         */
6d1f4b722acd 6465942: Add problem identification facility to the CertPathValidator framework
mullan
parents: 2
diff changeset
   289
        INVALID_SIGNATURE
6d1f4b722acd 6465942: Add problem identification facility to the CertPathValidator framework
mullan
parents: 2
diff changeset
   290
    }
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   291
}