1 10 11 package org.mule.umo.security.provider; 12 13 import org.apache.commons.logging.Log; 14 import org.apache.commons.logging.LogFactory; 15 import org.mule.MuleRuntimeException; 16 import org.mule.config.i18n.CoreMessageConstants; 17 import org.mule.config.i18n.Message; 18 import org.mule.util.ClassUtils; 19 import org.mule.util.SystemUtils; 20 21 import java.security.Provider ; 22 23 29 public class AutoDiscoverySecurityProviderFactory implements SecurityProviderFactory 30 { 31 32 35 public static final SecurityProviderInfo DEFAULT_SECURITY_PROVIDER = new SunSecurityProviderInfo(); 36 37 40 protected transient Log logger = LogFactory.getLog(getClass()); 41 42 45 private static final SecurityProviderInfo IBM_SECURITY_PROVIDER = new IBMSecurityProviderInfo(); 46 47 50 53 public SecurityProviderInfo getSecurityProviderInfo() 54 { 55 SecurityProviderInfo info; 56 57 if (SystemUtils.isIbmJDK()) 58 { 59 info = IBM_SECURITY_PROVIDER; 68 } 70 else 71 { 72 info = DEFAULT_SECURITY_PROVIDER; 73 74 } 75 76 78 return info; 79 } 80 81 public Provider getProvider() 82 { 83 SecurityProviderInfo info = getSecurityProviderInfo(); 84 85 if (logger.isInfoEnabled()) 86 { 87 logger.info("Using " + info.getClass().getName()); 88 } 89 90 try 91 { 92 return (Provider )ClassUtils.instanciateClass(info.getProviderClass(), null); 93 } 94 catch (Exception ex) 95 { 96 throw new MuleRuntimeException(new Message("core", 97 CoreMessageConstants.FAILED_TO_INITIALIZE_SECURITY_PROVIDER, info.getProviderClass()), ex); 98 } 99 } 100 } 101 | Popular Tags |