Package java.security.cert

Examples of java.security.cert.TrustAnchor


        }

        String certAlias = "testca1";
        byte[] nc = getFullEncoding();
        // sub testcase 1
        TrustAnchor ta = new TrustAnchor(
                (X509Certificate)ks.getCertificate(certAlias), nc);
        byte[] ncRet = ta.getNameConstraints();
        // assert 1
        assertTrue(Arrays.equals(nc, ncRet));
        assertNotSame(nc, ncRet);
        // assert 2
        assertNotSame(ncRet, ta.getNameConstraints());
    }
View Full Code Here


        KeyStore ks = TestUtils.getKeyStore(true, TestUtils.TRUSTED);
        if (ks == null) {
            fail(getName() + ": not performed (could not create test KeyStore)");
        }

        TrustAnchor ta = new TrustAnchor(
                (X509Certificate)ks.getCertificate("testca1"),
                null);
        assertNull(ta.getCAPublicKey());
    }
View Full Code Here

        KeyStore ks = TestUtils.getKeyStore(true, TestUtils.TRUSTED);
        if (ks == null) {
            fail(getName() + ": not performed (could not create test KeyStore)");
        }

        TrustAnchor ta = new TrustAnchor(
                (X509Certificate)ks.getCertificate("testca1"),
                null);
        assertNull(ta.getCAName());
    }
View Full Code Here

            fail(getName() + ": not performed (could not create test KeyStore)");
        }

        X509Certificate cert =
            (X509Certificate)ks.getCertificate("testca1");
        TrustAnchor ta = new TrustAnchor(cert, null);
        assertEquals(cert, ta.getTrustedCert());
    }
View Full Code Here

        KeyStore ks = TestUtils.getKeyStore(true, TestUtils.TRUSTED);
        if (ks == null) {
            fail(getName() + ": not performed (could not create test KeyStore)");
        }

        TrustAnchor ta = new TrustAnchor(
                (X509Certificate)ks.getCertificate("testca1"),
                null);
        assertNull(ta.getCA());
    }
View Full Code Here

        }

        String certAlias = "test";

        // sub testcase 1
        TrustAnchor ta = new TrustAnchor(
                (X509Certificate)ks.getCertificate(certAlias),
                getFullEncoding());

        assertNotNull("#1", ta.toString());

        PublicKey pk = new TestKeyPair(keyAlg).getPublic();


        // sub testcase 2
        ta = new TrustAnchor(validCaNameRfc2253, pk, getEncodingESOnly());

        assertNotNull("#2", ta.toString());

        // sub testcase 3
        X500Principal x500p = new X500Principal(validCaNameRfc2253);
        ta = new TrustAnchor(x500p, pk, getEncodingNoMinMax());

        assertNotNull("#3", ta.toString());

        // sub testcase 4
        ta = new TrustAnchor(x500p, pk, null);
        assertNotNull("#4", ta.toString());
    }
View Full Code Here

            throws Exception {

        PublicKey pk = new TestKeyPair(keyAlg).getPublic();

        // sub testcase 1
        new TrustAnchor(validCaNameRfc2253, pk, getFullEncoding());
        // sub testcase 2
        new TrustAnchor(validCaNameRfc2253, pk, getEncodingPSOnly());       
        // sub testcase 3
        new TrustAnchor(validCaNameRfc2253, pk, getEncodingESOnly());       
        // sub testcase 4
        new TrustAnchor(validCaNameRfc2253, pk, getEncodingNoMinMax());       
    }
View Full Code Here

    public final void testTrustAnchorStringPublicKeybyteArray02()
            throws Exception {

        PublicKey pk = new TestKeyPair(keyAlg).getPublic();

        new TrustAnchor(validCaNameRfc2253, pk, null);
    }
View Full Code Here

        PublicKey pk = new TestKeyPair(keyAlg).getPublic();

        byte[] nc = getEncodingPSOnly();
        byte[] ncCopy = nc.clone();
        // sub testcase 5 - nameConstraints can be null
        TrustAnchor ta = new TrustAnchor(validCaNameRfc2253, pk, ncCopy);
        // modify
        ncCopy[0]=(byte)0;
        // check that above modification did not change
        // object internal state
        assertTrue(Arrays.equals(nc, ta.getNameConstraints()));
    }
View Full Code Here

        PublicKey pk = new TestKeyPair(keyAlg).getPublic();

        // sub testcase 1: 'caName' param is null
        try {
            new TrustAnchor((String)null, pk, getEncodingPSOnly());
            fail("NullPointerException has not been thrown");
        } catch (NullPointerException ok) {
        }

        // sub testcase 2: 'caPublicKey' param is null
        try {
            new TrustAnchor(validCaNameRfc2253, null, getEncodingPSOnly());
            fail("NullPointerException has not been thrown");
        } catch (NullPointerException ok) {
        }

        // sub testcase 3: 'caName' and 'caPublicKey' params are null
        try {
            new TrustAnchor((String)null, null, getEncodingPSOnly());
            fail("NullPointerException has not been thrown");
        } catch (NullPointerException ok) {
        }

        // sub testcase 4: 'caName' param is empty
        try {
            new TrustAnchor("", pk, getEncodingPSOnly());
            fail("IllegalArgumentException has not been thrown");
        } catch (IllegalArgumentException ok) {
        }

        // sub testcase 5: 'caName' param is incorrect distinguished name
        try {
            new TrustAnchor("AID.11.12=A", pk, getEncodingPSOnly());
            fail("IllegalArgumentException has not been thrown");
        } catch (IllegalArgumentException ok) {
        }
    }
View Full Code Here

TOP

Related Classes of java.security.cert.TrustAnchor

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.