java.security.cert.X509CRLSelector Java Examples

The following examples show how to use java.security.cert.X509CRLSelector. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: X509CRLSelector2Test.java    From j2objc with Apache License 2.0 6 votes vote down vote up
/**
 * 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.
 */
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));
}
 
Example #2
Source File: X509CRLSelector2Test.java    From j2objc with Apache License 2.0 6 votes vote down vote up
/**
 * getIssuerNames() method testing. Tests if the method return null in the
 * case of not specified issuers, if the returned collection corresponds to
 * the specified issuers.
 */
public void testGetIssuerNames() {
    X509CRLSelector selector = new X509CRLSelector();
    byte[] iss1 = new byte[]
    // manually obtained DER encoding of "O=First Org." issuer name;
    { 48, 21, 49, 19, 48, 17, 6, 3, 85, 4, 10, 19, 10, 70, 105, 114, 115,
            116, 32, 79, 114, 103, 46 };
    byte[] iss2 = new byte[]
    // manually obtained DER encoding of "O=Second Org." issuer name;
    { 48, 22, 49, 20, 48, 18, 6, 3, 85, 4, 10, 19, 11, 83, 101, 99, 111,
            110, 100, 32, 79, 114, 103, 46 };
    assertNull("The collection should be null.", selector.getIssuerNames());
    try {
        selector.addIssuerName(iss1);
        selector.addIssuerName(iss2);
    } catch (IOException e) {
        e.printStackTrace();
        fail("Unexpected IOException was thrown.");
    }
    Collection<Object> result = selector.getIssuerNames();
    assertEquals("The collection should contain all of the specified DNs.",
            2, result.size());
}
 
Example #3
Source File: X509CRLStoreSelector.java    From ripple-lib-java with ISC License 6 votes vote down vote up
/**
 * 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;
}
 
Example #4
Source File: X509CRLSelector2Test.java    From j2objc with Apache License 2.0 6 votes vote down vote up
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());
}
 
Example #5
Source File: X509CRLStoreSelector.java    From RipplePower with Apache License 2.0 6 votes vote down vote up
/**
 * 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;
}
 
Example #6
Source File: X509CRLSelector2Test.java    From j2objc with Apache License 2.0 6 votes vote down vote up
/**
 * addIssuer(X500Principal issuer) method testing. Tests if CRLs with
 * specified issuers match the selector, and if not specified issuer does
 * not match the selector.
 */
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));
}
 
Example #7
Source File: X509CRLSelector2Test.java    From j2objc with Apache License 2.0 6 votes vote down vote up
/**
 * 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.
 */
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));
}
 
Example #8
Source File: X509CRLSelector2Test.java    From j2objc with Apache License 2.0 6 votes vote down vote up
/**
 * 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.
 */
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));
}
 
Example #9
Source File: X509CRLSelector2Test.java    From j2objc with Apache License 2.0 6 votes vote down vote up
/**
 * 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.
 */
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));
}
 
Example #10
Source File: X509CRLSelector2Test.java    From j2objc with Apache License 2.0 6 votes vote down vote up
/**
 * setCertificateChecking(X509Certificate) method testing.
 */
public void testSetCertificateCheckingLjava_X509Certificate()
        throws CertificateException {
    X509CRLSelector selector = new X509CRLSelector();

    CertificateFactory certFact = CertificateFactory.getInstance("X509");
    X509Certificate cert = (X509Certificate) certFact
            .generateCertificate(new ByteArrayInputStream(TestUtils
                    .getX509Certificate_v3()));

    TestCRL crl = new TestCRL();
    selector.setCertificateChecking(cert);
    assertTrue("The CRL should match the selection criteria.", selector
            .match(crl));
    assertEquals(cert, selector.getCertificateChecking());

    selector.setCertificateChecking(null);
    assertTrue("The CRL should match the selection criteria.", selector
            .match(crl));
    assertNull(selector.getCertificateChecking());
}
 
Example #11
Source File: X509CRLSelectorTest.java    From j2objc with Apache License 2.0 5 votes vote down vote up
/**
 * java.security.cert.X509CRLSelector#addIssuer(javax.security.auth.x500.X500Principal)
 */
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
    }
}
 
Example #12
Source File: SSLServerCertStoreHelper.java    From openjdk-jdk8u with GNU General Public License v2.0 5 votes vote down vote up
@Override
public X509CRLSelector wrap(X509CRLSelector selector,
                            Collection<X500Principal> certIssuers,
                            String ldapDN)
    throws IOException
{
    throw new UnsupportedOperationException();
}
 
Example #13
Source File: X509CRLSelectorTest.java    From j2objc with Apache License 2.0 5 votes vote down vote up
/**
 * java.security.cert.X509CRLSelector#addIssuerName(byte[])
 */
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
    }
}
 
Example #14
Source File: X509CRLSelectorTest.java    From j2objc with Apache License 2.0 5 votes vote down vote up
public void testGetIssuersNamesCopy() {
    X509CRLSelector crlSelector = new X509CRLSelector();
    crlSelector.addIssuer(PRINCIPAL);
    Collection<Object> issuers = crlSelector.getIssuerNames();
    assertEquals(1, issuers.size());
    issuers.clear();
    assertEquals(0, issuers.size());
}
 
Example #15
Source File: LDAPCertStoreHelper.java    From jdk8u-jdk with GNU General Public License v2.0 5 votes vote down vote up
@Override
public X509CRLSelector wrap(X509CRLSelector selector,
                            Collection<X500Principal> certIssuers,
                            String ldapDN)
    throws IOException
{
    return new LDAPCertStore.LDAPCRLSelector(selector, certIssuers, ldapDN);
}
 
