author | wetmore |
Fri, 11 May 2018 15:53:12 -0700 | |
branch | JDK-8145252-TLS13-branch |
changeset 56542 | 56aaa6cb3693 |
parent 47216 | 71c04702a3d5 |
child 54483 | ac20c3bdc55d |
permissions | -rw-r--r-- |
2 | 1 |
/* |
56542 | 2 |
* Copyright (c) 1997, 2018, 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 java.security.cert; |
|
27 |
||
56542 | 28 |
import java.security.*; |
29 |
import java.security.spec.*; |
|
30 |
||
2 | 31 |
import javax.security.auth.x500.X500Principal; |
32 |
||
33 |
import java.math.BigInteger; |
|
34 |
import java.util.Date; |
|
35 |
import java.util.Set; |
|
36 |
import java.util.Arrays; |
|
37 |
||
38 |
import sun.security.x509.X509CRLImpl; |
|
56542 | 39 |
import sun.security.util.SignatureUtil; |
2 | 40 |
|
41 |
/** |
|
42 |
* <p> |
|
43 |
* Abstract class for an X.509 Certificate Revocation List (CRL). |
|
44 |
* A CRL is a time-stamped list identifying revoked certificates. |
|
45 |
* It is signed by a Certificate Authority (CA) and made freely |
|
46 |
* available in a public repository. |
|
47 |
* |
|
48 |
* <p>Each revoked certificate is |
|
49 |
* identified in a CRL by its certificate serial number. When a |
|
50 |
* certificate-using system uses a certificate (e.g., for verifying a |
|
51 |
* remote user's digital signature), that system not only checks the |
|
52 |
* certificate signature and validity but also acquires a suitably- |
|
53 |
* recent CRL and checks that the certificate serial number is not on |
|
54 |
* that CRL. The meaning of "suitably-recent" may vary with local |
|
55 |
* policy, but it usually means the most recently-issued CRL. A CA |
|
56 |
* issues a new CRL on a regular periodic basis (e.g., hourly, daily, or |
|
57 |
* weekly). Entries are added to CRLs as revocations occur, and an |
|
58 |
* entry may be removed when the certificate expiration date is reached. |
|
59 |
* <p> |
|
60 |
* The X.509 v2 CRL format is described below in ASN.1: |
|
61 |
* <pre> |
|
62 |
* CertificateList ::= SEQUENCE { |
|
63 |
* tbsCertList TBSCertList, |
|
64 |
* signatureAlgorithm AlgorithmIdentifier, |
|
65 |
* signature BIT STRING } |
|
66 |
* </pre> |
|
67 |
* <p> |
|
68 |
* More information can be found in |
|
26967
c182469301ee
8037550: Update RFC references in javadoc to RFC 5280
juh
parents:
25859
diff
changeset
|
69 |
* <a href="http://tools.ietf.org/html/rfc5280">RFC 5280: Internet X.509 |
2 | 70 |
* Public Key Infrastructure Certificate and CRL Profile</a>. |
71 |
* <p> |
|
18551
882a3948c6e6
8017325: Cleanup of the javadoc <code> tag in java.security.cert
juh
parents:
14342
diff
changeset
|
72 |
* The ASN.1 definition of {@code tbsCertList} is: |
2 | 73 |
* <pre> |
74 |
* TBSCertList ::= SEQUENCE { |
|
75 |
* version Version OPTIONAL, |
|
76 |
* -- if present, must be v2 |
|
77 |
* signature AlgorithmIdentifier, |
|
78 |
* issuer Name, |
|
79 |
* thisUpdate ChoiceOfTime, |
|
80 |
* nextUpdate ChoiceOfTime OPTIONAL, |
|
81 |
* revokedCertificates SEQUENCE OF SEQUENCE { |
|
82 |
* userCertificate CertificateSerialNumber, |
|
83 |
* revocationDate ChoiceOfTime, |
|
84 |
* crlEntryExtensions Extensions OPTIONAL |
|
85 |
* -- if present, must be v2 |
|
86 |
* } OPTIONAL, |
|
87 |
* crlExtensions [0] EXPLICIT Extensions OPTIONAL |
|
88 |
* -- if present, must be v2 |
|
89 |
* } |
|
90 |
* </pre> |
|
91 |
* <p> |
|
92 |
* CRLs are instantiated using a certificate factory. The following is an |
|
93 |
* example of how to instantiate an X.509 CRL: |
|
18551
882a3948c6e6
8017325: Cleanup of the javadoc <code> tag in java.security.cert
juh
parents:
14342
diff
changeset
|
94 |
* <pre>{@code |
10114
d35f0b7bda65
7054969: Null-check-in-finally pattern in java/security documentation
mullan
parents:
6114
diff
changeset
|
95 |
* try (InputStream inStream = new FileInputStream("fileName-of-crl")) { |
2 | 96 |
* CertificateFactory cf = CertificateFactory.getInstance("X.509"); |
97 |
* X509CRL crl = (X509CRL)cf.generateCRL(inStream); |
|
98 |
* } |
|
18551
882a3948c6e6
8017325: Cleanup of the javadoc <code> tag in java.security.cert
juh
parents:
14342
diff
changeset
|
99 |
* }</pre> |
2 | 100 |
* |
101 |
* @author Hemma Prafullchandra |
|
45434
4582657c7260
8181082: class-level since tag issues in java.base & java.datatransfer module
mli
parents:
26967
diff
changeset
|
102 |
* @since 1.2 |
2 | 103 |
* |
104 |
* |
|
105 |
* @see CRL |
|
106 |
* @see CertificateFactory |
|
107 |
* @see X509Extension |
|
108 |
*/ |
|
109 |
||
110 |
public abstract class X509CRL extends CRL implements X509Extension { |
|
111 |
||
112 |
private transient X500Principal issuerPrincipal; |
|
113 |
||
114 |
/** |
|
115 |
* Constructor for X.509 CRLs. |
|
116 |
*/ |
|
117 |
protected X509CRL() { |
|
118 |
super("X.509"); |
|
119 |
} |
|
120 |
||
121 |
/** |
|
122 |
* Compares this CRL for equality with the given |
|
18551
882a3948c6e6
8017325: Cleanup of the javadoc <code> tag in java.security.cert
juh
parents:
14342
diff
changeset
|
123 |
* object. If the {@code other} object is an |
882a3948c6e6
8017325: Cleanup of the javadoc <code> tag in java.security.cert
juh
parents:
14342
diff
changeset
|
124 |
* {@code instanceof} {@code X509CRL}, then |
2 | 125 |
* its encoded form is retrieved and compared with the |
126 |
* encoded form of this CRL. |
|
127 |
* |
|
128 |
* @param other the object to test for equality with this CRL. |
|
129 |
* |
|
130 |
* @return true iff the encoded forms of the two CRLs |
|
131 |
* match, false otherwise. |
|
132 |
*/ |
|
133 |
public boolean equals(Object other) { |
|
134 |
if (this == other) { |
|
135 |
return true; |
|
136 |
} |
|
137 |
if (!(other instanceof X509CRL)) { |
|
138 |
return false; |
|
139 |
} |
|
140 |
try { |
|
141 |
byte[] thisCRL = X509CRLImpl.getEncodedInternal(this); |
|
142 |
byte[] otherCRL = X509CRLImpl.getEncodedInternal((X509CRL)other); |
|
143 |
||
144 |
return Arrays.equals(thisCRL, otherCRL); |
|
145 |
} catch (CRLException e) { |
|
146 |
return false; |
|
147 |
} |
|
148 |
} |
|
149 |
||
150 |
/** |
|
151 |
* Returns a hashcode value for this CRL from its |
|
152 |
* encoded form. |
|
153 |
* |
|
154 |
* @return the hashcode value. |
|
155 |
*/ |
|
156 |
public int hashCode() { |
|
157 |
int retval = 0; |
|
158 |
try { |
|
159 |
byte[] crlData = X509CRLImpl.getEncodedInternal(this); |
|
160 |
for (int i = 1; i < crlData.length; i++) { |
|
161 |
retval += crlData[i] * i; |
|
162 |
} |
|
163 |
return retval; |
|
164 |
} catch (CRLException e) { |
|
165 |
return retval; |
|
166 |
} |
|
167 |
} |
|
168 |
||
169 |
/** |
|
170 |
* Returns the ASN.1 DER-encoded form of this CRL. |
|
171 |
* |
|
172 |
* @return the encoded form of this certificate |
|
173 |
* @exception CRLException if an encoding error occurs. |
|
174 |
*/ |
|
175 |
public abstract byte[] getEncoded() |
|
176 |
throws CRLException; |
|
177 |
||
178 |
/** |
|
179 |
* Verifies that this CRL was signed using the |
|
180 |
* private key that corresponds to the given public key. |
|
181 |
* |
|
182 |
* @param key the PublicKey used to carry out the verification. |
|
183 |
* |
|
184 |
* @exception NoSuchAlgorithmException on unsupported signature |
|
185 |
* algorithms. |
|
186 |
* @exception InvalidKeyException on incorrect key. |
|
187 |
* @exception NoSuchProviderException if there's no default provider. |
|
188 |
* @exception SignatureException on signature errors. |
|
189 |
* @exception CRLException on encoding errors. |
|
190 |
*/ |
|
191 |
public abstract void verify(PublicKey key) |
|
192 |
throws CRLException, NoSuchAlgorithmException, |
|
193 |
InvalidKeyException, NoSuchProviderException, |
|
194 |
SignatureException; |
|
195 |
||
196 |
/** |
|
197 |
* Verifies that this CRL was signed using the |
|
198 |
* private key that corresponds to the given public key. |
|
199 |
* This method uses the signature verification engine |
|
200 |
* supplied by the given provider. |
|
201 |
* |
|
202 |
* @param key the PublicKey used to carry out the verification. |
|
203 |
* @param sigProvider the name of the signature provider. |
|
204 |
* |
|
205 |
* @exception NoSuchAlgorithmException on unsupported signature |
|
206 |
* algorithms. |
|
207 |
* @exception InvalidKeyException on incorrect key. |
|
208 |
* @exception NoSuchProviderException on incorrect provider. |
|
209 |
* @exception SignatureException on signature errors. |
|
210 |
* @exception CRLException on encoding errors. |
|
211 |
*/ |
|
212 |
public abstract void verify(PublicKey key, String sigProvider) |
|
213 |
throws CRLException, NoSuchAlgorithmException, |
|
214 |
InvalidKeyException, NoSuchProviderException, |
|
215 |
SignatureException; |
|
216 |
||
217 |
/** |
|
13406
33d7bf574b42
7026347: Certificate and X509CRL should have verify(PublicKey key, Provider sigProvider)
mullan
parents:
10114
diff
changeset
|
218 |
* Verifies that this CRL was signed using the |
33d7bf574b42
7026347: Certificate and X509CRL should have verify(PublicKey key, Provider sigProvider)
mullan
parents:
10114
diff
changeset
|
219 |
* private key that corresponds to the given public key. |
33d7bf574b42
7026347: Certificate and X509CRL should have verify(PublicKey key, Provider sigProvider)
mullan
parents:
10114
diff
changeset
|
220 |
* This method uses the signature verification engine |
33d7bf574b42
7026347: Certificate and X509CRL should have verify(PublicKey key, Provider sigProvider)
mullan
parents:
10114
diff
changeset
|
221 |
* supplied by the given provider. Note that the specified Provider object |
33d7bf574b42
7026347: Certificate and X509CRL should have verify(PublicKey key, Provider sigProvider)
mullan
parents:
10114
diff
changeset
|
222 |
* does not have to be registered in the provider list. |
33d7bf574b42
7026347: Certificate and X509CRL should have verify(PublicKey key, Provider sigProvider)
mullan
parents:
10114
diff
changeset
|
223 |
* |
33d7bf574b42
7026347: Certificate and X509CRL should have verify(PublicKey key, Provider sigProvider)
mullan
parents:
10114
diff
changeset
|
224 |
* This method was added to version 1.8 of the Java Platform Standard |
33d7bf574b42
7026347: Certificate and X509CRL should have verify(PublicKey key, Provider sigProvider)
mullan
parents:
10114
diff
changeset
|
225 |
* Edition. In order to maintain backwards compatibility with existing |
18551
882a3948c6e6
8017325: Cleanup of the javadoc <code> tag in java.security.cert
juh
parents:
14342
diff
changeset
|
226 |
* service providers, this method is not {@code abstract} |
13406
33d7bf574b42
7026347: Certificate and X509CRL should have verify(PublicKey key, Provider sigProvider)
mullan
parents:
10114
diff
changeset
|
227 |
* and it provides a default implementation. |
33d7bf574b42
7026347: Certificate and X509CRL should have verify(PublicKey key, Provider sigProvider)
mullan
parents:
10114
diff
changeset
|
228 |
* |
33d7bf574b42
7026347: Certificate and X509CRL should have verify(PublicKey key, Provider sigProvider)
mullan
parents:
10114
diff
changeset
|
229 |
* @param key the PublicKey used to carry out the verification. |
33d7bf574b42
7026347: Certificate and X509CRL should have verify(PublicKey key, Provider sigProvider)
mullan
parents:
10114
diff
changeset
|
230 |
* @param sigProvider the signature provider. |
33d7bf574b42
7026347: Certificate and X509CRL should have verify(PublicKey key, Provider sigProvider)
mullan
parents:
10114
diff
changeset
|
231 |
* |
33d7bf574b42
7026347: Certificate and X509CRL should have verify(PublicKey key, Provider sigProvider)
mullan
parents:
10114
diff
changeset
|
232 |
* @exception NoSuchAlgorithmException on unsupported signature |
33d7bf574b42
7026347: Certificate and X509CRL should have verify(PublicKey key, Provider sigProvider)
mullan
parents:
10114
diff
changeset
|
233 |
* algorithms. |
33d7bf574b42
7026347: Certificate and X509CRL should have verify(PublicKey key, Provider sigProvider)
mullan
parents:
10114
diff
changeset
|
234 |
* @exception InvalidKeyException on incorrect key. |
33d7bf574b42
7026347: Certificate and X509CRL should have verify(PublicKey key, Provider sigProvider)
mullan
parents:
10114
diff
changeset
|
235 |
* @exception SignatureException on signature errors. |
33d7bf574b42
7026347: Certificate and X509CRL should have verify(PublicKey key, Provider sigProvider)
mullan
parents:
10114
diff
changeset
|
236 |
* @exception CRLException on encoding errors. |
33d7bf574b42
7026347: Certificate and X509CRL should have verify(PublicKey key, Provider sigProvider)
mullan
parents:
10114
diff
changeset
|
237 |
* @since 1.8 |
33d7bf574b42
7026347: Certificate and X509CRL should have verify(PublicKey key, Provider sigProvider)
mullan
parents:
10114
diff
changeset
|
238 |
*/ |
33d7bf574b42
7026347: Certificate and X509CRL should have verify(PublicKey key, Provider sigProvider)
mullan
parents:
10114
diff
changeset
|
239 |
public void verify(PublicKey key, Provider sigProvider) |
33d7bf574b42
7026347: Certificate and X509CRL should have verify(PublicKey key, Provider sigProvider)
mullan
parents:
10114
diff
changeset
|
240 |
throws CRLException, NoSuchAlgorithmException, |
33d7bf574b42
7026347: Certificate and X509CRL should have verify(PublicKey key, Provider sigProvider)
mullan
parents:
10114
diff
changeset
|
241 |
InvalidKeyException, SignatureException { |
44476
e275cd2f9319
8175029: StackOverflowError in X509CRL and X509Certificate.verify(PublicKey, Provider)
mullan
parents:
26967
diff
changeset
|
242 |
Signature sig = (sigProvider == null) |
e275cd2f9319
8175029: StackOverflowError in X509CRL and X509Certificate.verify(PublicKey, Provider)
mullan
parents:
26967
diff
changeset
|
243 |
? Signature.getInstance(getSigAlgName()) |
e275cd2f9319
8175029: StackOverflowError in X509CRL and X509Certificate.verify(PublicKey, Provider)
mullan
parents:
26967
diff
changeset
|
244 |
: Signature.getInstance(getSigAlgName(), sigProvider); |
56542 | 245 |
|
44476
e275cd2f9319
8175029: StackOverflowError in X509CRL and X509Certificate.verify(PublicKey, Provider)
mullan
parents:
26967
diff
changeset
|
246 |
sig.initVerify(key); |
e275cd2f9319
8175029: StackOverflowError in X509CRL and X509Certificate.verify(PublicKey, Provider)
mullan
parents:
26967
diff
changeset
|
247 |
|
56542 | 248 |
// set parameters after Signature.initSign/initVerify call, |
249 |
// so the deferred provider selections occur when key is set |
|
250 |
try { |
|
251 |
SignatureUtil.specialSetParameter(sig, getSigAlgParams()); |
|
252 |
} catch (ProviderException e) { |
|
253 |
throw new CRLException(e.getMessage(), e.getCause()); |
|
254 |
} catch (InvalidAlgorithmParameterException e) { |
|
255 |
throw new CRLException(e); |
|
256 |
} |
|
257 |
||
44476
e275cd2f9319
8175029: StackOverflowError in X509CRL and X509Certificate.verify(PublicKey, Provider)
mullan
parents:
26967
diff
changeset
|
258 |
byte[] tbsCRL = getTBSCertList(); |
e275cd2f9319
8175029: StackOverflowError in X509CRL and X509Certificate.verify(PublicKey, Provider)
mullan
parents:
26967
diff
changeset
|
259 |
sig.update(tbsCRL, 0, tbsCRL.length); |
e275cd2f9319
8175029: StackOverflowError in X509CRL and X509Certificate.verify(PublicKey, Provider)
mullan
parents:
26967
diff
changeset
|
260 |
|
e275cd2f9319
8175029: StackOverflowError in X509CRL and X509Certificate.verify(PublicKey, Provider)
mullan
parents:
26967
diff
changeset
|
261 |
if (sig.verify(getSignature()) == false) { |
e275cd2f9319
8175029: StackOverflowError in X509CRL and X509Certificate.verify(PublicKey, Provider)
mullan
parents:
26967
diff
changeset
|
262 |
throw new SignatureException("Signature does not match."); |
e275cd2f9319
8175029: StackOverflowError in X509CRL and X509Certificate.verify(PublicKey, Provider)
mullan
parents:
26967
diff
changeset
|
263 |
} |
13406
33d7bf574b42
7026347: Certificate and X509CRL should have verify(PublicKey key, Provider sigProvider)
mullan
parents:
10114
diff
changeset
|
264 |
} |
33d7bf574b42
7026347: Certificate and X509CRL should have verify(PublicKey key, Provider sigProvider)
mullan
parents:
10114
diff
changeset
|
265 |
|
33d7bf574b42
7026347: Certificate and X509CRL should have verify(PublicKey key, Provider sigProvider)
mullan
parents:
10114
diff
changeset
|
266 |
/** |
18551
882a3948c6e6
8017325: Cleanup of the javadoc <code> tag in java.security.cert
juh
parents:
14342
diff
changeset
|
267 |
* Gets the {@code version} (version number) value from the CRL. |
2 | 268 |
* The ASN.1 definition for this is: |
269 |
* <pre> |
|
270 |
* version Version OPTIONAL, |
|
18592
80cdfecea074
8019539: Fix doclint errors in java.security and its subpackages
juh
parents:
18551
diff
changeset
|
271 |
* -- if present, must be v2 |
80cdfecea074
8019539: Fix doclint errors in java.security and its subpackages
juh
parents:
18551
diff
changeset
|
272 |
* |
2 | 273 |
* Version ::= INTEGER { v1(0), v2(1), v3(2) } |
274 |
* -- v3 does not apply to CRLs but appears for consistency |
|
275 |
* -- with definition of Version for certs |
|
276 |
* </pre> |
|
277 |
* |
|
278 |
* @return the version number, i.e. 1 or 2. |
|
279 |
*/ |
|
280 |
public abstract int getVersion(); |
|
281 |
||
282 |
/** |
|
283 |
* <strong>Denigrated</strong>, replaced by {@linkplain |
|
18551
882a3948c6e6
8017325: Cleanup of the javadoc <code> tag in java.security.cert
juh
parents:
14342
diff
changeset
|
284 |
* #getIssuerX500Principal()}. This method returns the {@code issuer} |
2 | 285 |
* as an implementation specific Principal object, which should not be |
286 |
* relied upon by portable code. |
|
287 |
* |
|
288 |
* <p> |
|
18551
882a3948c6e6
8017325: Cleanup of the javadoc <code> tag in java.security.cert
juh
parents:
14342
diff
changeset
|
289 |
* Gets the {@code issuer} (issuer distinguished name) value from |
2 | 290 |
* the CRL. The issuer name identifies the entity that signed (and |
291 |
* issued) the CRL. |
|
292 |
* |
|
293 |
* <p>The issuer name field contains an |
|
294 |
* X.500 distinguished name (DN). |
|
295 |
* The ASN.1 definition for this is: |
|
296 |
* <pre> |
|
297 |
* issuer Name |
|
298 |
* |
|
299 |
* Name ::= CHOICE { RDNSequence } |
|
300 |
* RDNSequence ::= SEQUENCE OF RelativeDistinguishedName |
|
301 |
* RelativeDistinguishedName ::= |
|
302 |
* SET OF AttributeValueAssertion |
|
303 |
* |
|
304 |
* AttributeValueAssertion ::= SEQUENCE { |
|
305 |
* AttributeType, |
|
306 |
* AttributeValue } |
|
307 |
* AttributeType ::= OBJECT IDENTIFIER |
|
308 |
* AttributeValue ::= ANY |
|
309 |
* </pre> |
|
18551
882a3948c6e6
8017325: Cleanup of the javadoc <code> tag in java.security.cert
juh
parents:
14342
diff
changeset
|
310 |
* The {@code Name} describes a hierarchical name composed of |
2 | 311 |
* attributes, |
312 |
* such as country name, and corresponding values, such as US. |
|
18551
882a3948c6e6
8017325: Cleanup of the javadoc <code> tag in java.security.cert
juh
parents:
14342
diff
changeset
|
313 |
* The type of the {@code AttributeValue} component is determined by |
882a3948c6e6
8017325: Cleanup of the javadoc <code> tag in java.security.cert
juh
parents:
14342
diff
changeset
|
314 |
* the {@code AttributeType}; in general it will be a |
882a3948c6e6
8017325: Cleanup of the javadoc <code> tag in java.security.cert
juh
parents:
14342
diff
changeset
|
315 |
* {@code directoryString}. A {@code directoryString} is usually |
882a3948c6e6
8017325: Cleanup of the javadoc <code> tag in java.security.cert
juh
parents:
14342
diff
changeset
|
316 |
* one of {@code PrintableString}, |
882a3948c6e6
8017325: Cleanup of the javadoc <code> tag in java.security.cert
juh
parents:
14342
diff
changeset
|
317 |
* {@code TeletexString} or {@code UniversalString}. |
2 | 318 |
* |
319 |
* @return a Principal whose name is the issuer distinguished name. |
|
320 |
*/ |
|
321 |
public abstract Principal getIssuerDN(); |
|
322 |
||
323 |
/** |
|
324 |
* Returns the issuer (issuer distinguished name) value from the |
|
18551
882a3948c6e6
8017325: Cleanup of the javadoc <code> tag in java.security.cert
juh
parents:
14342
diff
changeset
|
325 |
* CRL as an {@code X500Principal}. |
2 | 326 |
* <p> |
327 |
* It is recommended that subclasses override this method. |
|
328 |
* |
|
18551
882a3948c6e6
8017325: Cleanup of the javadoc <code> tag in java.security.cert
juh
parents:
14342
diff
changeset
|
329 |
* @return an {@code X500Principal} representing the issuer |
2 | 330 |
* distinguished name |
331 |
* @since 1.4 |
|
332 |
*/ |
|
333 |
public X500Principal getIssuerX500Principal() { |
|
334 |
if (issuerPrincipal == null) { |
|
335 |
issuerPrincipal = X509CRLImpl.getIssuerX500Principal(this); |
|
336 |
} |
|
337 |
return issuerPrincipal; |
|
338 |
} |
|
339 |
||
340 |
/** |
|
18551
882a3948c6e6
8017325: Cleanup of the javadoc <code> tag in java.security.cert
juh
parents:
14342
diff
changeset
|
341 |
* Gets the {@code thisUpdate} date from the CRL. |
2 | 342 |
* The ASN.1 definition for this is: |
343 |
* <pre> |
|
344 |
* thisUpdate ChoiceOfTime |
|
345 |
* ChoiceOfTime ::= CHOICE { |
|
346 |
* utcTime UTCTime, |
|
347 |
* generalTime GeneralizedTime } |
|
348 |
* </pre> |
|
349 |
* |
|
18551
882a3948c6e6
8017325: Cleanup of the javadoc <code> tag in java.security.cert
juh
parents:
14342
diff
changeset
|
350 |
* @return the {@code thisUpdate} date from the CRL. |
2 | 351 |
*/ |
352 |
public abstract Date getThisUpdate(); |
|
353 |
||
354 |
/** |
|
18551
882a3948c6e6
8017325: Cleanup of the javadoc <code> tag in java.security.cert
juh
parents:
14342
diff
changeset
|
355 |
* Gets the {@code nextUpdate} date from the CRL. |
2 | 356 |
* |
18551
882a3948c6e6
8017325: Cleanup of the javadoc <code> tag in java.security.cert
juh
parents:
14342
diff
changeset
|
357 |
* @return the {@code nextUpdate} date from the CRL, or null if |
2 | 358 |
* not present. |
359 |
*/ |
|
360 |
public abstract Date getNextUpdate(); |
|
361 |
||
362 |
/** |
|
363 |
* Gets the CRL entry, if any, with the given certificate serialNumber. |
|
364 |
* |
|
365 |
* @param serialNumber the serial number of the certificate for which a CRL entry |
|
366 |
* is to be looked up |
|
367 |
* @return the entry with the given serial number, or null if no such entry |
|
368 |
* exists in this CRL. |
|
369 |
* @see X509CRLEntry |
|
370 |
*/ |
|
371 |
public abstract X509CRLEntry |
|
372 |
getRevokedCertificate(BigInteger serialNumber); |
|
373 |
||
374 |
/** |
|
375 |
* Get the CRL entry, if any, for the given certificate. |
|
376 |
* |
|
377 |
* <p>This method can be used to lookup CRL entries in indirect CRLs, |
|
378 |
* that means CRLs that contain entries from issuers other than the CRL |
|
379 |
* issuer. The default implementation will only return entries for |
|
380 |
* certificates issued by the CRL issuer. Subclasses that wish to |
|
381 |
* support indirect CRLs should override this method. |
|
382 |
* |
|
383 |
* @param certificate the certificate for which a CRL entry is to be looked |
|
384 |
* up |
|
385 |
* @return the entry for the given certificate, or null if no such entry |
|
386 |
* exists in this CRL. |
|
387 |
* @exception NullPointerException if certificate is null |
|
388 |
* |
|
389 |
* @since 1.5 |
|
390 |
*/ |
|
391 |
public X509CRLEntry getRevokedCertificate(X509Certificate certificate) { |
|
392 |
X500Principal certIssuer = certificate.getIssuerX500Principal(); |
|
393 |
X500Principal crlIssuer = getIssuerX500Principal(); |
|
394 |
if (certIssuer.equals(crlIssuer) == false) { |
|
395 |
return null; |
|
396 |
} |
|
397 |
return getRevokedCertificate(certificate.getSerialNumber()); |
|
398 |
} |
|
399 |
||
400 |
/** |
|
401 |
* Gets all the entries from this CRL. |
|
402 |
* This returns a Set of X509CRLEntry objects. |
|
403 |
* |
|
404 |
* @return all the entries or null if there are none present. |
|
405 |
* @see X509CRLEntry |
|
406 |
*/ |
|
407 |
public abstract Set<? extends X509CRLEntry> getRevokedCertificates(); |
|
408 |
||
409 |
/** |
|
410 |
* Gets the DER-encoded CRL information, the |
|
18551
882a3948c6e6
8017325: Cleanup of the javadoc <code> tag in java.security.cert
juh
parents:
14342
diff
changeset
|
411 |
* {@code tbsCertList} from this CRL. |
2 | 412 |
* This can be used to verify the signature independently. |
413 |
* |
|
414 |
* @return the DER-encoded CRL information. |
|
415 |
* @exception CRLException if an encoding error occurs. |
|
416 |
*/ |
|
417 |
public abstract byte[] getTBSCertList() throws CRLException; |
|
418 |
||
419 |
/** |
|
18551
882a3948c6e6
8017325: Cleanup of the javadoc <code> tag in java.security.cert
juh
parents:
14342
diff
changeset
|
420 |
* Gets the {@code signature} value (the raw signature bits) from |
2 | 421 |
* the CRL. |
422 |
* The ASN.1 definition for this is: |
|
423 |
* <pre> |
|
424 |
* signature BIT STRING |
|
425 |
* </pre> |
|
426 |
* |
|
427 |
* @return the signature. |
|
428 |
*/ |
|
429 |
public abstract byte[] getSignature(); |
|
430 |
||
431 |
/** |
|
432 |
* Gets the signature algorithm name for the CRL |
|
6114
9d463b9408ba
6870553: X509Certificate.getSigAlgName method description uses non-standard algorithm name as example
mullan
parents:
5506
diff
changeset
|
433 |
* signature algorithm. An example is the string "SHA256withRSA". |
2 | 434 |
* The ASN.1 definition for this is: |
435 |
* <pre> |
|
18592
80cdfecea074
8019539: Fix doclint errors in java.security and its subpackages
juh
parents:
18551
diff
changeset
|
436 |
* signatureAlgorithm AlgorithmIdentifier |
80cdfecea074
8019539: Fix doclint errors in java.security and its subpackages
juh
parents:
18551
diff
changeset
|
437 |
* |
2 | 438 |
* AlgorithmIdentifier ::= SEQUENCE { |
439 |
* algorithm OBJECT IDENTIFIER, |
|
440 |
* parameters ANY DEFINED BY algorithm OPTIONAL } |
|
441 |
* -- contains a value of the type |
|
442 |
* -- registered for use with the |
|
443 |
* -- algorithm object identifier value |
|
444 |
* </pre> |
|
445 |
* |
|
18551
882a3948c6e6
8017325: Cleanup of the javadoc <code> tag in java.security.cert
juh
parents:
14342
diff
changeset
|
446 |
* <p>The algorithm name is determined from the {@code algorithm} |
2 | 447 |
* OID string. |
448 |
* |
|
449 |
* @return the signature algorithm name. |
|
450 |
*/ |
|
451 |
public abstract String getSigAlgName(); |
|
452 |
||
453 |
/** |
|
454 |
* Gets the signature algorithm OID string from the CRL. |
|
455 |
* An OID is represented by a set of nonnegative whole numbers separated |
|
456 |
* by periods. |
|
457 |
* For example, the string "1.2.840.10040.4.3" identifies the SHA-1 |
|
458 |
* with DSA signature algorithm defined in |
|
459 |
* <a href="http://www.ietf.org/rfc/rfc3279.txt">RFC 3279: Algorithms and |
|
460 |
* Identifiers for the Internet X.509 Public Key Infrastructure Certificate |
|
461 |
* and CRL Profile</a>. |
|
462 |
* |
|
463 |
* <p>See {@link #getSigAlgName() getSigAlgName} for |
|
464 |
* relevant ASN.1 definitions. |
|
465 |
* |
|
466 |
* @return the signature algorithm OID string. |
|
467 |
*/ |
|
468 |
public abstract String getSigAlgOID(); |
|
469 |
||
470 |
/** |
|
471 |
* Gets the DER-encoded signature algorithm parameters from this |
|
472 |
* CRL's signature algorithm. In most cases, the signature |
|
473 |
* algorithm parameters are null; the parameters are usually |
|
474 |
* supplied with the public key. |
|
475 |
* If access to individual parameter values is needed then use |
|
476 |
* {@link java.security.AlgorithmParameters AlgorithmParameters} |
|
477 |
* and instantiate with the name returned by |
|
478 |
* {@link #getSigAlgName() getSigAlgName}. |
|
479 |
* |
|
480 |
* <p>See {@link #getSigAlgName() getSigAlgName} for |
|
481 |
* relevant ASN.1 definitions. |
|
482 |
* |
|
483 |
* @return the DER-encoded signature algorithm parameters, or |
|
484 |
* null if no parameters are present. |
|
485 |
*/ |
|
486 |
public abstract byte[] getSigAlgParams(); |
|
487 |
} |