/** * Returns an instance of this from a <code>X509CRLSelector</code>. * * @param selector A <code>X509CRLSelector</code> instance. * @return An instance of an <code>X509CRLStoreSelector</code>. * @exception IllegalArgumentException if selector is null or creation * fails. */ public static X509CRLStoreSelector getInstance(X509CRLSelector selector) { if (selector == null) { throw new IllegalArgumentException( "cannot create from null selector"); } X509CRLStoreSelector cs = new X509CRLStoreSelector(); cs.setCertificateChecking(selector.getCertificateChecking()); cs.setDateAndTime(selector.getDateAndTime()); try { cs.setIssuerNames(selector.getIssuerNames()); } catch (IOException e) { // cannot happen throw new IllegalArgumentException(e.getMessage()); } cs.setIssuers(selector.getIssuers()); cs.setMaxCRLNumber(selector.getMaxCRL()); cs.setMinCRLNumber(selector.getMinCRL()); return cs; }
/** * @tests java.security.cert.X509CRLSelector#addIssuer(javax.security.auth.x500.X500Principal) */ @TestTargetNew( level = TestLevel.PARTIAL_COMPLETE, notes = "", method = "addIssuer", args = {javax.security.auth.x500.X500Principal.class} ) public void test_addIssuerLjavax_security_auth_x500_X500Principal01() throws Exception { //Regression for HARMONY-465 X509CRLSelector obj = new X509CRLSelector(); try { obj.addIssuer((X500Principal) null); fail("NullPointerException expected"); } catch (NullPointerException e) { // expected } }
/** * @tests java.security.cert.X509CRLSelector#addIssuerName(byte[]) */ @TestTargetNew( level = TestLevel.PARTIAL_COMPLETE, notes = "Verifies IOException.", method = "addIssuerName", args = {byte[].class} ) public void test_addIssuerName$B_3() throws Exception { //Regression for HARMONY-465 X509CRLSelector obj = new X509CRLSelector(); try { obj.addIssuerName(new byte[] { (byte) 2, (byte) 3, (byte) 4 }); fail("IOException expected"); } catch (IOException e) { // expected } }
/** * @tests java.security.cert.X509CRLSelector#addIssuerName(byte[]) */ @TestTargetNew( level = TestLevel.PARTIAL_COMPLETE, notes = "Verifies NullPointerException.", method = "addIssuerName", args = {byte[].class} ) public void test_addIssuerName$B_4() throws Exception { //Regression for HARMONY-465 X509CRLSelector obj = new X509CRLSelector(); try { obj.addIssuerName((byte[]) null); fail("NullPointerException expected"); } catch (NullPointerException e) { // expected } }
/** * @tests setIssuerNames(Collection <?> names) */ @TestTargetNew( level = TestLevel.PARTIAL, notes = "Regression test.", method = "setIssuerNames", args = {java.util.Collection.class} ) public void test_setIssuerNamesLjava_util_Collection01() throws IOException { // Regression for HARMONY-737 X509CRLSelector selector = new X509CRLSelector(); selector.setIssuerNames(new TreeSet<Comparable>() { private static final long serialVersionUID = 6009545505321092498L; public Iterator<Comparable> iterator() { return null; } }); }
/** * constructor testing. * */ @TestTargetNew( level = TestLevel.COMPLETE, notes = "", method = "X509CRLSelector", args = {} ) public void testX509CRLSelector() { X509CRLSelector selector = new X509CRLSelector(); assertNull(selector.getDateAndTime()); assertNull(selector.getCertificateChecking()); assertNull(selector.getIssuerNames()); assertNull(selector.getIssuers()); assertNull(selector.getMaxCRL()); assertNull(selector.getMinCRL()); }
/** * setMinCRLNumber(BigInteger minCRL) method testing. Tests if CRLs with any * crl number value match the selector in the case of null crlNumber * criteria, if specified minCRL value matches the selector, and if CRL with * inappropriate crlNumber value does not match the selector. */ @TestTargetNew( level = TestLevel.COMPLETE, notes = "", method = "setMinCRLNumber", args = {java.math.BigInteger.class} ) @AndroidOnly("Uses specific class: " + "org.apache.harmony.security.asn1.ASN1OctetString.") public void testSetMinCRLNumberLjava_math_BigInteger() { X509CRLSelector selector = new X509CRLSelector(); BigInteger minCRL = new BigInteger("10000"); CRL crl = new TestCRL(minCRL); selector.setMinCRLNumber(null); assertTrue("Any CRL should match in the case of null minCRLNumber.", selector.match(crl)); selector.setMinCRLNumber(minCRL); assertTrue("The CRL should match the selection criteria.", selector .match(crl)); selector.setMinCRLNumber(new BigInteger("10001")); assertFalse("The CRL should not match the selection criteria.", selector.match(crl)); }
/** * setMaxCRLNumber(BigInteger maxCRL) method testing. Tests if CRLs with any * crl number value match the selector in the case of null crlNumber * criteria, if specified maxCRL value matches the selector, and if CRL with * inappropriate crlNumber value does not match the selector. */ @TestTargetNew( level = TestLevel.COMPLETE, notes = "", method = "setMaxCRLNumber", args = {java.math.BigInteger.class} ) @AndroidOnly("Uses specific class: " + "org.apache.harmony.security.asn1.ASN1OctetString.") public void testSetMaxCRLNumberLjava_math_BigInteger() { X509CRLSelector selector = new X509CRLSelector(); BigInteger maxCRL = new BigInteger("10000"); TestCRL crl = new TestCRL(maxCRL); selector.setMaxCRLNumber(null); assertTrue("Any CRL should match in the case of null minCRLNumber.", selector.match(crl)); selector.setMaxCRLNumber(maxCRL); assertTrue("The CRL should match the selection criteria.", selector .match(crl)); selector.setMaxCRLNumber(new BigInteger("9999")); assertFalse("The CRL should not match the selection criteria.", selector.match(crl)); }
/** * getIssuers() method testing. Tests if the method return null in the case * of not specified issuers, if the returned collection corresponds to the * specified issuers and this collection is unmodifiable. */ @TestTargetNew( level = TestLevel.COMPLETE, notes = "", method = "getIssuers", args = {} ) public void testGetIssuers() { X509CRLSelector selector = new X509CRLSelector(); X500Principal iss1 = new X500Principal("O=First Org."); X500Principal iss2 = new X500Principal("O=Second Org."); X500Principal iss3 = new X500Principal("O=Third Org."); assertNull("The collection should be null.", selector.getIssuers()); selector.addIssuer(iss1); selector.addIssuer(iss2); Collection<X500Principal> result = selector.getIssuers(); try { result.add(iss3); fail("The returned collection should be unmodifiable."); } catch (UnsupportedOperationException e) { } assertTrue("The collection should contain the specified DN.", result .contains(iss2)); }
/** * getDateAndTime() method testing. Tests if the method return null in the * case of not specified dateAndTime criteria, and if the returned value * corresponds to the specified one. */ @TestTargetNew( level = TestLevel.COMPLETE, notes = "", method = "getDateAndTime", args = {} ) public void testGetDateAndTime() { X509CRLSelector selector = new X509CRLSelector(); assertNull("Initially the dateAndTime criteria should be null.", selector.getDateAndTime()); Date date = new Date(200); selector.setDateAndTime(date); assertTrue("The result should be equal to specified.", date .equals(selector.getDateAndTime())); }
/** * getCertificateChecking() method testing. */ @TestTargetNew( level = TestLevel.COMPLETE, notes = "", method = "getCertificateChecking", args = {} ) public void testGetCertificateCheckingLjava_X509Certificate() throws CertificateException { X509CRLSelector selector = new X509CRLSelector(); CertificateFactory certFact = CertificateFactory.getInstance("X509"); X509Certificate cert = (X509Certificate) certFact .generateCertificate(new ByteArrayInputStream(TestUtils .getX509Certificate_v3())); selector.setCertificateChecking(cert); assertEquals(cert, selector.getCertificateChecking()); selector.setCertificateChecking(null); assertNull(selector.getCertificateChecking()); }
@TestTargetNew( level = TestLevel.COMPLETE, notes = "", method = "toString", args = {} ) public void testToString() { X509CRLSelector selector = new X509CRLSelector(); X500Principal iss1 = new X500Principal("O=First Org."); X500Principal iss2 = new X500Principal("O=Second Org."); BigInteger minCRL = new BigInteger("10000"); BigInteger maxCRL = new BigInteger("10000"); Date date = new Date(200); selector.addIssuer(iss1); selector.addIssuer(iss2); selector.setMinCRLNumber(minCRL); selector.setMaxCRLNumber(maxCRL); selector.setDateAndTime(date); assertNotNull("The result should not be null.", selector.toString()); }
/** * Returns an instance of this from a <code>X509CRLSelector</code>. * * @param selector A <code>X509CRLSelector</code> instance. * @return An instance of an <code>X509CRLStoreSelector</code>. * @exception IllegalArgumentException if selector is null or creation * fails. */ public static X509CRLStoreSelector getInstance(X509CRLSelector selector) { if (selector == null) { throw new IllegalArgumentException( "cannot create from null selector"); } X509CRLStoreSelector cs = new X509CRLStoreSelector(); cs.setCertificateChecking(selector.getCertificateChecking()); cs.setDateAndTime(selector.getDateAndTime()); try { cs.setIssuerNames(selector.getIssuerNames()); } catch (IOException e) { // cannot happen throw new IllegalArgumentException(e.getMessage()); } //cs.setIssuers(selector.getIssuers()); cs.setMaxCRLNumber(selector.getMaxCRL()); cs.setMinCRLNumber(selector.getMinCRL()); return cs; }
/** * Return a Collection of all CRLs found in the * CertStore's that are matching the crlSelect criteriums. * * @param certSelector a {@link CertSelector CertSelector} * object that will be used to select the certificates * @param certStores a List containing only {@link CertStore * CertStore} objects. These are used to search for * CRLs * * @return a Collection of all found {@link CRL CRL} * objects. May be empty but never <code>null</code>. */ private Collection findCRLs( X509CRLSelector crlSelect, List crlStores) throws AnnotatedException { Set crls = new HashSet(); Iterator iter = crlStores.iterator(); while (iter.hasNext()) { CertStore certStore = (CertStore)iter.next(); try { crls.addAll(certStore.getCRLs(crlSelect)); } catch (CertStoreException e) { throw new AnnotatedException("cannot extract crl: " + e, e); } } return crls; }
@Override public X509CRLSelector wrap(X509CRLSelector selector, Collection<X500Principal> certIssuers, String ldapDN) throws IOException { throw new UnsupportedOperationException(); }
@Override public X509CRLSelector wrap(X509CRLSelector selector, Collection<X500Principal> certIssuers, String ldapDN) throws IOException { return new LDAPCertStore.LDAPCRLSelector(selector, certIssuers, ldapDN); }
public X509Certificate getCertificateChecking() { if (baseSelector instanceof X509CRLSelector) { return ((X509CRLSelector)baseSelector).getCertificateChecking(); } return null; }
/** * @tests java.security.cert.X509CRLSelector#addIssuerName(java.lang.String) */ @TestTargetNew( level = TestLevel.PARTIAL_COMPLETE, notes = "Verifies null as a parameter.", method = "addIssuerName", args = {java.lang.String.class} ) public void test_addIssuerNameLjava_lang_String02() throws IOException { // Regression for HARMONY-736 X509CRLSelector selector = new X509CRLSelector(); // no exception for null selector.addIssuerName((String) null); }
/** * addIssuer(X500Principal issuer) method testing. Tests if CRLs with * specified issuers match the selector, and if not specified issuer does * not match the selector. */ @TestTargets({ @TestTargetNew( level = TestLevel.PARTIAL_COMPLETE, notes = "", method = "addIssuer", args = {javax.security.auth.x500.X500Principal.class} ), @TestTargetNew( level=TestLevel.PARTIAL_COMPLETE, method="match", args={java.security.cert.CRL.class} ) }) public void testAddIssuerLjavax_security_auth_x500_X500Principal02() { X509CRLSelector selector = new X509CRLSelector(); X500Principal iss1 = new X500Principal("O=First Org."); X500Principal iss2 = new X500Principal("O=Second Org."); CRL crl1 = new TestCRL(iss1); CRL crl2 = new TestCRL(iss2); selector.addIssuer(iss1); assertTrue("The CRL should match the selection criteria.", selector .match(crl1)); assertFalse("The CRL should not match the selection criteria.", selector.match(crl2)); selector.addIssuer(iss2); assertTrue("The CRL should match the selection criteria.", selector .match(crl2)); }
/** * setIssuers(Collection <X500Principal> issuers) method testing. Tests if * CRLs with any issuers match the selector in the case of null issuerNames * criteria, if specified issuers match the selector, and if not specified * issuer does not match the selector. */ @TestTargetNew( level = TestLevel.COMPLETE, notes = "", method = "setIssuers", args = {java.util.Collection.class} ) public void testSetIssuersLjava_util_Collection() { X509CRLSelector selector = new X509CRLSelector(); X500Principal iss1 = new X500Principal("O=First Org."); X500Principal iss2 = new X500Principal("O=Second Org."); X500Principal iss3 = new X500Principal("O=Third Org."); TestCRL crl1 = new TestCRL(iss1); TestCRL crl2 = new TestCRL(iss2); TestCRL crl3 = new TestCRL(iss3); selector.setIssuers(null); assertTrue("Any CRL issuers should match in the case of null issuers.", selector.match(crl1) && selector.match(crl2)); ArrayList<X500Principal> issuers = new ArrayList<X500Principal>(2); issuers.add(iss1); issuers.add(iss2); selector.setIssuers(issuers); assertTrue("The CRL should match the selection criteria.", selector .match(crl1) && selector.match(crl2)); assertFalse("The CRL should not match the selection criteria.", selector.match(crl3)); issuers.add(iss3); assertFalse("The internal issuer collection is not protected " + "against the modifications.", selector.match(crl3)); }
/** * setDateAndTime(Date dateAndTime) method testing. Tests if CRLs with any * update dates match the selector in the case of null dateAndTime criteria, * if correct dates match and incorrect do not match the selector. */ @TestTargetNew( level = TestLevel.COMPLETE, notes = "", method = "setDateAndTime", args = {java.util.Date.class} ) public void testSetDateAndTimeLjava_util_Date() { X509CRLSelector selector = new X509CRLSelector(); TestCRL crl = new TestCRL(new Date(200), new Date(300)); selector.setDateAndTime(null); assertTrue("Any CRL should match in the case of null dateAndTime.", selector.match(crl)); selector.setDateAndTime(new Date(200)); assertTrue("The CRL should match the selection criteria.", selector .match(crl)); selector.setDateAndTime(new Date(250)); assertTrue("The CRL should match the selection criteria.", selector .match(crl)); selector.setDateAndTime(new Date(300)); assertTrue("The CRL should match the selection criteria.", selector .match(crl)); selector.setDateAndTime(new Date(150)); assertFalse("The CRL should not match the selection criteria.", selector.match(crl)); selector.setDateAndTime(new Date(350)); assertFalse("The CRL should not match the selection criteria.", selector.match(crl)); }