1 11 12 package org.jivesoftware.messenger.net; 13 14 import com.sun.net.ssl.TrustManager; 15 import com.sun.net.ssl.TrustManagerFactory; 16 17 import java.io.FileInputStream ; 18 import java.io.IOException ; 19 import java.security.KeyStore ; 20 import java.security.KeyStoreException ; 21 import java.security.NoSuchAlgorithmException ; 22 import java.security.cert.CertificateException ; 23 24 38 public class SSLJiveTrustManagerFactory { 39 40 59 public static TrustManager[] getTrustManagers(String storeType, String truststore, String trustpass) throws NoSuchAlgorithmException , KeyStoreException , IOException , CertificateException { 60 TrustManager[] trustManagers; 61 if (truststore == null) { 62 trustManagers = null; 63 } 64 else { 65 TrustManagerFactory trustFactory = TrustManagerFactory.getInstance(TrustManagerFactory.getDefaultAlgorithm()); 66 if (trustpass == null) { 67 trustpass = ""; 68 } 69 KeyStore keyStore = KeyStore.getInstance(storeType); 70 keyStore.load(new FileInputStream (truststore), trustpass.toCharArray()); 71 trustFactory.init(keyStore); 72 trustManagers = trustFactory.getTrustManagers(); 73 } 74 return trustManagers; 75 } 76 } 77 | Popular Tags |