Get the SSL socket factory.

@return the {@link SSLSocketFactory} object
773936
public SSLSocketFactory getSSLSockectFactory() {

    SSLContext context = null;

    try {

      context = SSLContext.getInstance("TLS");

    } catch (NoSuchAlgorithmException e) {

      throw new VOMSError(e.getMessage(), e);
    }

    KeyManager[] keyManagers = new KeyManager[] { credential.getKeyManager() };

    X509TrustManager trustManager = SocketFactoryCreator
      .getSSLTrustManager(validator);

    TrustManager[] trustManagers = new TrustManager[] { trustManager };

    SecureRandom secureRandom = null;

    /* http://bugs.sun.com/view_bug.do?bug_id=6202721 */
    /*
     * Use new SecureRandom instead of SecureRandom.getInstance("SHA1PRNG") to
     * avoid unnecessary blocking
     */
    secureRandom = new SecureRandom();

    try {

      context.init(keyManagers, trustManagers, secureRandom);

    } catch (KeyManagementException e) {

      throw new VOMSError(e.getMessage(), e);
    }

    return context.getSocketFactory();
  }
393892
public static SSLSocketFactory getPinnedCertSslSocketFactory(Context context,
                                                               int keyStoreRawResId,
                                                               String keyStorePassword) {
    InputStream in = null;
    try {
      // Get an instance of the Bouncy Castle KeyStore format
      KeyStore trusted = KeyStore.getInstance("BKS");

      // Get the keystore from raw resource
      in = context.getResources().openRawResource(keyStoreRawResId);
      // Initialize the keystore with the provided trusted certificates
      // Also provide the password of the keystore
      trusted.load(in, keyStorePassword.toCharArray());

      // Create a TrustManager that trusts the CAs in our KeyStore
      String tmfAlgorithm = TrustManagerFactory.getDefaultAlgorithm();
      TrustManagerFactory tmf = TrustManagerFactory.getInstance(tmfAlgorithm);
      tmf.init(trusted);

      // Create an SSLContext that uses our TrustManager
      SSLContext sslContext = SSLContext.getInstance("TLS");
      sslContext.init(null, tmf.getTrustManagers(), null);

      return sslContext.getSocketFactory();
    } catch (Exception e) {
      throw new RuntimeException(e);
    } finally {
      try {
        if (in != null) {
          in.close();
        }
      } catch (IOException e) {
        Logger.e(e.getMessage());
      }
    }
  }
878042
def getFactory(self):
        
        factory = ServerFactory()
        def protocol():
            proto = CredReceiver()
            proto.portal = Portal(
                self.loginSystem,
                [self.loginSystem,
                 OneTimePadChecker(self._oneTimePads)])
            return proto
        factory.protocol = protocol
        return factory
632963
public static synchronized JmsFactoryFactory getInstance() throws JMSException
  {
  	
  	if (tcInt.isEntryEnabled())
      Tr.entry(tcInt, "getInstance");

    if (instance == null)
    {
      

      try
      {
        Class cls =
          Class.forName(ApiJmsConstants.CONNFACTORY_FACTORY_CLASS);
        instance = (JmsFactoryFactory) cls.newInstance();

      } catch (Exception e)
      {
        // No FFDC code needed
      	if (tcInt.isDebugEnabled())
          Tr.debug(tcInt, "Unable to instantiate JmsFactoryFactory", e);
        if (tcInt.isEntryEnabled())
          Tr.exit(tcInt, "getInstance");
          
        instance = null;
              
        JMSException jmse = new JMSException(nls.getFormattedMessage("UNABLE_TO_CREATE_FACTORY_CWSIA0001",
        																			new Object[] {"JmsFactoryFactoryImpl", "sib.api.jmsImpl.jar"},
        																			"!!!Unable to instantiate JmsFactoryFactoryImpl"));
        jmse.setLinkedException(e);
        jmse.initCause(e);
        throw jmse;

      }

    }//if

		if (tcInt.isEntryEnabled())
      Tr.exit(tcInt, "getInstance");
      
		// If we get this far, then the instance is initialized, since an exception would
		// have been thrown if it was not.
    return instance;
  }
