1package tests.security.cert; 2 3import dalvik.annotation.AndroidOnly; 4import dalvik.annotation.TestLevel; 5import dalvik.annotation.TestTargetClass; 6import dalvik.annotation.TestTargetNew; 7import dalvik.annotation.TestTargets; 8 9import junit.framework.TestCase; 10 11import org.apache.harmony.security.asn1.ASN1Integer; 12import org.apache.harmony.security.asn1.ASN1OctetString; 13import org.apache.harmony.security.tests.support.cert.TestUtils; 14 15import java.io.ByteArrayInputStream; 16import java.io.IOException; 17import java.math.BigInteger; 18import java.security.InvalidKeyException; 19import java.security.NoSuchAlgorithmException; 20import java.security.NoSuchProviderException; 21import java.security.Principal; 22import java.security.PublicKey; 23import java.security.SignatureException; 24import java.security.cert.CRL; 25import java.security.cert.CRLException; 26import java.security.cert.Certificate; 27import java.security.cert.CertificateException; 28import java.security.cert.CertificateFactory; 29import java.security.cert.X509CRL; 30import java.security.cert.X509CRLEntry; 31import java.security.cert.X509CRLSelector; 32import java.security.cert.X509Certificate; 33import java.util.ArrayList; 34import java.util.Collection; 35import java.util.Date; 36import java.util.Set; 37 38import javax.security.auth.x500.X500Principal; 39@TestTargetClass(X509CRLSelector.class) 40public class X509CRLSelector2Test extends TestCase { 41 42 protected void setUp() throws Exception { 43 super.setUp(); 44 } 45 46 protected void tearDown() throws Exception { 47 super.tearDown(); 48 } 49 50 /** 51 * constructor testing. 52 * 53 */ 54 @TestTargetNew( 55 level = TestLevel.COMPLETE, 56 notes = "", 57 method = "X509CRLSelector", 58 args = {} 59 ) 60 public void testX509CRLSelector() { 61 X509CRLSelector selector = new X509CRLSelector(); 62 assertNull(selector.getDateAndTime()); 63 assertNull(selector.getCertificateChecking()); 64 assertNull(selector.getIssuerNames()); 65 assertNull(selector.getIssuers()); 66 assertNull(selector.getMaxCRL()); 67 assertNull(selector.getMinCRL()); 68 } 69 70 /** 71 * addIssuer(X500Principal issuer) method testing. Tests if CRLs with 72 * specified issuers match the selector, and if not specified issuer does 73 * not match the selector. 74 */ 75 @TestTargets({ 76 @TestTargetNew( 77 level = TestLevel.PARTIAL_COMPLETE, 78 notes = "", 79 method = "addIssuer", 80 args = {javax.security.auth.x500.X500Principal.class} 81 ), 82 @TestTargetNew( 83 level=TestLevel.PARTIAL_COMPLETE, 84 method="match", 85 args={java.security.cert.CRL.class} 86 ) 87 }) 88 public void testAddIssuerLjavax_security_auth_x500_X500Principal02() { 89 X509CRLSelector selector = new X509CRLSelector(); 90 X500Principal iss1 = new X500Principal("O=First Org."); 91 X500Principal iss2 = new X500Principal("O=Second Org."); 92 CRL crl1 = new TestCRL(iss1); 93 CRL crl2 = new TestCRL(iss2); 94 95 selector.addIssuer(iss1); 96 assertTrue("The CRL should match the selection criteria.", selector 97 .match(crl1)); 98 assertFalse("The CRL should not match the selection criteria.", 99 selector.match(crl2)); 100 selector.addIssuer(iss2); 101 assertTrue("The CRL should match the selection criteria.", selector 102 .match(crl2)); 103 } 104 105 /** 106 * addIssuerName(String name) method testing. Tests if CRLs with specified 107 * issuers match the selector, and if not specified issuer does not match 108 * the selector. 109 */ 110 @TestTargetNew( 111 level = TestLevel.PARTIAL_COMPLETE, 112 notes = "Doesn't verify IOException.", 113 method = "addIssuerName", 114 args = {java.lang.String.class} 115 ) 116 public void testAddIssuerNameLjava_lang_String03() { 117 X509CRLSelector selector = new X509CRLSelector(); 118 String iss1 = "O=First Org."; 119 String iss2 = "O=Second Org."; 120 TestCRL crl1 = new TestCRL(new X500Principal(iss1)); 121 TestCRL crl2 = new TestCRL(new X500Principal(iss2)); 122 123 try { 124 selector.addIssuerName(iss1); 125 } catch (IOException e) { 126 e.printStackTrace(); 127 fail("Unexpected IOException was thrown."); 128 } 129 assertTrue("The CRL should match the selection criteria.", selector 130 .match(crl1)); 131 assertFalse("The CRL should not match the selection criteria.", 132 selector.match(crl2)); 133 try { 134 selector.addIssuerName(iss2); 135 } catch (IOException e) { 136 e.printStackTrace(); 137 fail("Unexpected IOException was thrown."); 138 } 139 assertTrue("The CRL should match the selection criteria.", selector 140 .match(crl2)); 141 } 142 143 /** 144 * setIssuerNames(Collection <?> names) method testing. Tests if CRLs with 145 * any issuers match the selector in the case of null issuerNames criteria, 146 * if specified issuers match the selector, if not specified issuer does not 147 * match the selector, and if the internal collection of issuer names is 148 * copied during initialization. 149 */ 150 @TestTargetNew( 151 level = TestLevel.COMPLETE, 152 notes = "", 153 method = "setIssuerNames", 154 args = {java.util.Collection.class} 155 ) 156 @SuppressWarnings("unchecked") 157 public void testSetIssuerNamesLjava_util_Collection02() { 158 X509CRLSelector selector = new X509CRLSelector(); 159 String iss1 = "O=First Org."; 160 byte[] iss2 = new byte[] 161 // manually obtained DER encoding of "O=Second Org." issuer name; 162 { 48, 22, 49, 20, 48, 18, 6, 3, 85, 4, 10, 19, 11, 83, 101, 99, 111, 163 110, 100, 32, 79, 114, 103, 46 }; 164 165 String iss3 = "O=Third Org."; 166 TestCRL crl1 = new TestCRL(new X500Principal(iss1)); 167 TestCRL crl2 = new TestCRL(new X500Principal(iss2)); 168 TestCRL crl3 = new TestCRL(new X500Principal(iss3)); 169 170 try { 171 selector.setIssuerNames(null); 172 } catch (IOException e) { 173 e.printStackTrace(); 174 fail("Unexpected IOException was thrown."); 175 } 176 assertTrue("Any CRL issuers should match in the case of null issuers.", 177 selector.match(crl1) && selector.match(crl2)); 178 179 ArrayList issuers = new ArrayList(2); 180 issuers.add(iss1); 181 issuers.add(iss2); 182 try { 183 selector.setIssuerNames(issuers); 184 } catch (IOException e) { 185 e.printStackTrace(); 186 fail("Unexpected IOException was thrown."); 187 } 188 assertTrue("The CRL should match the selection criteria.", selector 189 .match(crl1) 190 && selector.match(crl2)); 191 assertFalse("The CRL should not match the selection criteria.", 192 selector.match(crl3)); 193 issuers.add(iss3); 194 assertFalse("The internal issuer collection is not protected " 195 + "against the modifications.", selector.match(crl3)); 196 } 197 198 /** 199 * setIssuers(Collection <X500Principal> issuers) method testing. Tests if 200 * CRLs with any issuers match the selector in the case of null issuerNames 201 * criteria, if specified issuers match the selector, and if not specified 202 * issuer does not match the selector. 203 */ 204 @TestTargetNew( 205 level = TestLevel.COMPLETE, 206 notes = "", 207 method = "setIssuers", 208 args = {java.util.Collection.class} 209 ) 210 public void testSetIssuersLjava_util_Collection() { 211 X509CRLSelector selector = new X509CRLSelector(); 212 X500Principal iss1 = new X500Principal("O=First Org."); 213 X500Principal iss2 = new X500Principal("O=Second Org."); 214 X500Principal iss3 = new X500Principal("O=Third Org."); 215 TestCRL crl1 = new TestCRL(iss1); 216 TestCRL crl2 = new TestCRL(iss2); 217 TestCRL crl3 = new TestCRL(iss3); 218 219 selector.setIssuers(null); 220 assertTrue("Any CRL issuers should match in the case of null issuers.", 221 selector.match(crl1) && selector.match(crl2)); 222 223 ArrayList<X500Principal> issuers = new ArrayList<X500Principal>(2); 224 issuers.add(iss1); 225 issuers.add(iss2); 226 selector.setIssuers(issuers); 227 assertTrue("The CRL should match the selection criteria.", selector 228 .match(crl1) 229 && selector.match(crl2)); 230 assertFalse("The CRL should not match the selection criteria.", 231 selector.match(crl3)); 232 issuers.add(iss3); 233 assertFalse("The internal issuer collection is not protected " 234 + "against the modifications.", selector.match(crl3)); 235 } 236 237 /** 238 * addIssuerName(byte[] name) method testing. Tests if CRLs with specified 239 * issuers match the selector, and if not specified issuer does not match 240 * the selector. 241 */ 242 @TestTargetNew( 243 level = TestLevel.PARTIAL_COMPLETE, 244 notes = "Doesn't verify IOException.", 245 method = "addIssuerName", 246 args = {byte[].class} 247 ) 248 public void testAddIssuerName$B() { 249 X509CRLSelector selector = new X509CRLSelector(); 250 byte[] iss1 = new byte[] 251 // manually obtained DER encoding of "O=First Org." issuer name; 252 { 48, 21, 49, 19, 48, 17, 6, 3, 85, 4, 10, 19, 10, 70, 105, 114, 115, 253 116, 32, 79, 114, 103, 46 }; 254 byte[] iss2 = new byte[] 255 // manually obtained DER encoding of "O=Second Org." issuer name; 256 { 48, 22, 49, 20, 48, 18, 6, 3, 85, 4, 10, 19, 11, 83, 101, 99, 111, 257 110, 100, 32, 79, 114, 103, 46 }; 258 TestCRL crl1 = new TestCRL(new X500Principal(iss1)); 259 TestCRL crl2 = new TestCRL(new X500Principal(iss2)); 260 261 try { 262 selector.addIssuerName(iss1); 263 } catch (IOException e) { 264 e.printStackTrace(); 265 fail("Unexpected IOException was thrown."); 266 } 267 assertTrue("The CRL should match the selection criteria.", selector 268 .match(crl1)); 269 assertFalse("The CRL should not match the selection criteria.", 270 selector.match(crl2)); 271 try { 272 selector.addIssuerName(iss2); 273 } catch (IOException e) { 274 e.printStackTrace(); 275 fail("Unexpected IOException was thrown."); 276 } 277 assertTrue("The CRL should match the selection criteria.", selector 278 .match(crl2)); 279 } 280 281 /** 282 * setMinCRLNumber(BigInteger minCRL) method testing. Tests if CRLs with any 283 * crl number value match the selector in the case of null crlNumber 284 * criteria, if specified minCRL value matches the selector, and if CRL with 285 * inappropriate crlNumber value does not match the selector. 286 */ 287 @TestTargetNew( 288 level = TestLevel.COMPLETE, 289 notes = "", 290 method = "setMinCRLNumber", 291 args = {java.math.BigInteger.class} 292 ) 293 @AndroidOnly("Uses specific class: " + 294 "org.apache.harmony.security.asn1.ASN1OctetString.") 295 public void testSetMinCRLNumberLjava_math_BigInteger() { 296 X509CRLSelector selector = new X509CRLSelector(); 297 BigInteger minCRL = new BigInteger("10000"); 298 CRL crl = new TestCRL(minCRL); 299 300 selector.setMinCRLNumber(null); 301 assertTrue("Any CRL should match in the case of null minCRLNumber.", 302 selector.match(crl)); 303 selector.setMinCRLNumber(minCRL); 304 assertTrue("The CRL should match the selection criteria.", selector 305 .match(crl)); 306 selector.setMinCRLNumber(new BigInteger("10001")); 307 assertFalse("The CRL should not match the selection criteria.", 308 selector.match(crl)); 309 } 310 311 /** 312 * setMaxCRLNumber(BigInteger maxCRL) method testing. Tests if CRLs with any 313 * crl number value match the selector in the case of null crlNumber 314 * criteria, if specified maxCRL value matches the selector, and if CRL with 315 * inappropriate crlNumber value does not match the selector. 316 */ 317 @TestTargetNew( 318 level = TestLevel.COMPLETE, 319 notes = "", 320 method = "setMaxCRLNumber", 321 args = {java.math.BigInteger.class} 322 ) 323 @AndroidOnly("Uses specific class: " + 324 "org.apache.harmony.security.asn1.ASN1OctetString.") 325 public void testSetMaxCRLNumberLjava_math_BigInteger() { 326 X509CRLSelector selector = new X509CRLSelector(); 327 BigInteger maxCRL = new BigInteger("10000"); 328 TestCRL crl = new TestCRL(maxCRL); 329 330 selector.setMaxCRLNumber(null); 331 assertTrue("Any CRL should match in the case of null minCRLNumber.", 332 selector.match(crl)); 333 selector.setMaxCRLNumber(maxCRL); 334 assertTrue("The CRL should match the selection criteria.", selector 335 .match(crl)); 336 selector.setMaxCRLNumber(new BigInteger("9999")); 337 assertFalse("The CRL should not match the selection criteria.", 338 selector.match(crl)); 339 } 340 341 /** 342 * setDateAndTime(Date dateAndTime) method testing. Tests if CRLs with any 343 * update dates match the selector in the case of null dateAndTime criteria, 344 * if correct dates match and incorrect do not match the selector. 345 */ 346 @TestTargetNew( 347 level = TestLevel.COMPLETE, 348 notes = "", 349 method = "setDateAndTime", 350 args = {java.util.Date.class} 351 ) 352 public void testSetDateAndTimeLjava_util_Date() { 353 X509CRLSelector selector = new X509CRLSelector(); 354 TestCRL crl = new TestCRL(new Date(200), new Date(300)); 355 selector.setDateAndTime(null); 356 assertTrue("Any CRL should match in the case of null dateAndTime.", 357 selector.match(crl)); 358 selector.setDateAndTime(new Date(200)); 359 assertTrue("The CRL should match the selection criteria.", selector 360 .match(crl)); 361 selector.setDateAndTime(new Date(250)); 362 assertTrue("The CRL should match the selection criteria.", selector 363 .match(crl)); 364 selector.setDateAndTime(new Date(300)); 365 assertTrue("The CRL should match the selection criteria.", selector 366 .match(crl)); 367 selector.setDateAndTime(new Date(150)); 368 assertFalse("The CRL should not match the selection criteria.", 369 selector.match(crl)); 370 selector.setDateAndTime(new Date(350)); 371 assertFalse("The CRL should not match the selection criteria.", 372 selector.match(crl)); 373 } 374 375 /** 376 * setCertificateChecking(X509Certificate) method testing. 377 */ 378 @TestTargetNew( 379 level = TestLevel.COMPLETE, 380 notes = "", 381 method = "setCertificateChecking", 382 args = {java.security.cert.X509Certificate.class} 383 ) 384 public void testSetCertificateCheckingLjava_X509Certificate() 385 throws CertificateException { 386 X509CRLSelector selector = new X509CRLSelector(); 387 388 CertificateFactory certFact = CertificateFactory.getInstance("X509"); 389 X509Certificate cert = (X509Certificate) certFact 390 .generateCertificate(new ByteArrayInputStream(TestUtils 391 .getX509Certificate_v3())); 392 393 TestCRL crl = new TestCRL(); 394 selector.setCertificateChecking(cert); 395 assertTrue("The CRL should match the selection criteria.", selector 396 .match(crl)); 397 assertEquals(cert, selector.getCertificateChecking()); 398 399 selector.setCertificateChecking(null); 400 assertTrue("The CRL should match the selection criteria.", selector 401 .match(crl)); 402 assertNull(selector.getCertificateChecking()); 403 } 404 405 /** 406 * getIssuers() method testing. Tests if the method return null in the case 407 * of not specified issuers, if the returned collection corresponds to the 408 * specified issuers and this collection is unmodifiable. 409 */ 410 @TestTargetNew( 411 level = TestLevel.COMPLETE, 412 notes = "", 413 method = "getIssuers", 414 args = {} 415 ) 416 public void testGetIssuers() { 417 X509CRLSelector selector = new X509CRLSelector(); 418 X500Principal iss1 = new X500Principal("O=First Org."); 419 X500Principal iss2 = new X500Principal("O=Second Org."); 420 X500Principal iss3 = new X500Principal("O=Third Org."); 421 assertNull("The collection should be null.", selector.getIssuers()); 422 selector.addIssuer(iss1); 423 selector.addIssuer(iss2); 424 Collection<X500Principal> result = selector.getIssuers(); 425 try { 426 result.add(iss3); 427 fail("The returned collection should be unmodifiable."); 428 } catch (UnsupportedOperationException e) { 429 } 430 assertTrue("The collection should contain the specified DN.", result 431 .contains(iss2)); 432 } 433 434 /** 435 * getIssuerNames() method testing. Tests if the method return null in the 436 * case of not specified issuers, if the returned collection corresponds to 437 * the specified issuers. 438 */ 439 @TestTargetNew( 440 level = TestLevel.COMPLETE, 441 notes = "", 442 method = "getIssuerNames", 443 args = {} 444 ) 445 public void testGetIssuerNames() { 446 X509CRLSelector selector = new X509CRLSelector(); 447 byte[] iss1 = new byte[] 448 // manually obtained DER encoding of "O=First Org." issuer name; 449 { 48, 21, 49, 19, 48, 17, 6, 3, 85, 4, 10, 19, 10, 70, 105, 114, 115, 450 116, 32, 79, 114, 103, 46 }; 451 byte[] iss2 = new byte[] 452 // manually obtained DER encoding of "O=Second Org." issuer name; 453 { 48, 22, 49, 20, 48, 18, 6, 3, 85, 4, 10, 19, 11, 83, 101, 99, 111, 454 110, 100, 32, 79, 114, 103, 46 }; 455 assertNull("The collection should be null.", selector.getIssuerNames()); 456 try { 457 selector.addIssuerName(iss1); 458 selector.addIssuerName(iss2); 459 } catch (IOException e) { 460 e.printStackTrace(); 461 fail("Unexpected IOException was thrown."); 462 } 463 Collection<Object> result = selector.getIssuerNames(); 464 assertEquals("The collection should contain all of the specified DNs.", 465 2, result.size()); 466 } 467 468 /** 469 * getMinCRL() method testing. Tests if the method return null in the case 470 * of not specified minCRL criteria, and if the returned value corresponds 471 * to the specified one. 472 */ 473 @TestTargetNew( 474 level = TestLevel.COMPLETE, 475 notes = "", 476 method = "getMinCRL", 477 args = {} 478 ) 479 public void testGetMinCRL() { 480 X509CRLSelector selector = new X509CRLSelector(); 481 assertNull("Initially the minCRL should be null.", selector.getMinCRL()); 482 BigInteger minCRL = new BigInteger("10000"); 483 selector.setMinCRLNumber(minCRL); 484 assertTrue("The result should be equal to specified.", minCRL 485 .equals(selector.getMinCRL())); 486 } 487 488 /** 489 * getMaxCRL() method testing. Tests if the method return null in the case 490 * of not specified maxCRL criteria, and if the returned value corresponds 491 * to the specified one. 492 */ 493 @TestTargetNew( 494 level = TestLevel.COMPLETE, 495 notes = "", 496 method = "getMaxCRL", 497 args = {} 498 ) 499 public void testGetMaxCRL() { 500 X509CRLSelector selector = new X509CRLSelector(); 501 assertNull("Initially the maxCRL should be null.", selector.getMaxCRL()); 502 BigInteger maxCRL = new BigInteger("10000"); 503 selector.setMaxCRLNumber(maxCRL); 504 assertTrue("The result should be equal to specified.", maxCRL 505 .equals(selector.getMaxCRL())); 506 } 507 508 /** 509 * getDateAndTime() method testing. Tests if the method return null in the 510 * case of not specified dateAndTime criteria, and if the returned value 511 * corresponds to the specified one. 512 */ 513 @TestTargetNew( 514 level = TestLevel.COMPLETE, 515 notes = "", 516 method = "getDateAndTime", 517 args = {} 518 ) 519 public void testGetDateAndTime() { 520 X509CRLSelector selector = new X509CRLSelector(); 521 assertNull("Initially the dateAndTime criteria should be null.", 522 selector.getDateAndTime()); 523 Date date = new Date(200); 524 selector.setDateAndTime(date); 525 assertTrue("The result should be equal to specified.", date 526 .equals(selector.getDateAndTime())); 527 } 528 529 /** 530 * getCertificateChecking() method testing. 531 */ 532 @TestTargetNew( 533 level = TestLevel.COMPLETE, 534 notes = "", 535 method = "getCertificateChecking", 536 args = {} 537 ) 538 public void testGetCertificateCheckingLjava_X509Certificate() 539 throws CertificateException { 540 X509CRLSelector selector = new X509CRLSelector(); 541 542 CertificateFactory certFact = CertificateFactory.getInstance("X509"); 543 X509Certificate cert = (X509Certificate) certFact 544 .generateCertificate(new ByteArrayInputStream(TestUtils 545 .getX509Certificate_v3())); 546 547 selector.setCertificateChecking(cert); 548 assertEquals(cert, selector.getCertificateChecking()); 549 550 selector.setCertificateChecking(null); 551 assertNull(selector.getCertificateChecking()); 552 } 553 554 /** 555 * match(CRL crl) method testing. Tests if the null object matches to the 556 * selector or not. 557 */ 558 @TestTargetNew( 559 level = TestLevel.PARTIAL_COMPLETE, 560 notes = "Doesn't verify not null value as parameter.", 561 method = "match", 562 args = {java.security.cert.CRL.class} 563 ) 564 public void testMatchLjava_security_cert_X509CRL() { 565 X509CRLSelector selector = new X509CRLSelector(); 566 assertFalse("The null object should not match", selector 567 .match((X509CRL) null)); 568 } 569 570 /** 571 * clone() method testing. Tests if the selector is cloned correctly: the 572 * crl which matche to the initial selector should match to the clone and 573 * the change of clone should not cause the change of initial selector. 574 */ 575 @TestTargetNew( 576 level = TestLevel.COMPLETE, 577 notes = "", 578 method = "clone", 579 args = {} 580 ) 581 @AndroidOnly("Uses specific classes: " + 582 "org.apache.harmony.security.asn1.ASN1OctetString, " + 583 "org.apache.harmony.security.asn1.ASN1Integer.") 584 public void testClone() { 585 X509CRLSelector selector = new X509CRLSelector(); 586 X500Principal iss1 = new X500Principal("O=First Org."); 587 X500Principal iss2 = new X500Principal("O=Second Org."); 588 X500Principal iss3 = new X500Principal("O=Third Org."); 589 BigInteger minCRL = new BigInteger("10000"); 590 BigInteger maxCRL = new BigInteger("10000"); 591 Date date = new Date(200); 592 593 selector.addIssuer(iss1); 594 selector.addIssuer(iss2); 595 selector.setMinCRLNumber(minCRL); 596 selector.setMaxCRLNumber(maxCRL); 597 selector.setDateAndTime(date); 598 599 X509CRLSelector clone = (X509CRLSelector) selector.clone(); 600 TestCRL crl = new TestCRL(iss1); 601 crl.setCrlNumber(minCRL); 602 crl.setUpdateDates(new Date(200), new Date(200)); 603 assertTrue("The specified CRL should match the clone selector.", 604 selector.match(crl)); 605 606 clone.addIssuer(iss3); 607 assertFalse("The changes of the clone selector should not cause " 608 + "the changes of initial object", selector.getIssuerNames() 609 .size() == 3); 610 } 611 @TestTargetNew( 612 level = TestLevel.COMPLETE, 613 notes = "", 614 method = "toString", 615 args = {} 616 ) 617 public void testToString() { 618 X509CRLSelector selector = new X509CRLSelector(); 619 X500Principal iss1 = new X500Principal("O=First Org."); 620 X500Principal iss2 = new X500Principal("O=Second Org."); 621 BigInteger minCRL = new BigInteger("10000"); 622 BigInteger maxCRL = new BigInteger("10000"); 623 Date date = new Date(200); 624 625 selector.addIssuer(iss1); 626 selector.addIssuer(iss2); 627 selector.setMinCRLNumber(minCRL); 628 selector.setMaxCRLNumber(maxCRL); 629 selector.setDateAndTime(date); 630 631 assertNotNull("The result should not be null.", selector.toString()); 632 } 633 634 /** 635 * The abstract class stub implementation. 636 */ 637 private class TestCRL extends X509CRL { 638 639 private X500Principal principal = null; 640 641 private BigInteger crlNumber = null; 642 643 private Date thisUpdate = null; 644 645 private Date nextUpdate = null; 646 647 public TestCRL() { 648 } 649 650 public TestCRL(X500Principal principal) { 651 this.principal = principal; 652 } 653 654 public TestCRL(Date thisUpdate, Date nextUpdate) { 655 setUpdateDates(thisUpdate, nextUpdate); 656 } 657 658 public TestCRL(BigInteger crlNumber) { 659 setCrlNumber(crlNumber); 660 } 661 662 public void setUpdateDates(Date thisUpdate, Date nextUpdate) { 663 this.thisUpdate = thisUpdate; 664 this.nextUpdate = nextUpdate; 665 } 666 667 public void setCrlNumber(BigInteger crlNumber) { 668 this.crlNumber = crlNumber; 669 } 670 671 public X500Principal getIssuerX500Principal() { 672 return principal; 673 } 674 675 public String toString() { 676 return null; 677 } 678 679 public boolean isRevoked(Certificate cert) { 680 return true; 681 } 682 683 public Set<String> getNonCriticalExtensionOIDs() { 684 return null; 685 } 686 687 public Set<String> getCriticalExtensionOIDs() { 688 return null; 689 } 690 691 public byte[] getExtensionValue(String oid) { 692 if ("2.5.29.20".equals(oid) && (crlNumber != null)) { 693 return ASN1OctetString.getInstance().encode( 694 ASN1Integer.getInstance().encode( 695 crlNumber.toByteArray())); 696 } 697 return null; 698 } 699 700 public boolean hasUnsupportedCriticalExtension() { 701 return false; 702 } 703 704 public byte[] getEncoded() { 705 return null; 706 } 707 708 @SuppressWarnings("unused") 709 public void verify(PublicKey key) throws CRLException, 710 NoSuchAlgorithmException, InvalidKeyException, 711 NoSuchProviderException, SignatureException { 712 } 713 714 @SuppressWarnings("unused") 715 public void verify(PublicKey key, String sigProvider) 716 throws CRLException, NoSuchAlgorithmException, 717 InvalidKeyException, NoSuchProviderException, 718 SignatureException { 719 } 720 721 public int getVersion() { 722 return 2; 723 } 724 725 public Principal getIssuerDN() { 726 return null; 727 } 728 729 public Date getThisUpdate() { 730 return thisUpdate; 731 } 732 733 public Date getNextUpdate() { 734 return nextUpdate; 735 } 736 737 public X509CRLEntry getRevokedCertificate(BigInteger serialNumber) { 738 return null; 739 } 740 741 public Set<X509CRLEntry> getRevokedCertificates() { 742 return null; 743 } 744 745 public byte[] getTBSCertList() { 746 return null; 747 } 748 749 public byte[] getSignature() { 750 return null; 751 } 752 753 public String getSigAlgName() { 754 return null; 755 } 756 757 public String getSigAlgOID() { 758 return null; 759 } 760 761 public byte[] getSigAlgParams() { 762 return null; 763 } 764 } 765} 766