@Override
    public void checkClientTrusted( X509Certificate[] chain, String authType ) throws CertificateException
    {
        // Find and use the end entity as the selector for verification.
        final X509Certificate endEntityCert = CertificateUtils.identifyEndEntityCertificate( Arrays.asList( chain ) );
        final X509CertSelector selector = new X509CertSelector();
        selector.setCertificate( endEntityCert );

        try
        {
            checkChainTrusted( selector, chain );
        }
        catch ( InvalidAlgorithmParameterException | NoSuchAlgorithmException | CertPathBuilderException ex )
        {
            throw new CertificateException( ex );
        }
    }
@Test
    public void testInvalidChainMissingIntermediate() throws Exception
    {
        // Setup fixture.
        assert validChain.length == 4;
        final X509Certificate[] input = new X509Certificate[ 3 ];
        input[ 0 ] = validChain[ 0 ];
        input[ 1 ] = validChain[ 2 ];
        input[ 2 ] = validChain[ 3 ];

        // Execute system under test.
        assertThrows(CertificateException.class, () -> systemUnderTest.checkClientTrusted( input, "RSA" ) );
    }