1 module hunt.security.cert.X509Certificate; 2 3 import hunt.security.cert.Certificate; 4 import hunt.security.Principal; 5 import hunt.security.Provider; 6 import hunt.security.x500.X500Principal; 7 import hunt.security.x509; 8 import hunt.security.Key; 9 10 import hunt.collection; 11 import hunt.Exceptions; 12 13 import std.bigint; 14 import std.datetime; 15 16 17 18 /** 19 * Interface for an X.509 extension. 20 * 21 * <p>The extensions defined for X.509 v3 22 * {@link X509Certificate Certificates} and v2 23 * {@link X509CRL CRLs} (Certificate Revocation 24 * Lists) provide methods 25 * for associating additional attributes with users or keys, 26 * for managing the certification hierarchy, and for managing CRL 27 * distribution. The X.509 extensions format also allows communities 28 * to define private extensions to carry information unique to those 29 * communities. 30 * 31 * <p>Each extension in a certificate/CRL may be designated as 32 * critical or non-critical. A certificate/CRL-using system (an application 33 * validating a certificate/CRL) must reject the certificate/CRL if it 34 * encounters a critical extension it does not recognize. A non-critical 35 * extension may be ignored if it is not recognized. 36 * <p> 37 * The ASN.1 definition for this is: 38 * <pre> 39 * Extensions ::= SEQUENCE SIZE (1..MAX) OF Extension 40 * 41 * Extension ::= SEQUENCE { 42 * extnId OBJECT IDENTIFIER, 43 * critical BOOLEAN DEFAULT FALSE, 44 * extnValue OCTET STRING 45 * -- contains a DER encoding of a value 46 * -- of the type registered for use with 47 * -- the extnId object identifier value 48 * } 49 * </pre> 50 * Since not all extensions are known, the {@code getExtensionValue} 51 * method returns the DER-encoded OCTET STRING of the 52 * extension value (i.e., the {@code extnValue}). This can then 53 * be handled by a <em>Class</em> that understands the extension. 54 * 55 * @author Hemma Prafullchandra 56 */ 57 58 interface X509Extension { 59 60 /** 61 * Check if there is a critical extension that is not supported. 62 * 63 * @return {@code true} if a critical extension is found that is 64 * not supported, otherwise {@code false}. 65 */ 66 bool hasUnsupportedCriticalExtension(); 67 68 /** 69 * Gets a Set of the OID strings for the extension(s) marked 70 * CRITICAL in the certificate/CRL managed by the object 71 * implementing this interface. 72 * 73 * Here is sample code to get a Set of critical extensions from an 74 * X509Certificate and print the OIDs: 75 * <pre>{@code 76 * X509Certificate cert = null; 77 * try (InputStream inStrm = new FileInputStream("DER-encoded-Cert")) { 78 * CertificateFactory cf = CertificateFactory.getInstance("X.509"); 79 * cert = (X509Certificate)cf.generateCertificate(inStrm); 80 * } 81 * 82 * Set!string critSet = cert.getCriticalExtensionOIDs(); 83 * if (critSet !is null && !critSet.isEmpty()) { 84 * System.out.println("Set of critical extensions:"); 85 * for (string oid : critSet) { 86 * System.out.println(oid); 87 * } 88 * } 89 * }</pre> 90 * @return a Set (or an empty Set if none are marked critical) of 91 * the extension OID strings for extensions that are marked critical. 92 * If there are no extensions present at all, then this method returns 93 * null. 94 */ 95 Set!string getCriticalExtensionOIDs(); 96 97 /** 98 * Gets a Set of the OID strings for the extension(s) marked 99 * NON-CRITICAL in the certificate/CRL managed by the object 100 * implementing this interface. 101 * 102 * Here is sample code to get a Set of non-critical extensions from an 103 * X509CRL revoked certificate entry and print the OIDs: 104 * <pre>{@code 105 * CertificateFactory cf = null; 106 * X509CRL crl = null; 107 * try (InputStream inStrm = new FileInputStream("DER-encoded-CRL")) { 108 * cf = CertificateFactory.getInstance("X.509"); 109 * crl = (X509CRL)cf.generateCRL(inStrm); 110 * } 111 * 112 * byte[] certData = <DER-encoded certificate data> 113 * ByteArrayInputStream bais = new ByteArrayInputStream(certData); 114 * X509Certificate cert = (X509Certificate)cf.generateCertificate(bais); 115 * X509CRLEntry badCert = 116 * crl.getRevokedCertificate(cert.getSerialNumber()); 117 * 118 * if (badCert !is null) { 119 * Set!string nonCritSet = badCert.getNonCriticalExtensionOIDs(); 120 * if (nonCritSet !is null) 121 * for (string oid : nonCritSet) { 122 * System.out.println(oid); 123 * } 124 * } 125 * }</pre> 126 * 127 * @return a Set (or an empty Set if none are marked non-critical) of 128 * the extension OID strings for extensions that are marked non-critical. 129 * If there are no extensions present at all, then this method returns 130 * null. 131 */ 132 Set!string getNonCriticalExtensionOIDs(); 133 134 /** 135 * Gets the DER-encoded OCTET string for the extension value 136 * (<em>extnValue</em>) identified by the passed-in {@code oid} 137 * string. 138 * The {@code oid} string is 139 * represented by a set of nonnegative whole numbers separated 140 * by periods. 141 * 142 * <p>For example:<br> 143 * <table border=groove summary="Examples of OIDs and extension names"> 144 * <tr> 145 * <th>OID <em>(Object Identifier)</em></th> 146 * <th>Extension Name</th></tr> 147 * <tr><td>2.5.29.14</td> 148 * <td>SubjectKeyIdentifier</td></tr> 149 * <tr><td>2.5.29.15</td> 150 * <td>KeyUsage</td></tr> 151 * <tr><td>2.5.29.16</td> 152 * <td>PrivateKeyUsage</td></tr> 153 * <tr><td>2.5.29.17</td> 154 * <td>SubjectAlternativeName</td></tr> 155 * <tr><td>2.5.29.18</td> 156 * <td>IssuerAlternativeName</td></tr> 157 * <tr><td>2.5.29.19</td> 158 * <td>BasicConstraints</td></tr> 159 * <tr><td>2.5.29.30</td> 160 * <td>NameConstraints</td></tr> 161 * <tr><td>2.5.29.33</td> 162 * <td>PolicyMappings</td></tr> 163 * <tr><td>2.5.29.35</td> 164 * <td>AuthorityKeyIdentifier</td></tr> 165 * <tr><td>2.5.29.36</td> 166 * <td>PolicyConstraints</td></tr> 167 * </table> 168 * 169 * @param oid the Object Identifier value for the extension. 170 * @return the DER-encoded octet string of the extension value or 171 * null if it is not present. 172 */ 173 byte[] getExtensionValue(string oid); 174 } 175 176 177 /** 178 * <p> 179 * Abstract class for X.509 certificates. This provides a standard 180 * way to access all the attributes of an X.509 certificate. 181 * <p> 182 * In June of 1996, the basic X.509 v3 format was completed by 183 * ISO/IEC and ANSI X9, which is described below in ASN.1: 184 * <pre> 185 * Certificate ::= SEQUENCE { 186 * tbsCertificate TBSCertificate, 187 * signatureAlgorithm AlgorithmIdentifier, 188 * signature BIT STRING } 189 * </pre> 190 * <p> 191 * These certificates are widely used to support authentication and 192 * other functionality in Internet security systems. Common applications 193 * include Privacy Enhanced Mail (PEM), Transport Layer Security (SSL), 194 * code signing for trusted software distribution, and Secure Electronic 195 * Transactions (SET). 196 * <p> 197 * These certificates are managed and vouched for by <em>Certificate 198 * Authorities</em> (CAs). CAs are services which create certificates by 199 * placing data in the X.509 standard format and then digitally signing 200 * that data. CAs act as trusted third parties, making introductions 201 * between principals who have no direct knowledge of each other. 202 * CA certificates are either signed by themselves, or by some other 203 * CA such as a "root" CA. 204 * <p> 205 * More information can be found in 206 * <a href="http://www.ietf.org/rfc/rfc3280.txt">RFC 3280: Internet X.509 207 * Public Key Infrastructure Certificate and CRL Profile</a>. 208 * <p> 209 * The ASN.1 definition of {@code tbsCertificate} is: 210 * <pre> 211 * TBSCertificate ::= SEQUENCE { 212 * version [0] EXPLICIT Version DEFAULT v1, 213 * serialNumber CertificateSerialNumber, 214 * signature AlgorithmIdentifier, 215 * issuer Name, 216 * validity Validity, 217 * subject Name, 218 * subjectPublicKeyInfo SubjectPublicKeyInfo, 219 * issuerUniqueID [1] IMPLICIT UniqueIdentifier OPTIONAL, 220 * -- If present, version must be v2 or v3 221 * subjectUniqueID [2] IMPLICIT UniqueIdentifier OPTIONAL, 222 * -- If present, version must be v2 or v3 223 * extensions [3] EXPLICIT Extensions OPTIONAL 224 * -- If present, version must be v3 225 * } 226 * </pre> 227 * <p> 228 * Certificates are instantiated using a certificate factory. The following is 229 * an example of how to instantiate an X.509 certificate: 230 * <pre> 231 * try (InputStream inStream = new FileInputStream("fileName-of-cert")) { 232 * CertificateFactory cf = CertificateFactory.getInstance("X.509"); 233 * X509Certificate cert = (X509Certificate)cf.generateCertificate(inStream); 234 * } 235 * </pre> 236 * 237 * @author Hemma Prafullchandra 238 * 239 * 240 * @see Certificate 241 * @see CertificateFactory 242 * @see X509Extension 243 */ 244 245 abstract class X509Certificate : Certificate, X509Extension { 246 247 // private static final long serialVersionUID = -2491127588187038216L; 248 249 private X500Principal subjectX500Principal, issuerX500Principal; 250 251 /** 252 * Constructor for X.509 certificates. 253 */ 254 protected this() { 255 super("X.509"); 256 } 257 258 /** 259 * Checks that the certificate is currently valid. It is if 260 * the current date and time are within the validity period given in the 261 * certificate. 262 * <p> 263 * The validity period consists of two date/time values: 264 * the first and last dates (and times) on which the certificate 265 * is valid. It is defined in 266 * ASN.1 as: 267 * <pre> 268 * validity Validity 269 * 270 * Validity ::= SEQUENCE { 271 * notBefore CertificateValidityDate, 272 * notAfter CertificateValidityDate } 273 * 274 * CertificateValidityDate ::= CHOICE { 275 * utcTime UTCTime, 276 * generalTime GeneralizedTime } 277 * </pre> 278 * 279 * @exception CertificateExpiredException if the certificate has expired. 280 * @exception CertificateNotYetValidException if the certificate is not 281 * yet valid. 282 */ 283 abstract void checkValidity(); 284 285 286 /** 287 * Checks that the given date is within the certificate's 288 * validity period. In other words, this determines whether the 289 * certificate would be valid at the given date/time. 290 * 291 * @param date the Date to check against to see if this certificate 292 * is valid at that date/time. 293 * 294 * @exception CertificateExpiredException if the certificate has expired 295 * with respect to the {@code date} supplied. 296 * @exception CertificateNotYetValidException if the certificate is not 297 * yet valid with respect to the {@code date} supplied. 298 * 299 * @see #checkValidity() 300 */ 301 abstract void checkValidity(Date date); 302 303 304 /** 305 * Gets the {@code version} (version number) value from the 306 * certificate. 307 * The ASN.1 definition for this is: 308 * <pre> 309 * version [0] EXPLICIT Version DEFAULT v1 310 * 311 * Version ::= INTEGER { v1(0), v2(1), v3(2) } 312 * </pre> 313 * @return the version number, i.e. 1, 2 or 3. 314 */ 315 abstract int getVersion(); 316 317 /** 318 * Gets the {@code serialNumber} value from the certificate. 319 * The serial number is an integer assigned by the certification 320 * authority to each certificate. It must be unique for each 321 * certificate issued by a given CA (i.e., the issuer name and 322 * serial number identify a unique certificate). 323 * The ASN.1 definition for this is: 324 * <pre> 325 * serialNumber CertificateSerialNumber 326 * 327 * CertificateSerialNumber ::= INTEGER 328 * </pre> 329 * 330 * @return the serial number. 331 */ 332 abstract BigInt getSerialNumber(); 333 334 /** 335 * <strong>Denigrated</strong>, replaced by {@linkplain 336 * #getIssuerX500Principal()}. This method returns the {@code issuer} 337 * as an implementation specific Principal object, which should not be 338 * relied upon by portable code. 339 * 340 * <p> 341 * Gets the {@code issuer} (issuer distinguished name) value from 342 * the certificate. The issuer name identifies the entity that signed (and 343 * issued) the certificate. 344 * 345 * <p>The issuer name field contains an 346 * X.500 distinguished name (DN). 347 * The ASN.1 definition for this is: 348 * <pre> 349 * issuer Name 350 * 351 * Name ::= CHOICE { RDNSequence } 352 * RDNSequence ::= SEQUENCE OF RelativeDistinguishedName 353 * RelativeDistinguishedName ::= 354 * SET OF AttributeValueAssertion 355 * 356 * AttributeValueAssertion ::= SEQUENCE { 357 * AttributeType, 358 * AttributeValue } 359 * AttributeType ::= OBJECT IDENTIFIER 360 * AttributeValue ::= ANY 361 * </pre> 362 * The {@code Name} describes a hierarchical name composed of 363 * attributes, 364 * such as country name, and corresponding values, such as US. 365 * The type of the {@code AttributeValue} component is determined by 366 * the {@code AttributeType}; in general it will be a 367 * {@code directoryString}. A {@code directoryString} is usually 368 * one of {@code PrintableString}, 369 * {@code TeletexString} or {@code UniversalString}. 370 * 371 * @return a Principal whose name is the issuer distinguished name. 372 */ 373 abstract Principal getIssuerDN(); 374 375 /** 376 * Returns the issuer (issuer distinguished name) value from the 377 * certificate as an {@code X500Principal}. 378 * <p> 379 * It is recommended that subclasses override this method. 380 * 381 * @return an {@code X500Principal} representing the issuer 382 * distinguished name 383 * @since 1.4 384 */ 385 X500Principal getIssuerX500Principal() { 386 implementationMissing(); 387 // if (issuerX500Principal is null) { 388 // issuerX500Principal = X509CertImpl.getIssuerX500Principal(this); 389 // } 390 return issuerX500Principal; 391 } 392 393 /** 394 * <strong>Denigrated</strong>, replaced by {@linkplain 395 * #getSubjectX500Principal()}. This method returns the {@code subject} 396 * as an implementation specific Principal object, which should not be 397 * relied upon by portable code. 398 * 399 * <p> 400 * Gets the {@code subject} (subject distinguished name) value 401 * from the certificate. If the {@code subject} value is empty, 402 * then the {@code getName()} method of the returned 403 * {@code Principal} object returns an empty string (""). 404 * 405 * <p> The ASN.1 definition for this is: 406 * <pre> 407 * subject Name 408 * </pre> 409 * 410 * <p>See {@link #getIssuerDN() getIssuerDN} for {@code Name} 411 * and other relevant definitions. 412 * 413 * @return a Principal whose name is the subject name. 414 */ 415 abstract Principal getSubjectDN(); 416 417 /** 418 * Returns the subject (subject distinguished name) value from the 419 * certificate as an {@code X500Principal}. If the subject value 420 * is empty, then the {@code getName()} method of the returned 421 * {@code X500Principal} object returns an empty string (""). 422 * <p> 423 * It is recommended that subclasses override this method. 424 * 425 * @return an {@code X500Principal} representing the subject 426 * distinguished name 427 * @since 1.4 428 */ 429 X500Principal getSubjectX500Principal() { 430 if (subjectX500Principal is null) { 431 // subjectX500Principal = X509CertImpl.getSubjectX500Principal(this); 432 433 implementationMissing(); 434 } 435 return subjectX500Principal; 436 } 437 438 /** 439 * Gets the {@code notBefore} date from the validity period of 440 * the certificate. 441 * The relevant ASN.1 definitions are: 442 * <pre> 443 * validity Validity 444 * 445 * Validity ::= SEQUENCE { 446 * notBefore CertificateValidityDate, 447 * notAfter CertificateValidityDate } 448 * 449 * CertificateValidityDate ::= CHOICE { 450 * utcTime UTCTime, 451 * generalTime GeneralizedTime } 452 * </pre> 453 * 454 * @return the start date of the validity period. 455 * @see #checkValidity 456 */ 457 abstract Date getNotBefore(); 458 459 /** 460 * Gets the {@code notAfter} date from the validity period of 461 * the certificate. See {@link #getNotBefore() getNotBefore} 462 * for relevant ASN.1 definitions. 463 * 464 * @return the end date of the validity period. 465 * @see #checkValidity 466 */ 467 abstract Date getNotAfter(); 468 469 /** 470 * Gets the DER-encoded certificate information, the 471 * {@code tbsCertificate} from this certificate. 472 * This can be used to verify the signature independently. 473 * 474 * @return the DER-encoded certificate information. 475 * @exception CertificateEncodingException if an encoding error occurs. 476 */ 477 abstract byte[] getTBSCertificate(); 478 479 /** 480 * Gets the {@code signature} value (the raw signature bits) from 481 * the certificate. 482 * The ASN.1 definition for this is: 483 * <pre> 484 * signature BIT STRING 485 * </pre> 486 * 487 * @return the signature. 488 */ 489 abstract byte[] getSignature(); 490 491 /** 492 * Gets the signature algorithm name for the certificate 493 * signature algorithm. An example is the string "SHA256withRSA". 494 * The ASN.1 definition for this is: 495 * <pre> 496 * signatureAlgorithm AlgorithmIdentifier 497 * 498 * AlgorithmIdentifier ::= SEQUENCE { 499 * algorithm OBJECT IDENTIFIER, 500 * parameters ANY DEFINED BY algorithm OPTIONAL } 501 * -- contains a value of the type 502 * -- registered for use with the 503 * -- algorithm object identifier value 504 * </pre> 505 * 506 * <p>The algorithm name is determined from the {@code algorithm} 507 * OID string. 508 * 509 * @return the signature algorithm name. 510 */ 511 abstract string getSigAlgName(); 512 513 /** 514 * Gets the signature algorithm OID string from the certificate. 515 * An OID is represented by a set of nonnegative whole numbers separated 516 * by periods. 517 * For example, the string "1.2.840.10040.4.3" identifies the SHA-1 518 * with DSA signature algorithm defined in 519 * <a href="http://www.ietf.org/rfc/rfc3279.txt">RFC 3279: Algorithms and 520 * Identifiers for the Internet X.509 Public Key Infrastructure Certificate 521 * and CRL Profile</a>. 522 * 523 * <p>See {@link #getSigAlgName() getSigAlgName} for 524 * relevant ASN.1 definitions. 525 * 526 * @return the signature algorithm OID string. 527 */ 528 abstract string getSigAlgOID(); 529 530 /** 531 * Gets the DER-encoded signature algorithm parameters from this 532 * certificate's signature algorithm. In most cases, the signature 533 * algorithm parameters are null; the parameters are usually 534 * supplied with the certificate's key. 535 * If access to individual parameter values is needed then use 536 * {@link java.security.AlgorithmParameters AlgorithmParameters} 537 * and instantiate with the name returned by 538 * {@link #getSigAlgName() getSigAlgName}. 539 * 540 * <p>See {@link #getSigAlgName() getSigAlgName} for 541 * relevant ASN.1 definitions. 542 * 543 * @return the DER-encoded signature algorithm parameters, or 544 * null if no parameters are present. 545 */ 546 abstract byte[] getSigAlgParams(); 547 548 /** 549 * Gets the {@code issuerUniqueID} value from the certificate. 550 * The issuer unique identifier is present in the certificate 551 * to handle the possibility of reuse of issuer names over time. 552 * RFC 3280 recommends that names not be reused and that 553 * conforming certificates not make use of unique identifiers. 554 * Applications conforming to that profile should be capable of 555 * parsing unique identifiers and making comparisons. 556 * 557 * <p>The ASN.1 definition for this is: 558 * <pre> 559 * issuerUniqueID [1] IMPLICIT UniqueIdentifier OPTIONAL 560 * 561 * UniqueIdentifier ::= BIT STRING 562 * </pre> 563 * 564 * @return the issuer unique identifier or null if it is not 565 * present in the certificate. 566 */ 567 abstract bool[] getIssuerUniqueID(); 568 569 /** 570 * Gets the {@code subjectUniqueID} value from the certificate. 571 * 572 * <p>The ASN.1 definition for this is: 573 * <pre> 574 * subjectUniqueID [2] IMPLICIT UniqueIdentifier OPTIONAL 575 * 576 * UniqueIdentifier ::= BIT STRING 577 * </pre> 578 * 579 * @return the subject unique identifier or null if it is not 580 * present in the certificate. 581 */ 582 abstract bool[] getSubjectUniqueID(); 583 584 /** 585 * Gets a bool array representing bits of 586 * the {@code KeyUsage} extension, (OID = 2.5.29.15). 587 * The key usage extension defines the purpose (e.g., encipherment, 588 * signature, certificate signing) of the key contained in the 589 * certificate. 590 * The ASN.1 definition for this is: 591 * <pre> 592 * KeyUsage ::= BIT STRING { 593 * digitalSignature (0), 594 * nonRepudiation (1), 595 * keyEncipherment (2), 596 * dataEncipherment (3), 597 * keyAgreement (4), 598 * keyCertSign (5), 599 * cRLSign (6), 600 * encipherOnly (7), 601 * decipherOnly (8) } 602 * </pre> 603 * RFC 3280 recommends that when used, this be marked 604 * as a critical extension. 605 * 606 * @return the KeyUsage extension of this certificate, represented as 607 * an array of booleans. The order of KeyUsage values in the array is 608 * the same as in the above ASN.1 definition. The array will contain a 609 * value for each KeyUsage defined above. If the KeyUsage list encoded 610 * in the certificate is longer than the above list, it will not be 611 * truncated. Returns null if this certificate does not 612 * contain a KeyUsage extension. 613 */ 614 abstract bool[] getKeyUsage(); 615 616 /** 617 * Gets an unmodifiable list of Strings representing the OBJECT 618 * IDENTIFIERs of the {@code ExtKeyUsageSyntax} field of the 619 * extended key usage extension, (OID = 2.5.29.37). It indicates 620 * one or more purposes for which the certified key may be 621 * used, in addition to or in place of the basic purposes 622 * indicated in the key usage extension field. The ASN.1 623 * definition for this is: 624 * <pre> 625 * ExtKeyUsageSyntax ::= SEQUENCE SIZE (1..MAX) OF KeyPurposeId 626 * 627 * KeyPurposeId ::= OBJECT IDENTIFIER 628 * </pre> 629 * 630 * Key purposes may be defined by any organization with a 631 * need. Object identifiers used to identify key purposes shall be 632 * assigned in accordance with IANA or ITU-T Rec. X.660 | 633 * ISO/IEC/ITU 9834-1. 634 * <p> 635 * This method was added to version 1.4 of the Java 2 Platform Standard 636 * Edition. In order to maintain backwards compatibility with existing 637 * service providers, this method is not {@code abstract} 638 * and it provides a default implementation. Subclasses 639 * should override this method with a correct implementation. 640 * 641 * @return the ExtendedKeyUsage extension of this certificate, 642 * as an unmodifiable list of object identifiers represented 643 * as Strings. Returns null if this certificate does not 644 * contain an ExtendedKeyUsage extension. 645 * @throws CertificateParsingException if the extension cannot be decoded 646 * @since 1.4 647 */ 648 // List!string getExtendedKeyUsage() { 649 // return X509CertImpl.getExtendedKeyUsage(this); 650 // } 651 652 /** 653 * Gets the certificate constraints path length from the 654 * critical {@code BasicConstraints} extension, (OID = 2.5.29.19). 655 * <p> 656 * The basic constraints extension identifies whether the subject 657 * of the certificate is a Certificate Authority (CA) and 658 * how deep a certification path may exist through that CA. The 659 * {@code pathLenConstraint} field (see below) is meaningful 660 * only if {@code cA} is set to TRUE. In this case, it gives the 661 * maximum number of CA certificates that may follow this certificate in a 662 * certification path. A value of zero indicates that only an end-entity 663 * certificate may follow in the path. 664 * <p> 665 * The ASN.1 definition for this is: 666 * <pre> 667 * BasicConstraints ::= SEQUENCE { 668 * cA BOOLEAN DEFAULT FALSE, 669 * pathLenConstraint INTEGER (0..MAX) OPTIONAL } 670 * </pre> 671 * 672 * @return the value of {@code pathLenConstraint} if the 673 * BasicConstraints extension is present in the certificate and the 674 * subject of the certificate is a CA, otherwise -1. 675 * If the subject of the certificate is a CA and 676 * {@code pathLenConstraint} does not appear, 677 * {@code int.max} is returned to indicate that there is no 678 * limit to the allowed length of the certification path. 679 */ 680 abstract int getBasicConstraints(); 681 682 /** 683 * Gets an immutable collection of subject alternative names from the 684 * {@code SubjectAltName} extension, (OID = 2.5.29.17). 685 * <p> 686 * The ASN.1 definition of the {@code SubjectAltName} extension is: 687 * <pre> 688 * SubjectAltName ::= GeneralNames 689 * 690 * GeneralNames :: = SEQUENCE SIZE (1..MAX) OF GeneralName 691 * 692 * GeneralName ::= CHOICE { 693 * otherName [0] OtherName, 694 * rfc822Name [1] IA5String, 695 * dNSName [2] IA5String, 696 * x400Address [3] ORAddress, 697 * directoryName [4] Name, 698 * ediPartyName [5] EDIPartyName, 699 * uniformResourceIdentifier [6] IA5String, 700 * iPAddress [7] OCTET STRING, 701 * registeredID [8] OBJECT IDENTIFIER} 702 * </pre> 703 * <p> 704 * If this certificate does not contain a {@code SubjectAltName} 705 * extension, {@code null} is returned. Otherwise, a 706 * {@code Collection} is returned with an entry representing each 707 * {@code GeneralName} included in the extension. Each entry is a 708 * {@code List} whose first entry is an {@code Integer} 709 * (the name type, 0-8) and whose second entry is a {@code string} 710 * or a byte array (the name, in string or ASN.1 DER encoded form, 711 * respectively). 712 * <p> 713 * <a href="http://www.ietf.org/rfc/rfc822.txt">RFC 822</a>, DNS, and URI 714 * names are returned as {@code string}s, 715 * using the well-established string formats for those types (subject to 716 * the restrictions included in RFC 3280). IPv4 address names are 717 * returned using dotted quad notation. IPv6 address names are returned 718 * in the form "a1:a2:...:a8", where a1-a8 are hexadecimal values 719 * representing the eight 16-bit pieces of the address. OID names are 720 * returned as {@code string}s represented as a series of nonnegative 721 * integers separated by periods. And directory names (distinguished names) 722 * are returned in <a href="http://www.ietf.org/rfc/rfc2253.txt"> 723 * RFC 2253</a> string format. No standard string format is 724 * defined for otherNames, X.400 names, EDI party names, or any 725 * other type of names. They are returned as byte arrays 726 * containing the ASN.1 DER encoded form of the name. 727 * <p> 728 * Note that the {@code Collection} returned may contain more 729 * than one name of the same type. Also, note that the returned 730 * {@code Collection} is immutable and any entries containing byte 731 * arrays are cloned to protect against subsequent modifications. 732 * <p> 733 * This method was added to version 1.4 of the Java 2 Platform Standard 734 * Edition. In order to maintain backwards compatibility with existing 735 * service providers, this method is not {@code abstract} 736 * and it provides a default implementation. Subclasses 737 * should override this method with a correct implementation. 738 * 739 * @return an immutable {@code Collection} of subject alternative 740 * names (or {@code null}) 741 * @throws CertificateParsingException if the extension cannot be decoded 742 * @since 1.4 743 */ 744 // Collection!(List<?>> getSubjectAlternativeNames() 745 // { 746 // return X509CertImpl.getSubjectAlternativeNames(this); 747 // } 748 749 /** 750 * Gets an immutable collection of issuer alternative names from the 751 * {@code IssuerAltName} extension, (OID = 2.5.29.18). 752 * <p> 753 * The ASN.1 definition of the {@code IssuerAltName} extension is: 754 * <pre> 755 * IssuerAltName ::= GeneralNames 756 * </pre> 757 * The ASN.1 definition of {@code GeneralNames} is defined 758 * in {@link #getSubjectAlternativeNames getSubjectAlternativeNames}. 759 * <p> 760 * If this certificate does not contain an {@code IssuerAltName} 761 * extension, {@code null} is returned. Otherwise, a 762 * {@code Collection} is returned with an entry representing each 763 * {@code GeneralName} included in the extension. Each entry is a 764 * {@code List} whose first entry is an {@code Integer} 765 * (the name type, 0-8) and whose second entry is a {@code string} 766 * or a byte array (the name, in string or ASN.1 DER encoded form, 767 * respectively). For more details about the formats used for each 768 * name type, see the {@code getSubjectAlternativeNames} method. 769 * <p> 770 * Note that the {@code Collection} returned may contain more 771 * than one name of the same type. Also, note that the returned 772 * {@code Collection} is immutable and any entries containing byte 773 * arrays are cloned to protect against subsequent modifications. 774 * <p> 775 * This method was added to version 1.4 of the Java 2 Platform Standard 776 * Edition. In order to maintain backwards compatibility with existing 777 * service providers, this method is not {@code abstract} 778 * and it provides a default implementation. Subclasses 779 * should override this method with a correct implementation. 780 * 781 * @return an immutable {@code Collection} of issuer alternative 782 * names (or {@code null}) 783 * @throws CertificateParsingException if the extension cannot be decoded 784 * @since 1.4 785 */ 786 // Collection<List<?>> getIssuerAlternativeNames() 787 // { 788 // return X509CertImpl.getIssuerAlternativeNames(this); 789 // } 790 791 /** 792 * Verifies that this certificate was signed using the 793 * private key that corresponds to the specified key. 794 * This method uses the signature verification engine 795 * supplied by the specified provider. Note that the specified 796 * Provider object does not have to be registered in the provider list. 797 * 798 * This method was added to version 1.8 of the Java Platform Standard 799 * Edition. In order to maintain backwards compatibility with existing 800 * service providers, this method is not {@code abstract} 801 * and it provides a default implementation. 802 * 803 * @param key the PublicKey used to carry out the verification. 804 * @param sigProvider the signature provider. 805 * 806 * @exception NoSuchAlgorithmException on unsupported signature 807 * algorithms. 808 * @exception InvalidKeyException on incorrect key. 809 * @exception SignatureException on signature errors. 810 * @exception CertificateException on encoding errors. 811 * @exception UnsupportedOperationException if the method is not supported 812 * @since 1.8 813 */ 814 override void verify(PublicKey key, Provider sigProvider) { 815 // X509CertImpl.verify(this, key, sigProvider); 816 817 implementationMissing(); 818 } 819 }