author | darcy |
Wed, 09 Oct 2019 09:57:41 -0700 | |
changeset 58519 | 6e017b301287 |
parent 57950 | 4612a3cfb927 |
child 58679 | 9c3209ff7550 |
permissions | -rw-r--r-- |
2 | 1 |
/* |
57950
4612a3cfb927
8229999: Apply java.io.Serial annotations to security types in java.base
darcy
parents:
47216
diff
changeset
|
2 |
* Copyright (c) 2002, 2019, Oracle and/or its affiliates. All rights reserved. |
2 | 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 |
|
5506 | 7 |
* published by the Free Software Foundation. Oracle designates this |
2 | 8 |
* particular file as subject to the "Classpath" exception as provided |
5506 | 9 |
* by Oracle in the LICENSE file that accompanied this code. |
2 | 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 |
* |
|
5506 | 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 |
|
23 |
* questions. |
|
2 | 24 |
*/ |
25 |
||
26 |
package sun.security.validator; |
|
27 |
||
28 |
import java.security.cert.*; |
|
29 |
||
30 |
/** |
|
31 |
* ValidatorException thrown by the Validator. It has optional fields that |
|
32 |
* allow better error diagnostics. |
|
33 |
* |
|
34 |
* @author Andreas Sterbenz |
|
35 |
*/ |
|
36 |
public class ValidatorException extends CertificateException { |
|
37 |
||
57950
4612a3cfb927
8229999: Apply java.io.Serial annotations to security types in java.base
darcy
parents:
47216
diff
changeset
|
38 |
@java.io.Serial |
2 | 39 |
private static final long serialVersionUID = -2836879718282292155L; |
40 |
||
32649
2ee9017c7597
8136583: Core libraries should use blessed modifier order
martin
parents:
25859
diff
changeset
|
41 |
public static final Object T_NO_TRUST_ANCHOR = |
2 | 42 |
"No trusted certificate found"; |
43 |
||
32649
2ee9017c7597
8136583: Core libraries should use blessed modifier order
martin
parents:
25859
diff
changeset
|
44 |
public static final Object T_EE_EXTENSIONS = |
2 | 45 |
"End entity certificate extension check failed"; |
46 |
||
32649
2ee9017c7597
8136583: Core libraries should use blessed modifier order
martin
parents:
25859
diff
changeset
|
47 |
public static final Object T_CA_EXTENSIONS = |
2 | 48 |
"CA certificate extension check failed"; |
49 |
||
32649
2ee9017c7597
8136583: Core libraries should use blessed modifier order
martin
parents:
25859
diff
changeset
|
50 |
public static final Object T_CERT_EXPIRED = |
2 | 51 |
"Certificate expired"; |
52 |
||
32649
2ee9017c7597
8136583: Core libraries should use blessed modifier order
martin
parents:
25859
diff
changeset
|
53 |
public static final Object T_SIGNATURE_ERROR = |
2 | 54 |
"Certificate signature validation failed"; |
55 |
||
32649
2ee9017c7597
8136583: Core libraries should use blessed modifier order
martin
parents:
25859
diff
changeset
|
56 |
public static final Object T_NAME_CHAINING = |
2 | 57 |
"Certificate chaining error"; |
58 |
||
32649
2ee9017c7597
8136583: Core libraries should use blessed modifier order
martin
parents:
25859
diff
changeset
|
59 |
public static final Object T_ALGORITHM_DISABLED = |
4190 | 60 |
"Certificate signature algorithm disabled"; |
61 |
||
32649
2ee9017c7597
8136583: Core libraries should use blessed modifier order
martin
parents:
25859
diff
changeset
|
62 |
public static final Object T_UNTRUSTED_CERT = |
11900 | 63 |
"Untrusted certificate"; |
64 |
||
58519
6e017b301287
8231262: Suppress warnings on non-serializable instance fields in security libs serializable classes
darcy
parents:
57950
diff
changeset
|
65 |
@SuppressWarnings("serial") // Not statically typed as Serializable |
2 | 66 |
private Object type; |
67 |
private X509Certificate cert; |
|
68 |
||
69 |
public ValidatorException(String msg) { |
|
70 |
super(msg); |
|
71 |
} |
|
72 |
||
73 |
public ValidatorException(String msg, Throwable cause) { |
|
74 |
super(msg); |
|
75 |
initCause(cause); |
|
76 |
} |
|
77 |
||
78 |
public ValidatorException(Object type) { |
|
79 |
this(type, null); |
|
80 |
} |
|
81 |
||
82 |
public ValidatorException(Object type, X509Certificate cert) { |
|
83 |
super((String)type); |
|
84 |
this.type = type; |
|
85 |
this.cert = cert; |
|
86 |
} |
|
87 |
||
88 |
public ValidatorException(Object type, X509Certificate cert, |
|
89 |
Throwable cause) { |
|
90 |
this(type, cert); |
|
91 |
initCause(cause); |
|
92 |
} |
|
93 |
||
94 |
public ValidatorException(String msg, Object type, X509Certificate cert) { |
|
95 |
super(msg); |
|
96 |
this.type = type; |
|
97 |
this.cert = cert; |
|
98 |
} |
|
99 |
||
100 |
public ValidatorException(String msg, Object type, X509Certificate cert, |
|
101 |
Throwable cause) { |
|
102 |
this(msg, type, cert); |
|
103 |
initCause(cause); |
|
104 |
} |
|
105 |
||
106 |
/** |
|
107 |
* Get the type of the failure (one of the T_XXX constants), if |
|
108 |
* available. This may be helpful when designing a user interface. |
|
109 |
*/ |
|
110 |
public Object getErrorType() { |
|
111 |
return type; |
|
112 |
} |
|
113 |
||
114 |
/** |
|
115 |
* Get the certificate causing the exception, if available. |
|
116 |
*/ |
|
117 |
public X509Certificate getErrorCertificate() { |
|
118 |
return cert; |
|
119 |
} |
|
120 |
||
121 |
} |