Home / Class/ SslContextTrustManagerTest Class — netty Architecture

SslContextTrustManagerTest Class — netty Architecture

Architecture documentation for the SslContextTrustManagerTest class in SslContextTrustManagerTest.java from the netty codebase.

Entity Profile

Dependency Diagram

graph TD
  78725ab9_1005_d91e_3eb0_838510c45286["SslContextTrustManagerTest"]
  178bc9ad_6f65_1c7b_ada7_b8169972b32c["SslContextTrustManagerTest.java"]
  78725ab9_1005_d91e_3eb0_838510c45286 -->|defined in| 178bc9ad_6f65_1c7b_ada7_b8169972b32c
  3dcd05f0_c273_9a99_041f_4210892b24d0["testUsingAllCAs()"]
  78725ab9_1005_d91e_3eb0_838510c45286 -->|method| 3dcd05f0_c273_9a99_041f_4210892b24d0
  e183122c_bfbf_ae1a_d583_25e6814f57f1["testUsingAllCAsWithDuplicates()"]
  78725ab9_1005_d91e_3eb0_838510c45286 -->|method| e183122c_bfbf_ae1a_d583_25e6814f57f1
  3e3567b0_db78_50d8_d378_08f6ae29d499["testUsingCAsOneAandB()"]
  78725ab9_1005_d91e_3eb0_838510c45286 -->|method| 3e3567b0_db78_50d8_d378_08f6ae29d499
  c721fdd4_cc78_3ef8_dd3d_642221a98b32["testUsingCAsOneAandTwo()"]
  78725ab9_1005_d91e_3eb0_838510c45286 -->|method| c721fdd4_cc78_3ef8_dd3d_642221a98b32
  ca743d5f_72b8_d15f_2c68_47954acd18ba["runTests()"]
  78725ab9_1005_d91e_3eb0_838510c45286 -->|method| ca743d5f_72b8_d15f_2c68_47954acd18ba
  65cd9a4e_bd9d_29f3_95a9_77e382dec9a9["X509TrustManager()"]
  78725ab9_1005_d91e_3eb0_838510c45286 -->|method| 65cd9a4e_bd9d_29f3_95a9_77e382dec9a9

Relationship Graph

Source Code

handler/src/test/java/io/netty/handler/ssl/SslContextTrustManagerTest.java lines 31–122

public class SslContextTrustManagerTest {
    @Test
    public void testUsingAllCAs() throws Exception {
        runTests(new String[] { "tm_test_ca_1a.pem", "tm_test_ca_1b.pem",
                "tm_test_ca_2.pem" }, new String[] { "tm_test_eec_1.pem",
                "tm_test_eec_2.pem", "tm_test_eec_3.pem" }, new boolean[] {
                true, true, true });
    }

    @Test
    public void testUsingAllCAsWithDuplicates() throws Exception {
        runTests(new String[] { "tm_test_ca_1a.pem", "tm_test_ca_1b.pem",
                "tm_test_ca_2.pem", "tm_test_ca_2.pem" },
                new String[] { "tm_test_eec_1.pem", "tm_test_eec_2.pem",
                        "tm_test_eec_3.pem" },
                new boolean[] { true, true, true });
    }

    @Test
    public void testUsingCAsOneAandB() throws Exception {
        runTests(new String[] { "tm_test_ca_1a.pem", "tm_test_ca_1b.pem", },
                new String[] { "tm_test_eec_1.pem", "tm_test_eec_2.pem",
                        "tm_test_eec_3.pem" }, new boolean[] { true, true,
                        false });
    }

    @Test
    public void testUsingCAsOneAandTwo() throws Exception {
        runTests(new String[] { "tm_test_ca_1a.pem", "tm_test_ca_2.pem" },
                new String[] { "tm_test_eec_1.pem", "tm_test_eec_2.pem",
                        "tm_test_eec_3.pem" }, new boolean[] { true, false,
                        true });
    }

    /**
     *
     * @param caResources
     *            an array of paths to CA Certificates in PEM format to load
     *            from the classpath (relative to this class).
     * @param eecResources
     *            an array of paths to Server Certificates in PEM format in to
     *            load from the classpath (relative to this class).
     * @param expectations
     *            an array of expecting results for each EEC Server Certificate
     *            (the array is expected to have the same length the previous
     *            argument, and be arrange in matching order: true means
     *            expected to be valid, false otherwise.
     */
    private static void runTests(String[] caResources, String[] eecResources,
            boolean[] expectations) throws Exception {
        X509TrustManager tm = getTrustManager(caResources);

        X509Certificate[] eecCerts = loadCertCollection(eecResources);

        for (int i = 0; i < eecResources.length; i++) {
            X509Certificate eecCert = eecCerts[i];
            assertNotNull(eecCert, "Cannot use cert " + eecResources[i]);
            try {
                tm.checkServerTrusted(new X509Certificate[] { eecCert }, "RSA");
                if (!expectations[i]) {
                    fail(String.format(
                            "Certificate %s was expected not to be valid when using CAs %s, but its "
                                    + "verification passed.", eecResources[i],
                            Arrays.asList(caResources)));
                }
            } catch (CertificateException e) {
                if (expectations[i]) {
                    fail(String.format(
                            "Certificate %s was expected to be valid when using CAs %s, but its "
                                    + "verification failed.", eecResources[i],
                            Arrays.asList(caResources)));
                }
            }
        }
    }

    private static X509TrustManager getTrustManager(String[] resourceNames)
            throws Exception {
        X509Certificate[] certCollection = loadCertCollection(resourceNames);
        TrustManagerFactory tmf = SslContext.buildTrustManagerFactory(
                certCollection, null, null);

Frequently Asked Questions

What is the SslContextTrustManagerTest class?
SslContextTrustManagerTest is a class in the netty codebase, defined in handler/src/test/java/io/netty/handler/ssl/SslContextTrustManagerTest.java.
Where is SslContextTrustManagerTest defined?
SslContextTrustManagerTest is defined in handler/src/test/java/io/netty/handler/ssl/SslContextTrustManagerTest.java at line 31.

Analyze Your Own Codebase

Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.

Try Supermodel Free