diff --git a/source/org/jivesoftware/smack/SSLXMPPConnection.java b/source/org/jivesoftware/smack/SSLXMPPConnection.java index 2badae4b5..563bcb894 100644 --- a/source/org/jivesoftware/smack/SSLXMPPConnection.java +++ b/source/org/jivesoftware/smack/SSLXMPPConnection.java @@ -59,6 +59,7 @@ import java.security.KeyManagementException; import java.security.cert.*; import javax.net.ssl.*; import javax.net.*; +import com.sun.net.ssl.*; /** * Creates an SSL connection to a XMPP (Jabber) server. @@ -76,7 +77,7 @@ public class SSLXMPPConnection extends XMPPConnection { this.port = port; try { SSLSocketFactory sslFactory = new DummySSLSocketFactory(); - this.socket = (SSLSocket)sslFactory.createSocket(host, port); + this.socket = sslFactory.createSocket(host, port); } catch (UnknownHostException uhe) { throw new XMPPException("Could not connect to " + host + ":" + port + ".", uhe); @@ -155,17 +156,20 @@ public class SSLXMPPConnection extends XMPPConnection { */ private static class DummyTrustManager implements X509TrustManager { - public void checkClientTrusted(X509Certificate[] chain, String authType) { - + public boolean isClientTrusted(X509Certificate[] cert) { + return true; } - public void checkServerTrusted(X509Certificate[] chain, String authType) { - try { - chain[0].checkValidity(); + public boolean isServerTrusted(X509Certificate[] cert) { + try { + cert[0].checkValidity(); + return true; } catch (CertificateExpiredException e) { + return false; } catch (CertificateNotYetValidException e) { + return false; } } diff --git a/source/org/jivesoftware/smack/XMPPException.java b/source/org/jivesoftware/smack/XMPPException.java index a272a1455..b9cbe27bd 100644 --- a/source/org/jivesoftware/smack/XMPPException.java +++ b/source/org/jivesoftware/smack/XMPPException.java @@ -52,9 +52,19 @@ package org.jivesoftware.smack; +import java.io.PrintStream; +import java.io.PrintWriter; +/** + * A generic exception that is thrown when an error occurs performing an + * XMPP operation. + * + * @author Matt Tucker + */ public class XMPPException extends Exception { + private Throwable cause; + public XMPPException() { super(); } @@ -64,10 +74,30 @@ public class XMPPException extends Exception { } public XMPPException(Throwable cause) { - super(cause); + super(); + this.cause = cause; } public XMPPException(String message, Throwable cause) { - super(message, cause); + super(message); + this.cause = cause; + } + + public void printStackTrace() { + super.printStackTrace(); + System.err.println("Nested Exception: "); + cause.printStackTrace(); + } + + public void printStackTrace(PrintStream out) { + super.printStackTrace(out); + out.println("Nested Exception: "); + cause.printStackTrace(out); + } + + public void printStackTrace(PrintWriter out) { + super.printStackTrace(out); + out.println("Nested Exception: "); + cause.printStackTrace(out); } }