< prev index next >

## src/java.base/share/classes/java/security/cert/CertPathValidatorException.java

Print this page

      1 /*
      2  * Copyright (c) 2000, 2019, Oracle and/or its affiliates. All rights reserved.
      3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
      4  *
      5  * This code is free software; you can redistribute it and/or modify it
      6  * under the terms of the GNU General Public License version 2 only, as
      7  * published by the Free Software Foundation.  Oracle designates this
      8  * particular file as subject to the "Classpath" exception as provided
      9  * by Oracle in the LICENSE file that accompanied this code.
     10  *
     11  * This code is distributed in the hope that it will be useful, but WITHOUT
     12  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
     13  * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
     14  * version 2 for more details (a copy is included in the LICENSE file that
     15  * accompanied this code).
     16  *
     17  * You should have received a copy of the GNU General Public License version
     18  * 2 along with this work; if not, write to the Free Software Foundation,
     19  * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
     20  *
     21  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
     22  * or visit www.oracle.com if you need additional information or have any
    212      */
    213     public int getIndex() {
    214         return this.index;
    215     }
    216
    217     /**
    218      * Returns the reason that the validation failed. The reason is
    219      * associated with the index of the certificate returned by
    220      * {@link #getIndex}.
    221      *
    222      * @return the reason that the validation failed, or
    223      *    {@code BasicReason.UNSPECIFIED} if a reason has not been
    224      *    specified
    225      *
    226      * @since 1.7
    227      */
    228     public Reason getReason() {
    229         return this.reason;
    230     }
    231

    232     @java.io.Serial
    233     private void readObject(ObjectInputStream stream)
    234         throws ClassNotFoundException, IOException {
    235         stream.defaultReadObject();
    236         if (reason == null) {
    237             reason = BasicReason.UNSPECIFIED;
    238         }
    239         if (certPath == null && index != -1) {
    240             throw new InvalidObjectException("certpath is null and index != -1");
    241         }
    242         if (index < -1 ||
    243             (certPath != null && index >= certPath.getCertificates().size())) {
    244             throw new InvalidObjectException("index out of range");
    245         }
    246     }
    247
    248     /**
    249      * The reason the validation algorithm failed.
    250      *
    251      * @since 1.7
      1 /*
      2  * Copyright (c) 2000, 2021, Oracle and/or its affiliates. All rights reserved.
      3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
      4  *
      5  * This code is free software; you can redistribute it and/or modify it
      6  * under the terms of the GNU General Public License version 2 only, as
      7  * published by the Free Software Foundation.  Oracle designates this
      8  * particular file as subject to the "Classpath" exception as provided
      9  * by Oracle in the LICENSE file that accompanied this code.
     10  *
     11  * This code is distributed in the hope that it will be useful, but WITHOUT
     12  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
     13  * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
     14  * version 2 for more details (a copy is included in the LICENSE file that
     15  * accompanied this code).
     16  *
     17  * You should have received a copy of the GNU General Public License version
     18  * 2 along with this work; if not, write to the Free Software Foundation,
     19  * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
     20  *
     21  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
     22  * or visit www.oracle.com if you need additional information or have any
    212      */
    213     public int getIndex() {
    214         return this.index;
    215     }
    216
    217     /**
    218      * Returns the reason that the validation failed. The reason is
    219      * associated with the index of the certificate returned by
    220      * {@link #getIndex}.
    221      *
    222      * @return the reason that the validation failed, or
    223      *    {@code BasicReason.UNSPECIFIED} if a reason has not been
    224      *    specified
    225      *
    226      * @since 1.7
    227      */
    228     public Reason getReason() {
    229         return this.reason;
    230     }
    231
    232     /**
    233      * Restores the state of this object from the stream.
    234      *
    235      * @param  stream the {@code ObjectInputStream} from which data is read
    236      * @throws IOException if an I/O error occurs
    237      * @throws ClassNotFoundException if a serialized class cannot be loaded
    238      */
    239     @java.io.Serial
    240     private void readObject(ObjectInputStream stream)
    241         throws ClassNotFoundException, IOException {
    242         stream.defaultReadObject();
    243         if (reason == null) {
    244             reason = BasicReason.UNSPECIFIED;
    245         }
    246         if (certPath == null && index != -1) {
    247             throw new InvalidObjectException("certpath is null and index != -1");
    248         }
    249         if (index < -1 ||
    250             (certPath != null && index >= certPath.getCertificates().size())) {
    251             throw new InvalidObjectException("index out of range");
    252         }
    253     }
    254
    255     /**
    256      * The reason the validation algorithm failed.
    257      *
    258      * @since 1.7

< prev index next >