Search in sources :

Example 1 with UnifiedX509TrustManager

use of com.sun.enterprise.security.ssl.manager.UnifiedX509TrustManager in project Payara by payara.

the class SecuritySupportImpl method getTrustManagers.

public TrustManager[] getTrustManagers(String algorithm) throws IOException, KeyStoreException, NoSuchAlgorithmException {
    KeyStore[] tstores = getTrustStores();
    ArrayList<TrustManager> trustManagers = new ArrayList<TrustManager>();
    for (KeyStore tstore : tstores) {
        checkCertificateDates(tstore);
        TrustManagerFactory tmf = TrustManagerFactory.getInstance((algorithm != null) ? algorithm : TrustManagerFactory.getDefaultAlgorithm());
        tmf.init(tstore);
        TrustManager[] tmgrs = tmf.getTrustManagers();
        if (tmgrs != null) {
            trustManagers.addAll(Arrays.asList(tmgrs));
        }
    }
    TrustManager trustManager;
    if (trustManagers.size() == 1) {
        trustManager = trustManagers.get(0);
    } else {
        trustManager = new UnifiedX509TrustManager(trustManagers.toArray(new X509TrustManager[trustManagers.size()]));
    }
    return new TrustManager[] { trustManager };
}
Also used : UnifiedX509TrustManager(com.sun.enterprise.security.ssl.manager.UnifiedX509TrustManager) TrustManagerFactory(javax.net.ssl.TrustManagerFactory) ArrayList(java.util.ArrayList) KeyStore(java.security.KeyStore) TrustManager(javax.net.ssl.TrustManager) UnifiedX509TrustManager(com.sun.enterprise.security.ssl.manager.UnifiedX509TrustManager) X509TrustManager(javax.net.ssl.X509TrustManager)

Aggregations

UnifiedX509TrustManager (com.sun.enterprise.security.ssl.manager.UnifiedX509TrustManager)1 KeyStore (java.security.KeyStore)1 ArrayList (java.util.ArrayList)1 TrustManager (javax.net.ssl.TrustManager)1 TrustManagerFactory (javax.net.ssl.TrustManagerFactory)1 X509TrustManager (javax.net.ssl.X509TrustManager)1