1 11 12 package org.jivesoftware.messenger.net; 13 14 import com.sun.net.ssl.KeyManager; 15 import com.sun.net.ssl.KeyManagerFactory; 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.UnrecoverableKeyException ; 23 import java.security.cert.CertificateException ; 24 25 37 public class SSLJiveKeyManagerFactory { 38 39 60 public static KeyManager[] getKeyManagers(String storeType, String keystore, String keypass) throws NoSuchAlgorithmException , KeyStoreException , IOException , CertificateException , UnrecoverableKeyException { 61 KeyManager[] keyManagers; 62 if (keystore == null) { 63 keyManagers = null; 64 } 65 else { 66 if (keypass == null) { 67 keypass = ""; 68 } 69 KeyStore keyStore = KeyStore.getInstance(storeType); 70 keyStore.load(new FileInputStream (keystore), keypass.toCharArray()); 71 72 KeyManagerFactory keyFactory = KeyManagerFactory.getInstance(KeyManagerFactory.getDefaultAlgorithm()); 73 keyFactory.init(keyStore, keypass.toCharArray()); 74 keyManagers = keyFactory.getKeyManagers(); 75 } 76 return keyManagers; 77 } 78 } 79 | Popular Tags |