1 20 package org.apache.mina.integration.spring.ssl; 21 22 import java.security.InvalidAlgorithmParameterException ; 23 import java.security.KeyStore ; 24 import java.security.KeyStoreException ; 25 import java.security.Provider ; 26 import java.security.cert.CertificateException ; 27 import java.security.cert.X509Certificate ; 28 29 import javax.net.ssl.ManagerFactoryParameters; 30 import javax.net.ssl.TrustManager; 31 import javax.net.ssl.TrustManagerFactory; 32 import javax.net.ssl.TrustManagerFactorySpi; 33 import javax.net.ssl.X509TrustManager; 34 35 42 public class BogusTrustManagerFactory extends TrustManagerFactory { 43 44 public BogusTrustManagerFactory() { 45 super(new BogusTrustManagerFactorySpi(), new Provider ("MinaBogus", 1.0, 46 "") { 47 private static final long serialVersionUID = -4024169055312053827L; 48 }, "MinaBogus"); 49 } 50 51 private static final X509TrustManager X509 = new X509TrustManager() { 52 public void checkClientTrusted(X509Certificate [] x509Certificates, 53 String s) throws CertificateException { 54 } 55 56 public void checkServerTrusted(X509Certificate [] x509Certificates, 57 String s) throws CertificateException { 58 } 59 60 public X509Certificate [] getAcceptedIssuers() { 61 return new X509Certificate [0]; 62 } 63 }; 64 65 private static final TrustManager[] X509_MANAGERS = new TrustManager[] { X509 }; 66 67 private static class BogusTrustManagerFactorySpi extends 68 TrustManagerFactorySpi { 69 70 protected TrustManager[] engineGetTrustManagers() { 71 return X509_MANAGERS; 72 } 73 74 protected void engineInit(KeyStore keystore) throws KeyStoreException { 75 } 77 78 protected void engineInit( 79 ManagerFactoryParameters managerFactoryParameters) 80 throws InvalidAlgorithmParameterException { 81 } 83 84 } 85 } 86 | Popular Tags |