1
0
Fork 0
mirror of https://github.com/vanitasvitae/Smack.git synced 2025-09-12 10:39:38 +02:00

Allow custom SocketFactory to be set (SMACK-140).

git-svn-id: http://svn.igniterealtime.org/svn/repos/smack/trunk@2330 b35dd754-fafc-0310-a699-88a17e54d16e
This commit is contained in:
Matt Tucker 2004-07-05 22:22:02 +00:00 committed by mtucker
parent 0b49cbc374
commit 757c7450d9
2 changed files with 42 additions and 28 deletions

View file

@ -60,15 +60,11 @@ import java.net.*;
import java.security.NoSuchAlgorithmException;
import java.security.KeyManagementException;
import javax.net.SocketFactory;
import javax.net.ssl.SSLSocketFactory;
import com.sun.net.ssl.X509TrustManager;
import java.security.cert.X509Certificate;
import java.security.cert.CertificateExpiredException;
import java.security.cert.CertificateNotYetValidException;
import org.jivesoftware.smack.packet.XMPPError;
/**
* Creates an SSL connection to a XMPP server.
*
@ -76,6 +72,8 @@ import org.jivesoftware.smack.packet.XMPPError;
*/
public class SSLXMPPConnection extends XMPPConnection {
private static SocketFactory socketFactory = new DummySSLSocketFactory();
/**
* Creates a new SSL connection to the specified host on the default
* SSL port (5223).
@ -103,21 +101,7 @@ public class SSLXMPPConnection extends XMPPConnection {
* appropiate error messages to end-users.
*/
public SSLXMPPConnection(String host, int port) throws XMPPException {
this.host = host;
this.port = port;
try {
SSLSocketFactory sslFactory = new DummySSLSocketFactory();
this.socket = sslFactory.createSocket(host, port);
}
catch (UnknownHostException uhe) {
throw new XMPPException("Could not connect to " + host + ":" + port + ".",
new XMPPError(504), uhe);
}
catch (IOException ioe) {
throw new XMPPException("XMPPError connecting to " + host + ":" + port + ".",
new XMPPError(502), ioe);
}
super.init();
super(host, port, socketFactory);
}
public boolean isSecureConnection() {