Package java.security.cert

Examples of java.security.cert.TrustAnchor


        try {
            bis = new BufferedInputStream(new ByteArrayInputStream(
                    getEncodedX509Certificate()));
            X509Certificate c1 = (X509Certificate)cf.generateCertificate(bis);

            return new TrustAnchor(c1, null);
        } catch (Exception e) {
            // all failures are fatal
            throw new RuntimeException(e);
        } finally {
            if (bis != null) {
View Full Code Here


     * Creates <code>Set</code> of <code>TrustAnchor</code>s
     * containing single element (self signed test certificate).
     * @return Returns <code>Set</code> of <code>TrustAnchor</code>s
     */
    public static Set getTrustAnchorSet() {
        TrustAnchor ta = getTrustAnchor();
        if (ta == null) {
            return null;
        }
        HashSet set = new HashSet();
        if (!set.add(ta)) {
View Full Code Here

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

        String certAlias = "testca1";
        // sub testcase 1
        new TrustAnchor(
            (X509Certificate)ks.getCertificate(certAlias),
            getFullEncoding());
        // sub testcase 2
        new TrustAnchor(
            (X509Certificate)ks.getCertificate(certAlias),
            getEncodingPSOnly());
        // sub testcase 3
        new TrustAnchor(
            (X509Certificate)ks.getCertificate(certAlias),
            getEncodingESOnly());
        // sub testcase 4
        new TrustAnchor(
            (X509Certificate)ks.getCertificate(certAlias),
            getEncodingNoMinMax());
    }
View Full Code Here

        if (ks == null) {
            fail(getName() + ": not performed (could not create test KeyStore)");
        }

        String certAlias = "testca1";
        new TrustAnchor(
            (X509Certificate)ks.getCertificate(certAlias),
            null);       
    }
View Full Code Here

        String certAlias = "testca1";
        byte[] nc = getEncodingPSOnly();
        byte[] ncCopy = nc.clone();
        // sub testcase 5 - nameConstraints can be null
        TrustAnchor ta = new TrustAnchor(
                (X509Certificate)ks.getCertificate(certAlias),
                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

        if (ks == null) {
            fail(getName() + ": not performed (could not create test KeyStore)");
        }

        try {
            new TrustAnchor(null, getFullEncoding());
            fail("NullPointerException has not been thrown");
        } catch (NullPointerException ok) {
        }
    }
View Full Code Here

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

        String certAlias = "testca1";
        byte []  nameConstraints = getEncodingOid();
        new TrustAnchor(
            (X509Certificate)ks.getCertificate(certAlias),
            nameConstraints);
    }
View Full Code Here

        String certAlias = "testca1";
        byte []  nameConstraints = getEncodingOid();
        //corrupt Oid
        nameConstraints[10]= (byte) 0xFF;
        try {
            new TrustAnchor(
                (X509Certificate)ks.getCertificate(certAlias),
                nameConstraints);
            fail("IllegalArgumentException has not been thrown");
        } catch (IllegalArgumentException ok) {
        }
View Full Code Here

                (byte)0x80,(byte)0x01,(byte)0x00 // minimum
        };
        for (int i=0; i<generalNameTag.length; i++) {
            wrongEncoding[6] = generalNameTag[i];
            try {
                new TrustAnchor(
                    (X509Certificate)ks.getCertificate(certAlias),
                    wrongEncoding);
                fail("IllegalArgumentException has not been thrown for tag " +
                        (generalNameTag[i]&0xff));
            } catch (IllegalArgumentException ok) {
View Full Code Here

                (byte)0x06,(byte)0x03,(byte)0x00,(byte)0x01,(byte)0x02,
                (byte)0xA0,(byte)0x03,1,1,(byte)0xff,
                (byte)0x80,(byte)0x01,(byte)0x00
        };
        try {
            new TrustAnchor(
                (X509Certificate)ks.getCertificate(certAlias), encoding);
        } catch (IllegalArgumentException failed) {
            fail("valid encoding not accepted");
        }
        // now corrupt encoding: set OtherName value tag to 1 (must be 0)
        encoding[13] = 1;
        try {
            new TrustAnchor(
                (X509Certificate)ks.getCertificate(certAlias), encoding);
            fail("invalid encoding accepted");
        } 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.