1 17 18 package org.apache.tomcat.util.net; 19 20 import java.net.Socket ; 21 import javax.net.ssl.SSLSession; 22 23 29 abstract public class SSLImplementation { 30 private static org.apache.commons.logging.Log logger = 31 org.apache.commons.logging.LogFactory.getLog(SSLImplementation.class); 32 33 private static final String PureTLSImplementationClass= 35 "org.apache.tomcat.util.net.puretls.PureTLSImplementation"; 36 private static final String JSSEImplementationClass= 37 "org.apache.tomcat.util.net.jsse.JSSEImplementation"; 38 39 private static final String [] implementations= 40 { 41 PureTLSImplementationClass, 42 JSSEImplementationClass 43 }; 44 45 public static SSLImplementation getInstance() throws ClassNotFoundException 46 { 47 for(int i=0;i<implementations.length;i++){ 48 try { 49 SSLImplementation impl= 50 getInstance(implementations[i]); 51 return impl; 52 } catch (Exception e) { 53 if(logger.isTraceEnabled()) 54 logger.trace("Error creating " + implementations[i],e); 55 } 56 } 57 58 throw new ClassNotFoundException ("Can't find any SSL implementation"); 60 } 61 62 public static SSLImplementation getInstance(String className) 63 throws ClassNotFoundException 64 { 65 if(className==null) return getInstance(); 66 67 try { 68 if( JSSEImplementationClass.equals(className) ) { 72 return new org.apache.tomcat.util.net.jsse.JSSEImplementation(); 73 } 74 Class clazz=Class.forName(className); 75 return (SSLImplementation)clazz.newInstance(); 76 } catch (Exception e){ 77 if(logger.isDebugEnabled()) 78 logger.debug("Error loading SSL Implementation " 79 +className, e); 80 throw new ClassNotFoundException ("Error loading SSL Implementation " 81 +className+ " :" +e.toString()); 82 } 83 } 84 85 abstract public String getImplementationName(); 86 abstract public ServerSocketFactory getServerSocketFactory(); 87 abstract public SSLSupport getSSLSupport(Socket sock); 88 abstract public SSLSupport getSSLSupport(SSLSession session); 89 } 90 | Popular Tags |