mirror of
https://codeberg.org/Mercury-IM/Smack
synced 2024-11-26 00:02:06 +01:00
Compatible with JDK 1.2 and 1.3.
git-svn-id: http://svn.igniterealtime.org/svn/repos/smack/trunk@1831 b35dd754-fafc-0310-a699-88a17e54d16e
This commit is contained in:
parent
f5ee8e1eb1
commit
b2fa523fcb
2 changed files with 42 additions and 8 deletions
|
@ -59,6 +59,7 @@ import java.security.KeyManagementException;
|
||||||
import java.security.cert.*;
|
import java.security.cert.*;
|
||||||
import javax.net.ssl.*;
|
import javax.net.ssl.*;
|
||||||
import javax.net.*;
|
import javax.net.*;
|
||||||
|
import com.sun.net.ssl.*;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Creates an SSL connection to a XMPP (Jabber) server.
|
* Creates an SSL connection to a XMPP (Jabber) server.
|
||||||
|
@ -76,7 +77,7 @@ public class SSLXMPPConnection extends XMPPConnection {
|
||||||
this.port = port;
|
this.port = port;
|
||||||
try {
|
try {
|
||||||
SSLSocketFactory sslFactory = new DummySSLSocketFactory();
|
SSLSocketFactory sslFactory = new DummySSLSocketFactory();
|
||||||
this.socket = (SSLSocket)sslFactory.createSocket(host, port);
|
this.socket = sslFactory.createSocket(host, port);
|
||||||
}
|
}
|
||||||
catch (UnknownHostException uhe) {
|
catch (UnknownHostException uhe) {
|
||||||
throw new XMPPException("Could not connect to " + host + ":" + port + ".", 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 {
|
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) {
|
public boolean isServerTrusted(X509Certificate[] cert) {
|
||||||
try {
|
try {
|
||||||
chain[0].checkValidity();
|
cert[0].checkValidity();
|
||||||
|
return true;
|
||||||
}
|
}
|
||||||
catch (CertificateExpiredException e) {
|
catch (CertificateExpiredException e) {
|
||||||
|
return false;
|
||||||
}
|
}
|
||||||
catch (CertificateNotYetValidException e) {
|
catch (CertificateNotYetValidException e) {
|
||||||
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -52,9 +52,19 @@
|
||||||
|
|
||||||
package org.jivesoftware.smack;
|
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 {
|
public class XMPPException extends Exception {
|
||||||
|
|
||||||
|
private Throwable cause;
|
||||||
|
|
||||||
public XMPPException() {
|
public XMPPException() {
|
||||||
super();
|
super();
|
||||||
}
|
}
|
||||||
|
@ -64,10 +74,30 @@ public class XMPPException extends Exception {
|
||||||
}
|
}
|
||||||
|
|
||||||
public XMPPException(Throwable cause) {
|
public XMPPException(Throwable cause) {
|
||||||
super(cause);
|
super();
|
||||||
|
this.cause = cause;
|
||||||
}
|
}
|
||||||
|
|
||||||
public XMPPException(String message, Throwable 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);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue