| | |
| | | import java.net.InetAddress; |
| | | import java.util.Map; |
| | | import java.util.HashMap; |
| | | import java.util.logging.Level; |
| | | import java.util.logging.Logger; |
| | | |
| | | import java.security.GeneralSecurityException; |
| | | |
| | |
| | | */ |
| | | public class TrustedSocketFactory extends SSLSocketFactory |
| | | { |
| | | static private final Logger LOG = |
| | | Logger.getLogger(TrustedSocketFactory.class.getName()); |
| | | private static Map<Thread, TrustManager> hmTrustManager = |
| | | new HashMap<Thread, TrustManager>(); |
| | | private static Map<Thread, KeyManager> hmKeyManager = |
| | |
| | | |
| | | if (trustManager == null) |
| | | { |
| | | LOG.log(Level.SEVERE, "Can't find a trust manager associated to thread " + |
| | | currentThread); |
| | | if (keyManager == null) |
| | | { |
| | | LOG.log(Level.SEVERE, "Can't find a key manager associated to thread " + |
| | | currentThread); |
| | | result = new TrustedSocketFactory(null,null); |
| | | } |
| | | else |
| | |
| | | { |
| | | if (keyManager == null) |
| | | { |
| | | LOG.log(Level.SEVERE, |
| | | "Can't find a key manager associated to thread " + currentThread); |
| | | result = hmDefaultFactoryTm.get(trustManager); |
| | | if (result == null) |
| | | { |
| | |
| | | |
| | | try { |
| | | SSLContext sslCtx = SSLContext.getInstance(algorithm); |
| | | if (trustManager == null) |
| | | { |
| | | LOG.log(Level.SEVERE, "Warning : no trust for this factory"); |
| | | } |
| | | else |
| | | if (trustManager != null) |
| | | { |
| | | tm = new TrustManager[] { trustManager }; |
| | | } |
| | | if (keyManager == null) |
| | | { |
| | | LOG.log(Level.SEVERE, "Warning : no key for this factory"); |
| | | } |
| | | else |
| | | if (keyManager != null) |
| | | { |
| | | km = new KeyManager[] { keyManager }; |
| | | } |