class CompositeTrustManager extends AbstractTrustManager {

    @Override
    public void checkServerTrusted(X509Certificate[] serverCertificates, String authType) throws CertificateException {
        for (TrustManager trustManager : trustManagers) {
            try {
                final X509TrustManager x509TrustManager = (X509TrustManager) trustManager;
                x509TrustManager.checkServerTrusted(serverCertificates, authType);
                return;
            }
            catch (CertificateException ex) {
                //Ignore and move on to the next trust manager
            }
        }
        throw new CertificateException("Certificate is not trusted by any of the trust managers");
    }

    public  CompositeTrustManager(TrustManager[] trustManagers);

}