1 16 package org.apache.axis.components.net; 17 18 import java.util.Hashtable ; 19 20 import org.apache.axis.components.logger.LogFactory; 21 import org.apache.axis.utils.Messages; 22 import org.apache.commons.logging.Log; 23 24 import com.sun.net.ssl.SSLContext; 25 import com.sun.net.ssl.TrustManager; 26 import com.sun.net.ssl.X509TrustManager; 27 28 31 public class SunFakeTrustSocketFactory extends SunJSSESocketFactory { 32 33 34 protected static Log log = 35 LogFactory.getLog(SunFakeTrustSocketFactory.class.getName()); 36 37 42 public SunFakeTrustSocketFactory(Hashtable attributes) { 43 super(attributes); 44 } 45 46 53 protected SSLContext getContext() throws Exception { 54 55 try { 56 SSLContext sc = SSLContext.getInstance("SSL"); 57 58 sc.init(null, new TrustManager[]{new FakeX509TrustManager()}, 60 new java.security.SecureRandom ()); 61 if (log.isDebugEnabled()) { 62 log.debug(Messages.getMessage("ftsf00")); 63 } 64 return sc; 65 } catch (Exception exc) { 66 log.error(Messages.getMessage("ftsf01"), exc); 67 throw new Exception (Messages.getMessage("ftsf02")); 68 } 69 } 70 71 74 public static class FakeX509TrustManager implements X509TrustManager { 75 76 77 protected static Log log = 78 LogFactory.getLog(FakeX509TrustManager.class.getName()); 79 80 87 public boolean isClientTrusted(java.security.cert 88 .X509Certificate[] chain) { 89 90 if (log.isDebugEnabled()) { 91 log.debug(Messages.getMessage("ftsf03")); 92 } 93 return true; 94 } 95 96 103 public boolean isServerTrusted(java.security.cert 104 .X509Certificate[] chain) { 105 106 if (log.isDebugEnabled()) { 107 log.debug(Messages.getMessage("ftsf04")); 108 } 109 return true; 110 } 111 112 117 public java.security.cert.X509Certificate [] getAcceptedIssuers() { 118 119 if (log.isDebugEnabled()) { 120 log.debug(Messages.getMessage("ftsf05")); 121 } 122 return null; 123 } 124 } 125 } 126 | Popular Tags |