mirror of
https://github.com/vanitasvitae/Smack.git
synced 2024-11-22 03:52:06 +01:00
Smack 4.2.2
-----BEGIN PGP SIGNATURE----- iQGTBAABCgB9FiEEl3UFnzoh3OFr5PuuIjmn6PWFIFIFAloZnf5fFIAAAAAALgAo aXNzdWVyLWZwckBub3RhdGlvbnMub3BlbnBncC5maWZ0aGhvcnNlbWFuLm5ldDk3 NzUwNTlGM0EyMURDRTE2QkU0RkJBRTIyMzlBN0U4RjU4NTIwNTIACgkQIjmn6PWF IFLcIQgAsTLRI3sWIZDPRuI5YaU/y6beqqzMp5cQgk/9+9DHGBoziLEU1spkvBs2 Yvlwu3NtHSJsI+ibzYLEFRnzEwuW07vXw7R5J+kRSZrsE40z1HCQRwUIXDkPgghe MuL6vT6OV+kLqKb33YLSBuT2fj2pzVE6mRmMsnFekay/weEqOGUZaY9Hd5lJ31/9 33fQC0FQfKULQ5t7PbdfX4dDDNWn0n6v+KjvjaskHI0oA+vqPWxPkj8gNXWW8b72 tVV4h5uXQ0ziK3oED79+GH+DSiET9N2PmsZ7woXiFy5H8KbcQDVe5Pazf+Iq2VQ+ Vi6Vxikr6Ak+v2Xkt+e3x9E6mZDI1w== =CVqq -----END PGP SIGNATURE----- Merge tag '4.2.2' Smack 4.2.2
This commit is contained in:
commit
76a6b9f2a1
16 changed files with 235 additions and 81 deletions
|
@ -141,6 +141,37 @@ hr {
|
||||||
|
|
||||||
<div id="pageBody">
|
<div id="pageBody">
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
<h2>4.2.2 -- <span style="font-weight: normal;">2017-11-25</span></h2>
|
||||||
|
|
||||||
|
<h2> Bug
|
||||||
|
</h2>
|
||||||
|
<ul>
|
||||||
|
<li>[<a href='https://issues.igniterealtime.org/browse/SMACK-775'>SMACK-775</a>] - Create callback interface for ReconnectionManager
|
||||||
|
</li>
|
||||||
|
<li>[<a href='https://issues.igniterealtime.org/browse/SMACK-778'>SMACK-778</a>] - ReconnectionManager.reconnect() can throw NotConnectedException
|
||||||
|
</li>
|
||||||
|
<li>[<a href='https://issues.igniterealtime.org/browse/SMACK-779'>SMACK-779</a>] - smack-android erroneously depends on smack-omemo and smack-omemo-signal
|
||||||
|
</li>
|
||||||
|
<li>[<a href='https://issues.igniterealtime.org/browse/SMACK-780'>SMACK-780</a>] - PushNotificationManager's isSupported logic does query the server, whereas it should query the bare JID
|
||||||
|
</li>
|
||||||
|
<li>[<a href='https://issues.igniterealtime.org/browse/SMACK-781'>SMACK-781</a>] - MiniDnsResolver does not correctly handle the case when NOERROR is returned together with an empty answer section.
|
||||||
|
</li>
|
||||||
|
<li>[<a href='https://issues.igniterealtime.org/browse/SMACK-782'>SMACK-782</a>] - MultiUserChat does not remove the subject listener causing a memory leak
|
||||||
|
</li>
|
||||||
|
<li>[<a href='https://issues.igniterealtime.org/browse/SMACK-783'>SMACK-783</a>] - InvitationRejectionListener fires multiple times
|
||||||
|
</li>
|
||||||
|
<li>[<a href='https://issues.igniterealtime.org/browse/SMACK-784'>SMACK-784</a>] - StringUtils.numbersAndLetters has the numbers twice, resulting in a lower entropy
|
||||||
|
</li>
|
||||||
|
<li>[<a href='https://issues.igniterealtime.org/browse/SMACK-785'>SMACK-785</a>] - OfflineMessageManager.getMessages() does count the pending messages incorrectly, causing an unnecessary delay
|
||||||
|
</li>
|
||||||
|
<li>[<a href='https://issues.igniterealtime.org/browse/SMACK-786'>SMACK-786</a>] - Race condition when resuming a stream
|
||||||
|
</li>
|
||||||
|
<li>[<a href='https://issues.igniterealtime.org/browse/SMACK-787'>SMACK-787</a>] - Presence.getPriority() may return Integer.MIN_VALUE.
|
||||||
|
</li>
|
||||||
|
</ul>
|
||||||
|
|
||||||
<h2>4.2.1 -- <span style="font-weight: normal;">2017-08-14</span></h2>
|
<h2>4.2.1 -- <span style="font-weight: normal;">2017-08-14</span></h2>
|
||||||
|
|
||||||
<h2> Bug
|
<h2> Bug
|
||||||
|
|
|
@ -432,7 +432,6 @@ public class XMPPBOSHConnection extends AbstractXMPPConnection {
|
||||||
throw new RuntimeException(e);
|
throw new RuntimeException(e);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
notifyReconnection();
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
|
|
|
@ -45,16 +45,19 @@ public class AbstractConnectionListener implements ConnectionListener {
|
||||||
// do nothing
|
// do nothing
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Deprecated
|
||||||
@Override
|
@Override
|
||||||
public void reconnectingIn(int seconds) {
|
public void reconnectingIn(int seconds) {
|
||||||
// do nothing
|
// do nothing
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Deprecated
|
||||||
@Override
|
@Override
|
||||||
public void reconnectionFailed(Exception e) {
|
public void reconnectionFailed(Exception e) {
|
||||||
// do nothing
|
// do nothing
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Deprecated
|
||||||
@Override
|
@Override
|
||||||
public void reconnectionSuccessful() {
|
public void reconnectionSuccessful() {
|
||||||
// do nothing
|
// do nothing
|
||||||
|
|
|
@ -1241,6 +1241,8 @@ public abstract class AbstractXMPPConnection implements XMPPConnection {
|
||||||
/**
|
/**
|
||||||
* Sends a notification indicating that the connection was reconnected successfully.
|
* Sends a notification indicating that the connection was reconnected successfully.
|
||||||
*/
|
*/
|
||||||
|
// TODO: Remove in Smack 4.3
|
||||||
|
@Deprecated
|
||||||
protected void notifyReconnection() {
|
protected void notifyReconnection() {
|
||||||
// Notify connection listeners of the reconnection.
|
// Notify connection listeners of the reconnection.
|
||||||
for (ConnectionListener listener : connectionListeners) {
|
for (ConnectionListener listener : connectionListeners) {
|
||||||
|
|
|
@ -18,6 +18,7 @@
|
||||||
package org.jivesoftware.smack;
|
package org.jivesoftware.smack;
|
||||||
|
|
||||||
import java.net.InetAddress;
|
import java.net.InetAddress;
|
||||||
|
import java.security.KeyStore;
|
||||||
import java.util.Arrays;
|
import java.util.Arrays;
|
||||||
import java.util.Collection;
|
import java.util.Collection;
|
||||||
import java.util.Collections;
|
import java.util.Collections;
|
||||||
|
@ -505,7 +506,7 @@ public abstract class ConnectionConfiguration {
|
||||||
private SecurityMode securityMode = SecurityMode.ifpossible;
|
private SecurityMode securityMode = SecurityMode.ifpossible;
|
||||||
private DnssecMode dnssecMode = DnssecMode.disabled;
|
private DnssecMode dnssecMode = DnssecMode.disabled;
|
||||||
private String keystorePath = System.getProperty("javax.net.ssl.keyStore");
|
private String keystorePath = System.getProperty("javax.net.ssl.keyStore");
|
||||||
private String keystoreType = "jks";
|
private String keystoreType = KeyStore.getDefaultType();
|
||||||
private String pkcs11Library = "pkcs11.config";
|
private String pkcs11Library = "pkcs11.config";
|
||||||
private SSLContext customSSLContext;
|
private SSLContext customSSLContext;
|
||||||
private String[] enabledSSLProtocols;
|
private String[] enabledSSLProtocols;
|
||||||
|
|
|
@ -64,7 +64,10 @@ public interface ConnectionListener {
|
||||||
/**
|
/**
|
||||||
* The connection has reconnected successfully to the server. Connections will
|
* The connection has reconnected successfully to the server. Connections will
|
||||||
* reconnect to the server when the previous socket connection was abruptly closed.
|
* reconnect to the server when the previous socket connection was abruptly closed.
|
||||||
|
* @deprecated use {@link #connected(XMPPConnection)} or {@link #authenticated(XMPPConnection, boolean)} instead.
|
||||||
*/
|
*/
|
||||||
|
// TODO: Remove in Smack 4.3
|
||||||
|
@Deprecated
|
||||||
public void reconnectionSuccessful();
|
public void reconnectionSuccessful();
|
||||||
|
|
||||||
// The next two methods *must* only be invoked by ReconnectionManager
|
// The next two methods *must* only be invoked by ReconnectionManager
|
||||||
|
@ -78,6 +81,8 @@ public interface ConnectionListener {
|
||||||
*
|
*
|
||||||
* @param seconds remaining seconds before attempting a reconnection.
|
* @param seconds remaining seconds before attempting a reconnection.
|
||||||
*/
|
*/
|
||||||
|
// TODO: Remove in Smack 4.3
|
||||||
|
@Deprecated
|
||||||
public void reconnectingIn(int seconds);
|
public void reconnectingIn(int seconds);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -90,5 +95,7 @@ public interface ConnectionListener {
|
||||||
*
|
*
|
||||||
* @param e the exception that caused the reconnection to fail.
|
* @param e the exception that caused the reconnection to fail.
|
||||||
*/
|
*/
|
||||||
|
// TODO: Remove in Smack 4.3
|
||||||
|
@Deprecated
|
||||||
public void reconnectionFailed(Exception e);
|
public void reconnectionFailed(Exception e);
|
||||||
}
|
}
|
||||||
|
|
|
@ -0,0 +1,50 @@
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* Copyright 2017 Florian Schmaus.
|
||||||
|
*
|
||||||
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
* you may not use this file except in compliance with the License.
|
||||||
|
* You may obtain a copy of the License at
|
||||||
|
*
|
||||||
|
* http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
*
|
||||||
|
* Unless required by applicable law or agreed to in writing, software
|
||||||
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
* See the License for the specific language governing permissions and
|
||||||
|
* limitations under the License.
|
||||||
|
*/
|
||||||
|
package org.jivesoftware.smack;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* A listener for the {@link ReconnectionManager}. Use
|
||||||
|
* {@link ReconnectionManager#addReconnectionListener(ReconnectionListener)} to add new listeners to the reconnection
|
||||||
|
* manager.
|
||||||
|
*
|
||||||
|
* @since 4.2.2
|
||||||
|
*/
|
||||||
|
public interface ReconnectionListener {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The connection will retry to reconnect in the specified number of seconds.
|
||||||
|
* <p>
|
||||||
|
* Note: This method is only called if {@link ReconnectionManager#isAutomaticReconnectEnabled()} returns true, i.e.
|
||||||
|
* only when the reconnection manager is enabled for the connection.
|
||||||
|
* </p>
|
||||||
|
*
|
||||||
|
* @param seconds remaining seconds before attempting a reconnection.
|
||||||
|
*/
|
||||||
|
public void reconnectingIn(int seconds);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* An attempt to connect to the server has failed. The connection will keep trying reconnecting to the server in a
|
||||||
|
* moment.
|
||||||
|
* <p>
|
||||||
|
* Note: This method is only called if {@link ReconnectionManager#isAutomaticReconnectEnabled()} returns true, i.e.
|
||||||
|
* only when the reconnection manager is enabled for the connection.
|
||||||
|
* </p>
|
||||||
|
*
|
||||||
|
* @param e the exception that caused the reconnection to fail.
|
||||||
|
*/
|
||||||
|
public void reconnectionFailed(Exception e);
|
||||||
|
}
|
|
@ -20,7 +20,9 @@ import java.io.IOException;
|
||||||
import java.lang.ref.WeakReference;
|
import java.lang.ref.WeakReference;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import java.util.Random;
|
import java.util.Random;
|
||||||
|
import java.util.Set;
|
||||||
import java.util.WeakHashMap;
|
import java.util.WeakHashMap;
|
||||||
|
import java.util.concurrent.CopyOnWriteArraySet;
|
||||||
import java.util.logging.Level;
|
import java.util.logging.Level;
|
||||||
import java.util.logging.Logger;
|
import java.util.logging.Logger;
|
||||||
|
|
||||||
|
@ -103,6 +105,8 @@ public final class ReconnectionManager {
|
||||||
return enabledPerDefault;
|
return enabledPerDefault;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private final Set<ReconnectionListener> reconnectionListeners = new CopyOnWriteArraySet<>();
|
||||||
|
|
||||||
// Holds the connection to the server
|
// Holds the connection to the server
|
||||||
private final WeakReference<AbstractXMPPConnection> weakRefConnection;
|
private final WeakReference<AbstractXMPPConnection> weakRefConnection;
|
||||||
private final int randomBase = new Random().nextInt(13) + 2; // between 2 and 15 seconds
|
private final int randomBase = new Random().nextInt(13) + 2; // between 2 and 15 seconds
|
||||||
|
@ -134,6 +138,27 @@ public final class ReconnectionManager {
|
||||||
defaultReconnectionPolicy = reconnectionPolicy;
|
defaultReconnectionPolicy = reconnectionPolicy;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Add a new reconnection listener.
|
||||||
|
*
|
||||||
|
* @param listener the listener to add
|
||||||
|
* @return <code>true</code> if the listener was not already added
|
||||||
|
* @since 4.2.2
|
||||||
|
*/
|
||||||
|
public boolean addReconnectionListener(ReconnectionListener listener) {
|
||||||
|
return reconnectionListeners.add(listener);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Remove a reconnection listener.
|
||||||
|
* @param listener the listener to remove
|
||||||
|
* @return <code>true</code> if the listener was active and got removed.
|
||||||
|
* @since 4.2.2
|
||||||
|
*/
|
||||||
|
public boolean removeReconnectionListener(ReconnectionListener listener) {
|
||||||
|
return reconnectionListeners.remove(listener);
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Set the fixed delay in seconds between the reconnection attempts Also set the connection
|
* Set the fixed delay in seconds between the reconnection attempts Also set the connection
|
||||||
* policy to {@link ReconnectionPolicy#FIXED_DELAY}.
|
* policy to {@link ReconnectionPolicy#FIXED_DELAY}.
|
||||||
|
@ -208,6 +233,7 @@ public final class ReconnectionManager {
|
||||||
/**
|
/**
|
||||||
* The process will try the reconnection until the connection succeed or the user cancel it
|
* The process will try the reconnection until the connection succeed or the user cancel it
|
||||||
*/
|
*/
|
||||||
|
@SuppressWarnings("deprecation")
|
||||||
@Override
|
@Override
|
||||||
public void run() {
|
public void run() {
|
||||||
final AbstractXMPPConnection connection = weakRefConnection.get();
|
final AbstractXMPPConnection connection = weakRefConnection.get();
|
||||||
|
@ -233,6 +259,9 @@ public final class ReconnectionManager {
|
||||||
try {
|
try {
|
||||||
Thread.sleep(1000);
|
Thread.sleep(1000);
|
||||||
remainingSeconds--;
|
remainingSeconds--;
|
||||||
|
for (ReconnectionListener listener : reconnectionListeners) {
|
||||||
|
listener.reconnectingIn(remainingSeconds);
|
||||||
|
}
|
||||||
for (ConnectionListener listener : connection.connectionListeners) {
|
for (ConnectionListener listener : connection.connectionListeners) {
|
||||||
listener.reconnectingIn(remainingSeconds);
|
listener.reconnectingIn(remainingSeconds);
|
||||||
}
|
}
|
||||||
|
@ -244,6 +273,9 @@ public final class ReconnectionManager {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
for (ReconnectionListener listener : reconnectionListeners) {
|
||||||
|
listener.reconnectingIn(0);
|
||||||
|
}
|
||||||
for (ConnectionListener listener : connection.connectionListeners) {
|
for (ConnectionListener listener : connection.connectionListeners) {
|
||||||
listener.reconnectingIn(0);
|
listener.reconnectingIn(0);
|
||||||
}
|
}
|
||||||
|
@ -269,6 +301,9 @@ public final class ReconnectionManager {
|
||||||
}
|
}
|
||||||
catch (SmackException | IOException | XMPPException e) {
|
catch (SmackException | IOException | XMPPException e) {
|
||||||
// Fires the failed reconnection notification
|
// Fires the failed reconnection notification
|
||||||
|
for (ReconnectionListener listener : reconnectionListeners) {
|
||||||
|
listener.reconnectionFailed(e);
|
||||||
|
}
|
||||||
for (ConnectionListener listener : connection.connectionListeners) {
|
for (ConnectionListener listener : connection.connectionListeners) {
|
||||||
listener.reconnectionFailed(e);
|
listener.reconnectionFailed(e);
|
||||||
}
|
}
|
||||||
|
|
|
@ -18,8 +18,13 @@ package org.jivesoftware.smack.debugger;
|
||||||
|
|
||||||
import java.io.Reader;
|
import java.io.Reader;
|
||||||
import java.io.Writer;
|
import java.io.Writer;
|
||||||
|
import java.util.logging.Logger;
|
||||||
|
|
||||||
|
import org.jivesoftware.smack.AbstractConnectionListener;
|
||||||
|
import org.jivesoftware.smack.AbstractXMPPConnection;
|
||||||
import org.jivesoftware.smack.ConnectionListener;
|
import org.jivesoftware.smack.ConnectionListener;
|
||||||
|
import org.jivesoftware.smack.ReconnectionListener;
|
||||||
|
import org.jivesoftware.smack.ReconnectionManager;
|
||||||
import org.jivesoftware.smack.XMPPConnection;
|
import org.jivesoftware.smack.XMPPConnection;
|
||||||
import org.jivesoftware.smack.packet.TopLevelStreamElement;
|
import org.jivesoftware.smack.packet.TopLevelStreamElement;
|
||||||
import org.jivesoftware.smack.util.ObservableReader;
|
import org.jivesoftware.smack.util.ObservableReader;
|
||||||
|
@ -31,9 +36,12 @@ import org.jxmpp.jid.EntityFullJid;
|
||||||
|
|
||||||
public abstract class AbstractDebugger extends SmackDebugger {
|
public abstract class AbstractDebugger extends SmackDebugger {
|
||||||
|
|
||||||
|
private static final Logger LOGGER = Logger.getLogger(AbstractDebugger.class.getName());
|
||||||
|
|
||||||
public static boolean printInterpreted = false;
|
public static boolean printInterpreted = false;
|
||||||
|
|
||||||
private final ConnectionListener connListener;
|
private final ConnectionListener connListener;
|
||||||
|
private final ReconnectionListener reconnectionListener;
|
||||||
private final ReaderListener readerListener;
|
private final ReaderListener readerListener;
|
||||||
private final WriterListener writerListener;
|
private final WriterListener writerListener;
|
||||||
|
|
||||||
|
@ -63,7 +71,7 @@ public abstract class AbstractDebugger extends SmackDebugger {
|
||||||
};
|
};
|
||||||
this.writer.addWriterListener(writerListener);
|
this.writer.addWriterListener(writerListener);
|
||||||
|
|
||||||
connListener = new ConnectionListener() {
|
connListener = new AbstractConnectionListener() {
|
||||||
@Override
|
@Override
|
||||||
public void connected(XMPPConnection connection) {
|
public void connected(XMPPConnection connection) {
|
||||||
log("XMPPConnection connected ("
|
log("XMPPConnection connected ("
|
||||||
|
@ -92,6 +100,9 @@ public abstract class AbstractDebugger extends SmackDebugger {
|
||||||
connection +
|
connection +
|
||||||
")", e);
|
")", e);
|
||||||
}
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
reconnectionListener = new ReconnectionListener() {
|
||||||
@Override
|
@Override
|
||||||
public void reconnectionFailed(Exception e) {
|
public void reconnectionFailed(Exception e) {
|
||||||
log(
|
log(
|
||||||
|
@ -100,13 +111,6 @@ public abstract class AbstractDebugger extends SmackDebugger {
|
||||||
")", e);
|
")", e);
|
||||||
}
|
}
|
||||||
@Override
|
@Override
|
||||||
public void reconnectionSuccessful() {
|
|
||||||
log(
|
|
||||||
"XMPPConnection reconnected (" +
|
|
||||||
connection +
|
|
||||||
")");
|
|
||||||
}
|
|
||||||
@Override
|
|
||||||
public void reconnectingIn(int seconds) {
|
public void reconnectingIn(int seconds) {
|
||||||
log(
|
log(
|
||||||
"XMPPConnection (" +
|
"XMPPConnection (" +
|
||||||
|
@ -114,6 +118,14 @@ public abstract class AbstractDebugger extends SmackDebugger {
|
||||||
") will reconnect in " + seconds);
|
") will reconnect in " + seconds);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
if (connection instanceof AbstractXMPPConnection) {
|
||||||
|
AbstractXMPPConnection abstractXmppConnection = (AbstractXMPPConnection) connection;
|
||||||
|
ReconnectionManager.getInstanceFor(abstractXmppConnection).addReconnectionListener(reconnectionListener);
|
||||||
|
} else {
|
||||||
|
LOGGER.info("The connection instance " + connection
|
||||||
|
+ " is not an instance of AbstractXMPPConnection, thus we can not install the ReconnectionListener");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
protected abstract void log(String logMessage);
|
protected abstract void log(String logMessage);
|
||||||
|
|
|
@ -88,6 +88,7 @@ public class DummyConnection extends AbstractXMPPConnection {
|
||||||
user = getUserJid();
|
user = getUserJid();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@SuppressWarnings("deprecation")
|
||||||
@Override
|
@Override
|
||||||
protected void connectInternal() {
|
protected void connectInternal() {
|
||||||
connected = true;
|
connected = true;
|
||||||
|
@ -95,6 +96,7 @@ public class DummyConnection extends AbstractXMPPConnection {
|
||||||
tlsHandled.reportSuccess();
|
tlsHandled.reportSuccess();
|
||||||
streamId = "dummy-" + new Random(new Date().getTime()).nextInt();
|
streamId = "dummy-" + new Random(new Date().getTime()).nextInt();
|
||||||
|
|
||||||
|
// TODO: Remove in Smack 4.3, and likely the suppression of the deprecation warning.
|
||||||
if (reconnect) {
|
if (reconnect) {
|
||||||
notifyReconnection();
|
notifyReconnection();
|
||||||
}
|
}
|
||||||
|
|
|
@ -17,12 +17,15 @@
|
||||||
|
|
||||||
package org.jivesoftware.smackx.debugger.slf4j;
|
package org.jivesoftware.smackx.debugger.slf4j;
|
||||||
|
|
||||||
import org.jivesoftware.smack.ConnectionListener;
|
import org.jivesoftware.smack.AbstractConnectionListener;
|
||||||
|
import org.jivesoftware.smack.ReconnectionListener;
|
||||||
import org.jivesoftware.smack.XMPPConnection;
|
import org.jivesoftware.smack.XMPPConnection;
|
||||||
|
|
||||||
import org.slf4j.Logger;
|
import org.slf4j.Logger;
|
||||||
|
|
||||||
class SLF4JLoggingConnectionListener implements ConnectionListener {
|
// TODO: The suppression of deprecated API can be removed in Smack 4.3.
|
||||||
|
@SuppressWarnings("deprecation")
|
||||||
|
class SLF4JLoggingConnectionListener extends AbstractConnectionListener implements ReconnectionListener {
|
||||||
private final XMPPConnection connection;
|
private final XMPPConnection connection;
|
||||||
private final Logger logger;
|
private final Logger logger;
|
||||||
|
|
||||||
|
@ -56,11 +59,6 @@ class SLF4JLoggingConnectionListener implements ConnectionListener {
|
||||||
logger.debug("({}) Reconnection failed due to an exception: {}", connection.hashCode(), e);
|
logger.debug("({}) Reconnection failed due to an exception: {}", connection.hashCode(), e);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public void reconnectionSuccessful() {
|
|
||||||
logger.debug("({}) Connection reconnected", connection.hashCode());
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void reconnectingIn(int seconds) {
|
public void reconnectingIn(int seconds) {
|
||||||
logger.debug("({}) Connection will reconnect in {}", connection.hashCode(), seconds);
|
logger.debug("({}) Connection will reconnect in {}", connection.hashCode(), seconds);
|
||||||
|
|
|
@ -21,6 +21,8 @@ import java.io.Reader;
|
||||||
import java.io.Writer;
|
import java.io.Writer;
|
||||||
import java.util.concurrent.atomic.AtomicBoolean;
|
import java.util.concurrent.atomic.AtomicBoolean;
|
||||||
|
|
||||||
|
import org.jivesoftware.smack.AbstractXMPPConnection;
|
||||||
|
import org.jivesoftware.smack.ReconnectionManager;
|
||||||
import org.jivesoftware.smack.SmackConfiguration;
|
import org.jivesoftware.smack.SmackConfiguration;
|
||||||
import org.jivesoftware.smack.XMPPConnection;
|
import org.jivesoftware.smack.XMPPConnection;
|
||||||
import org.jivesoftware.smack.debugger.SmackDebugger;
|
import org.jivesoftware.smack.debugger.SmackDebugger;
|
||||||
|
@ -40,6 +42,8 @@ import org.slf4j.LoggerFactory;
|
||||||
*/
|
*/
|
||||||
public class SLF4JSmackDebugger extends SmackDebugger {
|
public class SLF4JSmackDebugger extends SmackDebugger {
|
||||||
|
|
||||||
|
private static final java.util.logging.Logger LOGGER = java.util.logging.Logger.getLogger(SLF4JSmackDebugger.class.getName());
|
||||||
|
|
||||||
public static final String LOGGER_NAME = "SMACK";
|
public static final String LOGGER_NAME = "SMACK";
|
||||||
private static final Logger logger = LoggerFactory.getLogger(LOGGER_NAME);
|
private static final Logger logger = LoggerFactory.getLogger(LOGGER_NAME);
|
||||||
public static final AtomicBoolean printInterpreted = new AtomicBoolean(true);
|
public static final AtomicBoolean printInterpreted = new AtomicBoolean(true);
|
||||||
|
@ -70,7 +74,17 @@ public class SLF4JSmackDebugger extends SmackDebugger {
|
||||||
this.writer.addWriterListener(slf4JRawXmlListener);
|
this.writer.addWriterListener(slf4JRawXmlListener);
|
||||||
this.reader = new ObservableReader(Validate.notNull(reader));
|
this.reader = new ObservableReader(Validate.notNull(reader));
|
||||||
this.reader.addReaderListener(slf4JRawXmlListener);
|
this.reader.addReaderListener(slf4JRawXmlListener);
|
||||||
this.connection.addConnectionListener(new SLF4JLoggingConnectionListener(connection, logger));
|
|
||||||
|
final SLF4JLoggingConnectionListener loggingConnectionListener = new SLF4JLoggingConnectionListener(connection, logger);
|
||||||
|
this.connection.addConnectionListener(loggingConnectionListener);
|
||||||
|
|
||||||
|
if (connection instanceof AbstractXMPPConnection) {
|
||||||
|
AbstractXMPPConnection abstractXmppConnection = (AbstractXMPPConnection) connection;
|
||||||
|
ReconnectionManager.getInstanceFor(abstractXmppConnection).addReconnectionListener(loggingConnectionListener);
|
||||||
|
} else {
|
||||||
|
LOGGER.info("The connection instance " + connection
|
||||||
|
+ " is not an instance of AbstractXMPPConnection, thus we can not install the ReconnectionListener");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
|
@ -61,7 +61,10 @@ import javax.swing.table.DefaultTableModel;
|
||||||
import javax.swing.text.BadLocationException;
|
import javax.swing.text.BadLocationException;
|
||||||
|
|
||||||
import org.jivesoftware.smack.AbstractConnectionListener;
|
import org.jivesoftware.smack.AbstractConnectionListener;
|
||||||
|
import org.jivesoftware.smack.AbstractXMPPConnection;
|
||||||
import org.jivesoftware.smack.ConnectionListener;
|
import org.jivesoftware.smack.ConnectionListener;
|
||||||
|
import org.jivesoftware.smack.ReconnectionListener;
|
||||||
|
import org.jivesoftware.smack.ReconnectionManager;
|
||||||
import org.jivesoftware.smack.SmackException.NotConnectedException;
|
import org.jivesoftware.smack.SmackException.NotConnectedException;
|
||||||
import org.jivesoftware.smack.XMPPConnection;
|
import org.jivesoftware.smack.XMPPConnection;
|
||||||
import org.jivesoftware.smack.debugger.SmackDebugger;
|
import org.jivesoftware.smack.debugger.SmackDebugger;
|
||||||
|
@ -143,6 +146,7 @@ public class EnhancedDebugger extends SmackDebugger {
|
||||||
private JFormattedTextField statusField = null;
|
private JFormattedTextField statusField = null;
|
||||||
|
|
||||||
private ConnectionListener connListener = null;
|
private ConnectionListener connListener = null;
|
||||||
|
private final ReconnectionListener reconnectionListener;
|
||||||
|
|
||||||
private Writer writer;
|
private Writer writer;
|
||||||
private Reader reader;
|
private Reader reader;
|
||||||
|
@ -169,6 +173,36 @@ public class EnhancedDebugger extends SmackDebugger {
|
||||||
public EnhancedDebugger(XMPPConnection connection) {
|
public EnhancedDebugger(XMPPConnection connection) {
|
||||||
super(connection);
|
super(connection);
|
||||||
|
|
||||||
|
reconnectionListener = new ReconnectionListener() {
|
||||||
|
@Override
|
||||||
|
public void reconnectingIn(final int seconds) {
|
||||||
|
SwingUtilities.invokeLater(new Runnable() {
|
||||||
|
@Override
|
||||||
|
public void run() {
|
||||||
|
statusField.setValue("Attempt to reconnect in " + seconds + " seconds");
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void reconnectionFailed(Exception e) {
|
||||||
|
SwingUtilities.invokeLater(new Runnable() {
|
||||||
|
@Override
|
||||||
|
public void run() {
|
||||||
|
statusField.setValue("Reconnection failed");
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
if (connection instanceof AbstractXMPPConnection) {
|
||||||
|
AbstractXMPPConnection abstractXmppConnection = (AbstractXMPPConnection) connection;
|
||||||
|
ReconnectionManager.getInstanceFor(abstractXmppConnection).addReconnectionListener(reconnectionListener);
|
||||||
|
} else {
|
||||||
|
LOGGER.info("The connection instance " + connection
|
||||||
|
+ " is not an instance of AbstractXMPPConnection, thus we can not install the ReconnectionListener");
|
||||||
|
}
|
||||||
|
|
||||||
// We'll arrange the UI into six tabs. The first tab contains all data, the second
|
// We'll arrange the UI into six tabs. The first tab contains all data, the second
|
||||||
// client generated XML, the third server generated XML, the fourth allows to send
|
// client generated XML, the third server generated XML, the fourth allows to send
|
||||||
// ad-hoc messages and the fifth contains connection information.
|
// ad-hoc messages and the fifth contains connection information.
|
||||||
|
@ -208,36 +242,6 @@ public class EnhancedDebugger extends SmackDebugger {
|
||||||
});
|
});
|
||||||
|
|
||||||
}
|
}
|
||||||
@Override
|
|
||||||
public void reconnectingIn(final int seconds) {
|
|
||||||
SwingUtilities.invokeLater(new Runnable() {
|
|
||||||
@Override
|
|
||||||
public void run() {
|
|
||||||
statusField.setValue("Attempt to reconnect in " + seconds + " seconds");
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void reconnectionSuccessful() {
|
|
||||||
SwingUtilities.invokeLater(new Runnable() {
|
|
||||||
@Override
|
|
||||||
public void run() {
|
|
||||||
statusField.setValue("Reconnection stablished");
|
|
||||||
EnhancedDebuggerWindow.connectionEstablished(EnhancedDebugger.this);
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void reconnectionFailed(Exception e) {
|
|
||||||
SwingUtilities.invokeLater(new Runnable() {
|
|
||||||
@Override
|
|
||||||
public void run() {
|
|
||||||
statusField.setValue("Reconnection failed");
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
|
||||||
};
|
};
|
||||||
|
|
||||||
EnhancedDebuggerWindow.addDebugger(this);
|
EnhancedDebuggerWindow.addDebugger(this);
|
||||||
|
|
|
@ -120,8 +120,7 @@ public final class InBandBytestreamManager extends Manager implements Bytestream
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void reconnectionSuccessful() {
|
public void connected(XMPPConnection connection) {
|
||||||
// re-create the manager for this connection
|
|
||||||
InBandBytestreamManager.getByteStreamManager(connection);
|
InBandBytestreamManager.getByteStreamManager(connection);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -16,7 +16,7 @@
|
||||||
*/
|
*/
|
||||||
package org.jivesoftware.smackx.jingle.transports;
|
package org.jivesoftware.smackx.jingle.transports;
|
||||||
|
|
||||||
import org.jivesoftware.smack.ConnectionListener;
|
import org.jivesoftware.smack.AbstractConnectionListener;
|
||||||
import org.jivesoftware.smack.XMPPConnection;
|
import org.jivesoftware.smack.XMPPConnection;
|
||||||
import org.jivesoftware.smackx.jingle.JingleSession;
|
import org.jivesoftware.smackx.jingle.JingleSession;
|
||||||
import org.jivesoftware.smackx.jingle.element.JingleContentTransport;
|
import org.jivesoftware.smackx.jingle.element.JingleContentTransport;
|
||||||
|
@ -25,7 +25,7 @@ import org.jivesoftware.smackx.jingle.element.JingleContentTransport;
|
||||||
* Manager for a JingleTransport method.
|
* Manager for a JingleTransport method.
|
||||||
* @param <D> JingleContentTransport.
|
* @param <D> JingleContentTransport.
|
||||||
*/
|
*/
|
||||||
public abstract class JingleTransportManager<D extends JingleContentTransport> implements ConnectionListener {
|
public abstract class JingleTransportManager<D extends JingleContentTransport> extends AbstractConnectionListener {
|
||||||
|
|
||||||
private final XMPPConnection connection;
|
private final XMPPConnection connection;
|
||||||
|
|
||||||
|
@ -57,18 +57,4 @@ public abstract class JingleTransportManager<D extends JingleContentTransport> i
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public void reconnectionSuccessful() {
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void reconnectingIn(int seconds) {
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void reconnectionFailed(Exception e) {
|
|
||||||
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -676,10 +676,6 @@ public class XMPPTCPConnection extends AbstractXMPPConnection {
|
||||||
*/
|
*/
|
||||||
@SuppressWarnings("LiteralClassName")
|
@SuppressWarnings("LiteralClassName")
|
||||||
private void proceedTLSReceived() throws NoSuchAlgorithmException, CertificateException, IOException, KeyStoreException, NoSuchProviderException, UnrecoverableKeyException, KeyManagementException, SmackException {
|
private void proceedTLSReceived() throws NoSuchAlgorithmException, CertificateException, IOException, KeyStoreException, NoSuchProviderException, UnrecoverableKeyException, KeyManagementException, SmackException {
|
||||||
SSLContext context = this.config.getCustomSSLContext();
|
|
||||||
KeyStore ks = null;
|
|
||||||
KeyManager[] kms = null;
|
|
||||||
PasswordCallback pcb = null;
|
|
||||||
SmackDaneVerifier daneVerifier = null;
|
SmackDaneVerifier daneVerifier = null;
|
||||||
|
|
||||||
if (config.getDnssecMode() == DnssecMode.needsDnssecAndDane) {
|
if (config.getDnssecMode() == DnssecMode.needsDnssecAndDane) {
|
||||||
|
@ -693,6 +689,10 @@ public class XMPPTCPConnection extends AbstractXMPPConnection {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
SSLContext context = this.config.getCustomSSLContext();
|
||||||
|
KeyStore ks = null;
|
||||||
|
PasswordCallback pcb = null;
|
||||||
|
|
||||||
if (context == null) {
|
if (context == null) {
|
||||||
final String keyStoreType = config.getKeystoreType();
|
final String keyStoreType = config.getKeystoreType();
|
||||||
final CallbackHandler callbackHandler = config.getCallbackHandler();
|
final CallbackHandler callbackHandler = config.getCallbackHandler();
|
||||||
|
@ -737,21 +737,32 @@ public class XMPPTCPConnection extends AbstractXMPPConnection {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
KeyManager[] kms = null;
|
||||||
|
|
||||||
if (ks != null) {
|
if (ks != null) {
|
||||||
String keyManagerFactoryAlgorithm = KeyManagerFactory.getDefaultAlgorithm();
|
String keyManagerFactoryAlgorithm = KeyManagerFactory.getDefaultAlgorithm();
|
||||||
KeyManagerFactory kmf = KeyManagerFactory.getInstance(keyManagerFactoryAlgorithm);
|
KeyManagerFactory kmf = null;
|
||||||
try {
|
try {
|
||||||
if (pcb == null) {
|
kmf = KeyManagerFactory.getInstance(keyManagerFactoryAlgorithm);
|
||||||
kmf.init(ks, null);
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
kmf.init(ks, pcb.getPassword());
|
|
||||||
pcb.clearPassword();
|
|
||||||
}
|
|
||||||
kms = kmf.getKeyManagers();
|
|
||||||
}
|
}
|
||||||
catch (NullPointerException npe) {
|
catch (NoSuchAlgorithmException e) {
|
||||||
LOGGER.log(Level.WARNING, "NullPointerException", npe);
|
LOGGER.log(Level.FINE, "Could get the default KeyManagerFactory for the '"
|
||||||
|
+ keyManagerFactoryAlgorithm + "' algorithm", e);
|
||||||
|
}
|
||||||
|
if (kmf != null) {
|
||||||
|
try {
|
||||||
|
if (pcb == null) {
|
||||||
|
kmf.init(ks, null);
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
kmf.init(ks, pcb.getPassword());
|
||||||
|
pcb.clearPassword();
|
||||||
|
}
|
||||||
|
kms = kmf.getKeyManagers();
|
||||||
|
}
|
||||||
|
catch (NullPointerException npe) {
|
||||||
|
LOGGER.log(Level.WARNING, "NullPointerException", npe);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue