1 10 11 package org.mule.util; 12 13 import java.security.Provider ; 14 import java.security.Security ; 15 import java.util.HashSet ; 16 import java.util.Iterator ; 17 import java.util.Set ; 18 19 22 public class DebugUtils 24 { 25 26 29 public static String [] listSecurityServiceTypes() 30 { 31 Set result = new HashSet (); 32 33 Provider [] providers = Security.getProviders(); 35 for (int i = 0; i < providers.length; i++) 36 { 37 Set keys = providers[i].keySet(); 39 for (Iterator it = keys.iterator(); it.hasNext();) 40 { 41 String key = (String )it.next(); 42 key = key.split(" ")[0]; 43 44 if (key.startsWith("Alg.Alias.")) 45 { 46 key = key.substring(10); 48 } 49 int ix = key.indexOf('.'); 50 result.add(key.substring(0, ix)); 51 } 52 } 53 return (String [])result.toArray(new String [result.size()]); 54 } 55 56 59 public static String [] listCryptoImplementations(String serviceType) 60 { 61 Set result = new HashSet (); 62 63 Provider [] providers = Security.getProviders(); 65 for (int i = 0; i < providers.length; i++) 66 { 67 Set keys = providers[i].keySet(); 69 for (Iterator it = keys.iterator(); it.hasNext();) 70 { 71 String key = (String )it.next(); 72 key = key.split(" ")[0]; 73 74 if (key.startsWith(serviceType + ".")) 75 { 76 result.add(key.substring(serviceType.length() + 1)); 77 } 78 else if (key.startsWith("Alg.Alias." + serviceType + ".")) 79 { 80 result.add(key.substring(serviceType.length() + 11)); 82 } 83 } 84 } 85 return (String [])result.toArray(new String [result.size()]); 86 } 87 } 88 | Popular Tags |