protected void init(String serviceName, ProxyInfo proxy) { this.serviceName = serviceName; this.proxy = proxy; keystorePath = System.getProperty("javax.net.ssl.keyStore"); keystoreType = "jks"; pkcs11Library = "pkcs11.config"; // Setting the SocketFactory according to proxy supplied socketFactory = proxy.getSocketFactory(); }
/** * Initialize the XMPP connection. * * @param jid the jid to use * @param server the server to use (not using dns srv) may be null * @param port the port * @return the XMPPConnection prepared to connect */ private Connection prepareConnection(String jid, String server, int port) { boolean useProxy = settings.getBoolean(BeemApplication.PROXY_USE_KEY, false); ProxyInfo proxyinfo = ProxyInfo.forNoProxy(); if (useProxy) { String stype = settings.getString(BeemApplication.PROXY_TYPE_KEY, "HTTP"); String phost = settings.getString(BeemApplication.PROXY_SERVER_KEY, ""); String puser = settings.getString(BeemApplication.PROXY_USERNAME_KEY, ""); String ppass = settings.getString(BeemApplication.PROXY_PASSWORD_KEY, ""); int pport = Integer.parseInt(settings.getString(BeemApplication.PROXY_PORT_KEY, "1080")); ProxyInfo.ProxyType type = ProxyType.valueOf(stype); proxyinfo = new ProxyInfo(type, phost, pport, puser, ppass); } String serviceName = StringUtils.parseServer(jid); if (port != -1 || !TextUtils.isEmpty(server)) { if (port == -1) port = 5222; if (TextUtils.isEmpty(server)) server = serviceName; config = new ConnectionConfiguration(server, port, serviceName, proxyinfo); } else { config = new ConnectionConfiguration(serviceName, proxyinfo); } if (settings.getBoolean(BeemApplication.SMACK_DEBUG_KEY, false)) config.setDebuggerEnabled(true); return new XMPPConnection(config); }
/** * Creates a new ConnectionConfiguration for the specified service name. A DNS SRV lookup will be * performed to find out the actual host address and port to use for the connection. * * @param serviceName the name of the service provided by an XMPP server. */ public ConnectionConfiguration(String serviceName) { init(serviceName, ProxyInfo.forDefaultProxy()); }
/** * Creates a new ConnectionConfiguration for a connection that will connect to the desired host * and port. * * @param host the host where the XMPP server is running. * @param port the port where the XMPP is listening. */ public ConnectionConfiguration(String host, int port) { initHostAddresses(host, port); init(host, ProxyInfo.forDefaultProxy()); }