1251030
private SSLSocketFactory getSSLSocketFactory() throws Exception {
        SSLSocketFactory sslSF = null;
        Object sslConfig = this.sslConfig.getService();
        if(sslConfig != null) {
            // Reflectively invoke this operation to a helper class because the classes needed to perform
            // this operation are dynamically imported, depending on if the ssl-1.0 feature is enabled.
            Class<?> SSLHelper = Class.forName("com.ibm.ws.cloudant.internal.SSLHelper");
            sslSF = (SSLSocketFactory) SSLHelper.getMethod("getSSLSocketFactory", Object.class).invoke(null, sslConfig);
        }
        return sslSF;
    }
710160
public static javax.net.SocketFactory getDefault() {
        if (tc.isEntryEnabled())
            Tr.entry(tc, "getDefault");

        if (thisClass == null) {
            try {
                thisClass = new com.ibm.ws.ssl.protocol.LibertySSLSocketFactory();
            } catch (Exception e) {
                if (tc.isDebugEnabled())
                    Tr.debug(tc, "SSLSocketFactory exception getting default socket factory.", new Object[] { e });
                FFDCFilter.processException(e, "SSLSocketFactory", "getDefault", thisClass);
            }
        }

        if (tc.isEntryEnabled())
            Tr.exit(tc, "getDefault");
        return thisClass;
    }
758595
private SslContext getSslContext() {
        final SslContext sslCtx;
        if (clientConfig.isEnableTls()) {
            try {
                SslContextBuilder clientSslCtxBuilder = SslContextBuilder.forClient();
                if (Strings.isNullOrEmpty(clientConfig.getTrustStore())) {
                    clientSslCtxBuilder = clientSslCtxBuilder.trustManager(FingerprintTrustManagerFactory
                                                                                   .getInstance(FingerprintTrustManagerFactory.getDefaultAlgorithm()));
                    log.debug("SslContextBuilder was set to an instance of {}", FingerprintTrustManagerFactory.class);
                } else {
                    clientSslCtxBuilder = SslContextBuilder.forClient()
                                                           .trustManager(new File(clientConfig.getTrustStore()));
                }
                sslCtx = clientSslCtxBuilder.build();
            } catch (SSLException | NoSuchAlgorithmException e) {
                throw new RuntimeException(e);
            }
        } else {
            sslCtx = null;
        }
        return sslCtx;
    }
438539
protected SocketFactory createSocketFactory(InetAddress address,
                                                int port,
                                                InetAddress localAddr,
                                                int localPort,
                                                long timeout)
    {
        SocketFactory factory;
        factory = new PlainSocketFactory
            (address, port, localAddr, localPort, timeout);
        factory = new PooledSocketFactory(factory);
        factory = new LazySocketFactory(factory);
        return factory;
    }
1330802
public static SSLSocketFactory getSSLSocketFactory(Object sslConfig) throws Exception {
        SSLSocketFactory sslSF = null;
        if(sslConfig != null) {
            String sslAlias = ((com.ibm.wsspi.ssl.SSLConfiguration) sslConfig).getAlias();
            final com.ibm.websphere.ssl.JSSEHelper helper = com.ibm.websphere.ssl.JSSEHelper.getInstance();
            final Properties sslProps = helper.getProperties(sslAlias);
            
            sslSF = AccessController.doPrivileged(new PrivilegedExceptionAction<SSLSocketFactory>() {
                @Override
                public SSLSocketFactory run() throws Exception {
                    return helper.getSSLSocketFactory(Collections.<String, Object>emptyMap(), sslProps);
                }
            });
        }
        return sslSF;
    }
162813
public static ThreadManager getInstance() {
        if (thisClass == null) {
            thisClass = new ThreadManager();

            String useInheritableThreadLocalString = SSLConfigManager.getInstance().getGlobalProperty(Constants.SSLPROP_USE_INHERITABLE_THREAD_LOCAL);
            if (useInheritableThreadLocalString != null && (useInheritableThreadLocalString.equalsIgnoreCase("true") || useInheritableThreadLocalString.equalsIgnoreCase("yes"))) {
                if (TraceComponent.isAnyTracingEnabled() && tc.isDebugEnabled())
                    Tr.debug(tc, "useInheritableThreadLocal is enabled.");
                useInheritableThreadLocal = true;
            }
        }

        return thisClass;
    }