Example #16
Source File: X509CRLSelector2Test.java    From j2objc with Apache License 2.0 5 votes vote down vote up
/**
 * 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.
 */
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));
}
 
Example #17
Source File: X509CRLSelector2Test.java    From j2objc with Apache License 2.0 5 votes vote down vote up
/**
 * clone() method testing. Tests if the selector is cloned correctly: the
 * crl which matche to the initial selector should match to the clone and
 * the change of clone should not cause the change of initial selector.
 */
public void testClone() {
    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.");
    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);

    X509CRLSelector clone = (X509CRLSelector) selector.clone();
    TestCRL crl = new TestCRL(iss1);
    crl.setCrlNumber(minCRL);
    crl.setUpdateDates(new Date(200), new Date(200));
    assertTrue("The specified CRL should match the clone selector.",
            selector.match(crl));

    clone.addIssuer(iss3);
    assertFalse("The changes of the clone selector should not cause "
            + "the changes of initial object", selector.getIssuerNames()
            .size() == 3);
}
 
Example #18
Source File: LDAPCertStoreHelper.java    From jdk8u-jdk with GNU General Public License v2.0 5 votes vote down vote up
@Override
public X509CRLSelector wrap(X509CRLSelector selector,
                            Collection<X500Principal> certIssuers,
                            String ldapDN)
    throws IOException
{
    return new LDAPCertStore.LDAPCRLSelector(selector, certIssuers, ldapDN);
}
 
Example #19
Source File: X509CRLSelector2Test.java    From j2objc with Apache License 2.0 5 votes vote down vote up
/**
 * 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.
 */
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()));
}
 
Example #20
Source File: X509CRLSelectorTest.java    From j2objc with Apache License 2.0 5 votes vote down vote up
public void testGetIssuersImmutable() {
    X509CRLSelector crlSelector = new X509CRLSelector();
    crlSelector.addIssuer(PRINCIPAL);
    Collection<X500Principal> issuers = crlSelector.getIssuers();
    try {
        issuers.clear();
        fail();
    } catch (UnsupportedOperationException expected) {
    }
}
 
Example #21
Source File: SSLServerCertStoreHelper.java    From hottub with GNU General Public License v2.0 5 votes vote down vote up
@Override
public X509CRLSelector wrap(X509CRLSelector selector,
                            Collection<X500Principal> certIssuers,
                            String ldapDN)
    throws IOException
{
    throw new UnsupportedOperationException();
}
 
Example #22
Source File: LDAPCertStoreHelper.java    From hottub with GNU General Public License v2.0 5 votes vote down vote up
@Override
public X509CRLSelector wrap(X509CRLSelector selector,
                            Collection<X500Principal> certIssuers,
                            String ldapDN)
    throws IOException
{
    return new LDAPCertStore.LDAPCRLSelector(selector, certIssuers, ldapDN);
}
 
Example #23
Source File: LDAPCertStoreHelper.java    From jdk8u_jdk with GNU General Public License v2.0 5 votes vote down vote up
@Override
public X509CRLSelector wrap(X509CRLSelector selector,
                            Collection<X500Principal> certIssuers,
                            String ldapDN)
    throws IOException
{
    return new LDAPCertStore.LDAPCRLSelector(selector, certIssuers, ldapDN);
}
 
Example #24
Source File: SSLServerCertStoreHelper.java    From jdk8u_jdk with GNU General Public License v2.0 5 votes vote down vote up
@Override
public X509CRLSelector wrap(X509CRLSelector selector,
                            Collection<X500Principal> certIssuers,
                            String ldapDN)
    throws IOException
{
    throw new UnsupportedOperationException();
}
 
Example #25
Source File: SSLServerCertStoreHelper.java    From openjdk-8-source with GNU General Public License v2.0 5 votes vote down vote up
@Override
public X509CRLSelector wrap(X509CRLSelector selector,
                            Collection<X500Principal> certIssuers,
                            String ldapDN)
    throws IOException
{
    throw new UnsupportedOperationException();
}
 
Example #26
Source File: X509CRLSelector2Test.java    From j2objc with Apache License 2.0 5 votes vote down vote up
/**
 * constructor testing.
 *
 */
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());
}
 
Example #27
Source File: LDAPCertStoreHelper.java    From TencentKona-8 with GNU General Public License v2.0 5 votes vote down vote up
@Override
public X509CRLSelector wrap(X509CRLSelector selector,
                            Collection<X500Principal> certIssuers,
                            String ldapDN)
    throws IOException
{
    return new LDAPCertStore.LDAPCRLSelector(selector, certIssuers, ldapDN);
}
 
Example #28
Source File: LDAPCertStoreHelper.java    From openjdk-8 with GNU General Public License v2.0 5 votes vote down vote up
@Override
public X509CRLSelector wrap(X509CRLSelector selector,
                            Collection<X500Principal> certIssuers,
                            String ldapDN)
    throws IOException
{
    return new LDAPCertStore.LDAPCRLSelector(selector, certIssuers, ldapDN);
}
 
Example #29
Source File: SSLServerCertStoreHelper.java    From openjdk-8 with GNU General Public License v2.0 5 votes vote down vote up
@Override
public X509CRLSelector wrap(X509CRLSelector selector,
                            Collection<X500Principal> certIssuers,
                            String ldapDN)
    throws IOException
{
    throw new UnsupportedOperationException();
}
 
Example #30
Source File: SSLServerCertStoreHelper.java    From jdk8u-jdk with GNU General Public License v2.0 5 votes vote down vote up
@Override
public X509CRLSelector wrap(X509CRLSelector selector,
                            Collection<X500Principal> certIssuers,
                            String ldapDN)
    throws IOException
{
    throw new UnsupportedOperationException();
}