83218
public List<JmsConnectionFactoryType<EntityBeanType<T>>> getAllJmsConnectionFactory()
   {
      List<JmsConnectionFactoryType<EntityBeanType<T>>> list = new ArrayList<JmsConnectionFactoryType<EntityBeanType<T>>>();
      List<Node> nodeList = childNode.get("jms-connection-factory");
      for(Node node: nodeList)
      {
         JmsConnectionFactoryType<EntityBeanType<T>>  type = new JmsConnectionFactoryTypeImpl<EntityBeanType<T>>(this, "jms-connection-factory", childNode, node);
         list.add(type);
      }
      return list;
   }
1338035
public static String getDefaultSSLServerSocketFactory() {
        if (defaultSSLServerSocketFactory == null) {
            defaultSSLServerSocketFactory = AccessController.doPrivileged(new PrivilegedAction<String>() {
                @Override
                public String run() {
                    return Security.getProperty("ssl.ServerSocketFactory.provider");
                }
            });
        }

        return defaultSSLServerSocketFactory;
    }
1181582
public static <T extends VersionedProtocol> T getProxy(
      Class<T> protocol,
      long clientVersion, InetSocketAddress addr,
      Configuration conf, SocketFactory factory) throws IOException {
    return getProtocolProxy(protocol, clientVersion,
        addr, conf, factory).getProxy();
  }
485704
public static String getDefaultSSLSocketFactory() {
        if (defaultSSLSocketFactory == null) {
            defaultSSLSocketFactory = AccessController.doPrivileged(new PrivilegedAction<String>() {
                @Override
                public String run() {
                    return Security.getProperty("ssl.SocketFactory.provider");
                }
            });
        }

        return defaultSSLSocketFactory;
    }
1098572
public SSLSocket buildSocket() throws KeyStoreException, CertificateException, NoSuchAlgorithmException, IOException, UnrecoverableKeyException, KeyManagementException
    {
        if (host == null) throw new IllegalStateException("Cannot create socket without host");

        // Get socket
        final SSLSocket s = (SSLSocket) build().getSocketFactory().createSocket(host, port);

        // Set protocols
        s.setEnabledProtocols(TLS.getUsable(TLS.TLS_PROTOCOLS, s.getSupportedProtocols()));
        s.setEnabledCipherSuites(TLS.getUsable(TLS.TLS_CIPHER_SUITES, s.getSupportedCipherSuites()));

        return s;
    }
1098871
private SSLSocket getNewSocket() throws IOException {
		String host = getUrl().getHost();
		int port = getPort();
		Socket socketConnection = new Socket();
		InetSocketAddress mapServerAddress = new InetSocketAddress(host, port);
		socketConnection.connect(mapServerAddress, mInitialConnectionTimeout);
		SSLSocket ret = (SSLSocket) mSocketFactory.createSocket(socketConnection, host, port, true);

		ret.setTcpNoDelay(true);
		ret.setWantClientAuth(true);

		// Check if all is good... Will throw IOException if we don't
		// like the other end...
		ret.getSession().getPeerCertificates();

		if (!mHostnameVerifier.verify(mUrl.getHost(), ret.getSession())) {
			throw new IOException("Hostname Verification failed! "
					+ "Did you set ifmapj.communication.verifypeerhost?");
		}

		return ret;
	}
710111
public static SSLContext getInstance(boolean server) throws GeneralSecurityException {
        SSLContext retInstance = null;
        if (server) {
            if (serverInstance == null) {
                synchronized (BogusSslContextFactory.class) {
                    if (serverInstance == null) {
                        try {
                            serverInstance = createBougusServerSslContext();
                        } catch (Exception ioe) {
                            throw new GeneralSecurityException("Can't create Server SSLContext:" + ioe);
                        }
                    }
                }
            }
            retInstance = serverInstance;
        } else {
            if (clientInstance == null) {
                synchronized (BogusSslContextFactory.class) {
                    if (clientInstance == null) {
                        clientInstance = createBougusClientSslContext();
                    }
                }
            }
            retInstance = clientInstance;
        }
        return retInstance;
    }