mirror of
https://codeberg.org/Mercury-IM/Smack
synced 2024-11-22 06:12:05 +01:00
Introduce SmackMessageException
This commit is contained in:
parent
b51a6c54e8
commit
7fce6b5a98
13 changed files with 76 additions and 46 deletions
|
@ -195,7 +195,7 @@ public class XMPPBOSHConnection extends AbstractXMPPConnection {
|
||||||
done = true;
|
done = true;
|
||||||
String errorMessage = "Timeout reached for the connection to "
|
String errorMessage = "Timeout reached for the connection to "
|
||||||
+ getHost() + ":" + getPort() + ".";
|
+ getHost() + ":" + getPort() + ".";
|
||||||
throw new SmackException(errorMessage);
|
throw new SmackException.SmackMessageException(errorMessage);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
* Copyright 2014-2015 Florian Schmaus
|
* Copyright 2014-2019 Florian Schmaus
|
||||||
*
|
*
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
* you may not use this file except in compliance with the License.
|
* you may not use this file except in compliance with the License.
|
||||||
|
@ -41,11 +41,11 @@ public class SmackException extends Exception {
|
||||||
*
|
*
|
||||||
* @param wrappedThrowable the root cause of the exception.
|
* @param wrappedThrowable the root cause of the exception.
|
||||||
*/
|
*/
|
||||||
public SmackException(Throwable wrappedThrowable) {
|
protected SmackException(Throwable wrappedThrowable) {
|
||||||
super(wrappedThrowable);
|
super(wrappedThrowable);
|
||||||
}
|
}
|
||||||
|
|
||||||
public SmackException(String message) {
|
protected SmackException(String message) {
|
||||||
super(message);
|
super(message);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -367,6 +367,22 @@ public class SmackException extends Exception {
|
||||||
public SmackWrappedException(Exception exception) {
|
public SmackWrappedException(Exception exception) {
|
||||||
super(exception);
|
super(exception);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public SmackWrappedException(String message, Exception exception) {
|
||||||
|
super(message, exception);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public static class SmackMessageException extends SmackException {
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
private static final long serialVersionUID = 1L;
|
||||||
|
|
||||||
|
public SmackMessageException(String message) {
|
||||||
|
super(message);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public static class SmackSaslException extends SmackException {
|
public static class SmackSaslException extends SmackException {
|
||||||
|
|
|
@ -350,7 +350,7 @@ public final class HttpFileUploadManager extends Manager {
|
||||||
}
|
}
|
||||||
|
|
||||||
if (uploadService == null) {
|
if (uploadService == null) {
|
||||||
throw new SmackException("No upload service specified and also none discovered.");
|
throw new SmackException.SmackMessageException("No upload service specified and also none discovered.");
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!uploadService.acceptsFileOfSize(fileSize)) {
|
if (!uploadService.acceptsFileOfSize(fileSize)) {
|
||||||
|
|
|
@ -21,7 +21,6 @@ import java.util.ArrayList;
|
||||||
import java.util.Collection;
|
import java.util.Collection;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
import org.jivesoftware.smack.SmackException;
|
|
||||||
import org.jivesoftware.smack.SmackException.FeatureNotSupportedException;
|
import org.jivesoftware.smack.SmackException.FeatureNotSupportedException;
|
||||||
import org.jivesoftware.smack.SmackException.NoResponseException;
|
import org.jivesoftware.smack.SmackException.NoResponseException;
|
||||||
import org.jivesoftware.smack.SmackException.NotConnectedException;
|
import org.jivesoftware.smack.SmackException.NotConnectedException;
|
||||||
|
@ -140,21 +139,23 @@ public class MultipleRecipientManager {
|
||||||
* @param connection the connection to use to send the reply.
|
* @param connection the connection to use to send the reply.
|
||||||
* @param original the previously received stanza that was sent to multiple recipients.
|
* @param original the previously received stanza that was sent to multiple recipients.
|
||||||
* @param reply the new message to send as a reply.
|
* @param reply the new message to send as a reply.
|
||||||
* @throws SmackException
|
|
||||||
* @throws XMPPErrorException
|
* @throws XMPPErrorException
|
||||||
* @throws InterruptedException
|
* @throws InterruptedException
|
||||||
|
* @throws NotConnectedException
|
||||||
|
* @throws FeatureNotSupportedException
|
||||||
|
* @throws NoResponseException
|
||||||
*/
|
*/
|
||||||
public static void reply(XMPPConnection connection, Message original, Message reply)
|
public static void reply(XMPPConnection connection, Message original, Message reply)
|
||||||
throws SmackException, XMPPErrorException, InterruptedException {
|
throws XMPPErrorException, InterruptedException, NotConnectedException, NoResponseException, FeatureNotSupportedException {
|
||||||
MultipleRecipientInfo info = getMultipleRecipientInfo(original);
|
MultipleRecipientInfo info = getMultipleRecipientInfo(original);
|
||||||
if (info == null) {
|
if (info == null) {
|
||||||
throw new SmackException("Original message does not contain multiple recipient info");
|
throw new IllegalArgumentException("Original message does not contain multiple recipient info");
|
||||||
}
|
}
|
||||||
if (info.shouldNotReply()) {
|
if (info.shouldNotReply()) {
|
||||||
throw new SmackException("Original message should not be replied");
|
throw new IllegalArgumentException("Original message should not be replied");
|
||||||
}
|
}
|
||||||
if (info.getReplyRoom() != null) {
|
if (info.getReplyRoom() != null) {
|
||||||
throw new SmackException("Reply should be sent through a room");
|
throw new IllegalArgumentException("Reply should be sent through a room");
|
||||||
}
|
}
|
||||||
// Any <thread/> element from the initial message MUST be copied into the reply.
|
// Any <thread/> element from the initial message MUST be copied into the reply.
|
||||||
if (original.getThread() != null) {
|
if (original.getThread() != null) {
|
||||||
|
|
|
@ -36,6 +36,7 @@ import org.jivesoftware.smack.SmackException;
|
||||||
import org.jivesoftware.smack.SmackException.FeatureNotSupportedException;
|
import org.jivesoftware.smack.SmackException.FeatureNotSupportedException;
|
||||||
import org.jivesoftware.smack.SmackException.NoResponseException;
|
import org.jivesoftware.smack.SmackException.NoResponseException;
|
||||||
import org.jivesoftware.smack.SmackException.NotConnectedException;
|
import org.jivesoftware.smack.SmackException.NotConnectedException;
|
||||||
|
import org.jivesoftware.smack.SmackException.SmackMessageException;
|
||||||
import org.jivesoftware.smack.XMPPConnection;
|
import org.jivesoftware.smack.XMPPConnection;
|
||||||
import org.jivesoftware.smack.XMPPConnectionRegistry;
|
import org.jivesoftware.smack.XMPPConnectionRegistry;
|
||||||
import org.jivesoftware.smack.XMPPException;
|
import org.jivesoftware.smack.XMPPException;
|
||||||
|
@ -409,12 +410,15 @@ public final class Socks5BytestreamManager extends Manager implements Bytestream
|
||||||
* @return the Socket to send/receive data to/from the user
|
* @return the Socket to send/receive data to/from the user
|
||||||
* @throws IOException if the bytestream could not be established
|
* @throws IOException if the bytestream could not be established
|
||||||
* @throws InterruptedException if the current thread was interrupted while waiting
|
* @throws InterruptedException if the current thread was interrupted while waiting
|
||||||
* @throws SmackException if the target does not support SOCKS5.
|
|
||||||
* @throws XMPPException
|
* @throws XMPPException
|
||||||
|
* @throws NotConnectedException
|
||||||
|
* @throws NoResponseException
|
||||||
|
* @throws SmackMessageException
|
||||||
|
* @throws FeatureNotSupportedException
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public Socks5BytestreamSession establishSession(Jid targetJID, String sessionID)
|
public Socks5BytestreamSession establishSession(Jid targetJID, String sessionID)
|
||||||
throws IOException, InterruptedException, SmackException, XMPPException {
|
throws IOException, InterruptedException, XMPPException, NoResponseException, NotConnectedException, SmackMessageException, FeatureNotSupportedException {
|
||||||
XMPPConnection connection = connection();
|
XMPPConnection connection = connection();
|
||||||
XMPPErrorException discoveryException = null;
|
XMPPErrorException discoveryException = null;
|
||||||
// check if target supports SOCKS5 Bytestream
|
// check if target supports SOCKS5 Bytestream
|
||||||
|
@ -439,7 +443,7 @@ public final class Socks5BytestreamManager extends Manager implements Bytestream
|
||||||
if (discoveryException != null) {
|
if (discoveryException != null) {
|
||||||
throw discoveryException;
|
throw discoveryException;
|
||||||
} else {
|
} else {
|
||||||
throw new SmackException("no SOCKS5 proxies available");
|
throw new SmackException.SmackMessageException("no SOCKS5 proxies available");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -480,7 +484,7 @@ public final class Socks5BytestreamManager extends Manager implements Bytestream
|
||||||
StreamHost usedStreamHost = initiation.getStreamHost(streamHostUsed.getJID());
|
StreamHost usedStreamHost = initiation.getStreamHost(streamHostUsed.getJID());
|
||||||
|
|
||||||
if (usedStreamHost == null) {
|
if (usedStreamHost == null) {
|
||||||
throw new SmackException("Remote user responded with unknown host");
|
throw new SmackException.SmackMessageException("Remote user responded with unknown host");
|
||||||
}
|
}
|
||||||
|
|
||||||
// build SOCKS5 client
|
// build SOCKS5 client
|
||||||
|
|
|
@ -32,6 +32,9 @@ import java.util.concurrent.TimeoutException;
|
||||||
import java.util.logging.Logger;
|
import java.util.logging.Logger;
|
||||||
|
|
||||||
import org.jivesoftware.smack.SmackException;
|
import org.jivesoftware.smack.SmackException;
|
||||||
|
import org.jivesoftware.smack.SmackException.NoResponseException;
|
||||||
|
import org.jivesoftware.smack.SmackException.NotConnectedException;
|
||||||
|
import org.jivesoftware.smack.SmackException.SmackMessageException;
|
||||||
import org.jivesoftware.smack.XMPPException;
|
import org.jivesoftware.smack.XMPPException;
|
||||||
import org.jivesoftware.smack.util.CloseableUtil;
|
import org.jivesoftware.smack.util.CloseableUtil;
|
||||||
import org.jivesoftware.smack.util.StringUtils;
|
import org.jivesoftware.smack.util.StringUtils;
|
||||||
|
@ -74,16 +77,18 @@ public class Socks5Client {
|
||||||
* @throws IOException if initializing the socket failed due to a network error
|
* @throws IOException if initializing the socket failed due to a network error
|
||||||
* @throws TimeoutException if connecting to SOCKS5 proxy timed out
|
* @throws TimeoutException if connecting to SOCKS5 proxy timed out
|
||||||
* @throws InterruptedException if the current thread was interrupted while waiting
|
* @throws InterruptedException if the current thread was interrupted while waiting
|
||||||
* @throws SmackException if the connection to the SOCKS5 proxy failed
|
|
||||||
* @throws XMPPException
|
* @throws XMPPException
|
||||||
|
* @throws SmackMessageException
|
||||||
|
* @throws NotConnectedException
|
||||||
|
* @throws NoResponseException
|
||||||
*/
|
*/
|
||||||
public Socket getSocket(int timeout) throws IOException, InterruptedException,
|
public Socket getSocket(int timeout) throws IOException, InterruptedException,
|
||||||
TimeoutException, SmackException, XMPPException {
|
TimeoutException, XMPPException, SmackMessageException, NotConnectedException, NoResponseException {
|
||||||
// wrap connecting in future for timeout
|
// wrap connecting in future for timeout
|
||||||
FutureTask<Socket> futureTask = new FutureTask<>(new Callable<Socket>() {
|
FutureTask<Socket> futureTask = new FutureTask<>(new Callable<Socket>() {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Socket call() throws IOException, SmackException {
|
public Socket call() throws IOException, SmackMessageException {
|
||||||
|
|
||||||
// initialize socket
|
// initialize socket
|
||||||
Socket socket = new Socket();
|
Socket socket = new Socket();
|
||||||
|
@ -95,7 +100,7 @@ public class Socks5Client {
|
||||||
try {
|
try {
|
||||||
establish(socket);
|
establish(socket);
|
||||||
}
|
}
|
||||||
catch (SmackException e) {
|
catch (SmackMessageException e) {
|
||||||
if (!socket.isClosed()) {
|
if (!socket.isClosed()) {
|
||||||
CloseableUtil.maybeClose(socket, LOGGER);
|
CloseableUtil.maybeClose(socket, LOGGER);
|
||||||
}
|
}
|
||||||
|
@ -120,13 +125,13 @@ public class Socks5Client {
|
||||||
if (cause instanceof IOException) {
|
if (cause instanceof IOException) {
|
||||||
throw (IOException) cause;
|
throw (IOException) cause;
|
||||||
}
|
}
|
||||||
if (cause instanceof SmackException) {
|
if (cause instanceof SmackMessageException) {
|
||||||
throw (SmackException) cause;
|
throw (SmackMessageException) cause;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// throw generic Smack exception if unexpected exception was thrown
|
// throw generic Smack exception if unexpected exception was thrown
|
||||||
throw new SmackException("Error while connecting to SOCKS5 proxy", e);
|
throw new IllegalStateException("Error while connecting to SOCKS5 proxy", e);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -137,10 +142,10 @@ public class Socks5Client {
|
||||||
* supported by the Socks5Client.
|
* supported by the Socks5Client.
|
||||||
*
|
*
|
||||||
* @param socket connected to a SOCKS5 proxy
|
* @param socket connected to a SOCKS5 proxy
|
||||||
* @throws SmackException
|
|
||||||
* @throws IOException
|
* @throws IOException
|
||||||
|
* @throws SmackMessageException
|
||||||
*/
|
*/
|
||||||
protected void establish(Socket socket) throws SmackException, IOException {
|
protected void establish(Socket socket) throws IOException, SmackMessageException {
|
||||||
|
|
||||||
byte[] connectionRequest;
|
byte[] connectionRequest;
|
||||||
byte[] connectionResponse;
|
byte[] connectionResponse;
|
||||||
|
@ -166,7 +171,7 @@ public class Socks5Client {
|
||||||
|
|
||||||
// check if server responded with correct version and no-authentication method
|
// check if server responded with correct version and no-authentication method
|
||||||
if (response[0] != (byte) 0x05 || response[1] != (byte) 0x00) {
|
if (response[0] != (byte) 0x05 || response[1] != (byte) 0x00) {
|
||||||
throw new SmackException("Remote SOCKS5 server responded with unexpected version: " + response[0] + ' ' + response[1] + ". Should be 0x05 0x00.");
|
throw new SmackException.SmackMessageException("Remote SOCKS5 server responded with unexpected version: " + response[0] + ' ' + response[1] + ". Should be 0x05 0x00.");
|
||||||
}
|
}
|
||||||
|
|
||||||
// request SOCKS5 connection with given address/digest
|
// request SOCKS5 connection with given address/digest
|
||||||
|
@ -180,7 +185,7 @@ public class Socks5Client {
|
||||||
// verify response
|
// verify response
|
||||||
connectionRequest[1] = (byte) 0x00; // set expected return status to 0
|
connectionRequest[1] = (byte) 0x00; // set expected return status to 0
|
||||||
if (!Arrays.equals(connectionRequest, connectionResponse)) {
|
if (!Arrays.equals(connectionRequest, connectionResponse)) {
|
||||||
throw new SmackException(
|
throw new SmackException.SmackMessageException(
|
||||||
"Connection request does not equal connection response. Response: "
|
"Connection request does not equal connection response. Response: "
|
||||||
+ Arrays.toString(connectionResponse) + ". Request: "
|
+ Arrays.toString(connectionResponse) + ". Request: "
|
||||||
+ Arrays.toString(connectionRequest));
|
+ Arrays.toString(connectionRequest));
|
||||||
|
|
|
@ -24,6 +24,7 @@ import java.util.concurrent.TimeoutException;
|
||||||
import org.jivesoftware.smack.SmackException;
|
import org.jivesoftware.smack.SmackException;
|
||||||
import org.jivesoftware.smack.SmackException.NoResponseException;
|
import org.jivesoftware.smack.SmackException.NoResponseException;
|
||||||
import org.jivesoftware.smack.SmackException.NotConnectedException;
|
import org.jivesoftware.smack.SmackException.NotConnectedException;
|
||||||
|
import org.jivesoftware.smack.SmackException.SmackMessageException;
|
||||||
import org.jivesoftware.smack.XMPPConnection;
|
import org.jivesoftware.smack.XMPPConnection;
|
||||||
import org.jivesoftware.smack.XMPPException;
|
import org.jivesoftware.smack.XMPPException;
|
||||||
import org.jivesoftware.smack.XMPPException.XMPPErrorException;
|
import org.jivesoftware.smack.XMPPException.XMPPErrorException;
|
||||||
|
@ -73,7 +74,7 @@ public class Socks5ClientForInitiator extends Socks5Client {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Socket getSocket(int timeout) throws IOException, InterruptedException,
|
public Socket getSocket(int timeout) throws IOException, InterruptedException,
|
||||||
TimeoutException, XMPPException, SmackException {
|
TimeoutException, XMPPException, SmackMessageException, NotConnectedException, NoResponseException {
|
||||||
Socket socket;
|
Socket socket;
|
||||||
|
|
||||||
// check if stream host is the local SOCKS5 proxy
|
// check if stream host is the local SOCKS5 proxy
|
||||||
|
@ -81,7 +82,7 @@ public class Socks5ClientForInitiator extends Socks5Client {
|
||||||
Socks5Proxy socks5Server = Socks5Proxy.getSocks5Proxy();
|
Socks5Proxy socks5Server = Socks5Proxy.getSocks5Proxy();
|
||||||
socket = socks5Server.getSocket(this.digest);
|
socket = socks5Server.getSocket(this.digest);
|
||||||
if (socket == null) {
|
if (socket == null) {
|
||||||
throw new SmackException("target is not connected to SOCKS5 proxy");
|
throw new SmackException.SmackMessageException("target is not connected to SOCKS5 proxy");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
|
@ -111,7 +112,6 @@ public class Socks5ClientForInitiator extends Socks5Client {
|
||||||
* @throws NoResponseException
|
* @throws NoResponseException
|
||||||
* @throws NotConnectedException
|
* @throws NotConnectedException
|
||||||
* @throws InterruptedException
|
* @throws InterruptedException
|
||||||
* @throws SmackException if there was no response from the server.
|
|
||||||
*/
|
*/
|
||||||
private void activate() throws NoResponseException, XMPPErrorException, NotConnectedException, InterruptedException {
|
private void activate() throws NoResponseException, XMPPErrorException, NotConnectedException, InterruptedException {
|
||||||
Bytestream activate = createStreamHostActivation();
|
Bytestream activate = createStreamHostActivation();
|
||||||
|
|
|
@ -431,7 +431,7 @@ public final class Socks5Proxy {
|
||||||
// first byte is version should be 5
|
// first byte is version should be 5
|
||||||
int b = in.read();
|
int b = in.read();
|
||||||
if (b != 5) {
|
if (b != 5) {
|
||||||
throw new SmackException("Only SOCKS5 supported");
|
throw new SmackException.SmackMessageException("Only SOCKS5 supported");
|
||||||
}
|
}
|
||||||
|
|
||||||
// second byte number of authentication methods supported
|
// second byte number of authentication methods supported
|
||||||
|
@ -457,7 +457,7 @@ public final class Socks5Proxy {
|
||||||
authMethodSelectionResponse[1] = (byte) 0xFF; // no acceptable methods
|
authMethodSelectionResponse[1] = (byte) 0xFF; // no acceptable methods
|
||||||
out.write(authMethodSelectionResponse);
|
out.write(authMethodSelectionResponse);
|
||||||
out.flush();
|
out.flush();
|
||||||
throw new SmackException("Authentication method not supported");
|
throw new SmackException.SmackMessageException("Authentication method not supported");
|
||||||
}
|
}
|
||||||
|
|
||||||
authMethodSelectionResponse[1] = (byte) 0x00; // no-authentication method
|
authMethodSelectionResponse[1] = (byte) 0x00; // no-authentication method
|
||||||
|
@ -476,7 +476,7 @@ public final class Socks5Proxy {
|
||||||
out.write(connectionRequest);
|
out.write(connectionRequest);
|
||||||
out.flush();
|
out.flush();
|
||||||
|
|
||||||
throw new SmackException("Connection is not allowed");
|
throw new SmackException.SmackMessageException("Connection is not allowed");
|
||||||
}
|
}
|
||||||
|
|
||||||
connectionRequest[1] = (byte) 0x00; // set return status to 0 (success)
|
connectionRequest[1] = (byte) 0x00; // set return status to 0 (success)
|
||||||
|
|
|
@ -19,7 +19,7 @@ package org.jivesoftware.smackx.bytestreams.socks5;
|
||||||
import java.io.DataInputStream;
|
import java.io.DataInputStream;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
|
|
||||||
import org.jivesoftware.smack.SmackException;
|
import org.jivesoftware.smack.SmackException.SmackMessageException;
|
||||||
import org.jivesoftware.smack.util.SHA1;
|
import org.jivesoftware.smack.util.SHA1;
|
||||||
|
|
||||||
import org.jxmpp.jid.Jid;
|
import org.jxmpp.jid.Jid;
|
||||||
|
@ -55,14 +55,14 @@ public class Socks5Utils {
|
||||||
* @param in the DataInputStream to read the message from
|
* @param in the DataInputStream to read the message from
|
||||||
* @return the SOCKS5 message
|
* @return the SOCKS5 message
|
||||||
* @throws IOException if a network error occurred
|
* @throws IOException if a network error occurred
|
||||||
* @throws SmackException if the SOCKS5 message contains an unsupported address type
|
* @throws SmackMessageException if the SOCKS5 message contains an unsupported address type
|
||||||
*/
|
*/
|
||||||
public static byte[] receiveSocks5Message(DataInputStream in) throws IOException, SmackException {
|
public static byte[] receiveSocks5Message(DataInputStream in) throws IOException, SmackMessageException {
|
||||||
byte[] header = new byte[5];
|
byte[] header = new byte[5];
|
||||||
in.readFully(header, 0, 5);
|
in.readFully(header, 0, 5);
|
||||||
|
|
||||||
if (header[3] != (byte) 0x03) {
|
if (header[3] != (byte) 0x03) {
|
||||||
throw new SmackException("Unsupported SOCKS5 address type: " + header[3] + " (expected: 0x03)");
|
throw new SmackMessageException("Unsupported SOCKS5 address type: " + header[3] + " (expected: 0x03)");
|
||||||
}
|
}
|
||||||
|
|
||||||
int addressLength = header[4];
|
int addressLength = header[4];
|
||||||
|
|
|
@ -260,7 +260,7 @@ public final class Socks5TestProxy {
|
||||||
// first byte is version should be 5
|
// first byte is version should be 5
|
||||||
int b = in.read();
|
int b = in.read();
|
||||||
if (b != 5) {
|
if (b != 5) {
|
||||||
throw new SmackException("Only SOCKS5 supported");
|
throw new SmackException.SmackMessageException("Only SOCKS5 supported");
|
||||||
}
|
}
|
||||||
|
|
||||||
// second byte number of authentication methods supported
|
// second byte number of authentication methods supported
|
||||||
|
@ -286,7 +286,7 @@ public final class Socks5TestProxy {
|
||||||
authMethodSelectionResponse[1] = (byte) 0xFF; // no acceptable methods
|
authMethodSelectionResponse[1] = (byte) 0xFF; // no acceptable methods
|
||||||
out.write(authMethodSelectionResponse);
|
out.write(authMethodSelectionResponse);
|
||||||
out.flush();
|
out.flush();
|
||||||
throw new SmackException("Authentication method not supported");
|
throw new SmackException.SmackMessageException("Authentication method not supported");
|
||||||
}
|
}
|
||||||
|
|
||||||
authMethodSelectionResponse[1] = (byte) 0x00; // no-authentication method
|
authMethodSelectionResponse[1] = (byte) 0x00; // no-authentication method
|
||||||
|
|
|
@ -76,7 +76,9 @@ public class IoTDiscoveryIntegrationTest extends AbstractSmackIntegrationTest {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public static ThingState registerThing(IoTDiscoveryManager iotDiscoveryManager, Thing thing) throws XMPPErrorException, InterruptedException, SmackException {
|
public static ThingState registerThing(IoTDiscoveryManager iotDiscoveryManager, Thing thing)
|
||||||
|
throws XMPPErrorException, InterruptedException, SmackException.SmackMessageException,
|
||||||
|
NotConnectedException, NoResponseException {
|
||||||
int attempts = 0;
|
int attempts = 0;
|
||||||
while (true) {
|
while (true) {
|
||||||
try {
|
try {
|
||||||
|
@ -86,7 +88,7 @@ public class IoTDiscoveryIntegrationTest extends AbstractSmackIntegrationTest {
|
||||||
iotDiscoveryManager.unregister();
|
iotDiscoveryManager.unregister();
|
||||||
}
|
}
|
||||||
if (attempts++ > 3) {
|
if (attempts++ > 3) {
|
||||||
throw new SmackException("Could no register thing");
|
throw new SmackException.SmackMessageException("Could no register thing");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -26,6 +26,7 @@ import java.util.logging.Level;
|
||||||
import java.util.logging.Logger;
|
import java.util.logging.Logger;
|
||||||
|
|
||||||
import org.jivesoftware.smack.SmackException;
|
import org.jivesoftware.smack.SmackException;
|
||||||
|
import org.jivesoftware.smack.SmackException.NoResponseException;
|
||||||
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.XMPPException;
|
import org.jivesoftware.smack.XMPPException;
|
||||||
|
@ -105,13 +106,14 @@ public class BridgedResolver extends TransportResolver {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void initialize() throws SmackException, XMPPErrorException, InterruptedException {
|
public void initialize() throws SmackException.SmackMessageException, XMPPErrorException, InterruptedException,
|
||||||
|
NoResponseException, NotConnectedException {
|
||||||
|
|
||||||
clearCandidates();
|
clearCandidates();
|
||||||
|
|
||||||
if (!RTPBridge.serviceAvailable(connection)) {
|
if (!RTPBridge.serviceAvailable(connection)) {
|
||||||
setInitialized();
|
setInitialized();
|
||||||
throw new SmackException("No RTP Bridge service available");
|
throw new SmackException.SmackMessageException("No RTP Bridge service available");
|
||||||
}
|
}
|
||||||
setInitialized();
|
setInitialized();
|
||||||
|
|
||||||
|
|
|
@ -911,13 +911,13 @@ public class XMPPTCPConnection extends AbstractXMPPConnection {
|
||||||
case "urn:ietf:params:xml:ns:xmpp-tls":
|
case "urn:ietf:params:xml:ns:xmpp-tls":
|
||||||
// TLS negotiation has failed. The server will close the connection
|
// TLS negotiation has failed. The server will close the connection
|
||||||
// TODO Parse failure stanza
|
// TODO Parse failure stanza
|
||||||
throw new SmackException("TLS negotiation has failed");
|
throw new SmackException.SmackMessageException("TLS negotiation has failed");
|
||||||
case "http://jabber.org/protocol/compress":
|
case "http://jabber.org/protocol/compress":
|
||||||
// Stream compression has been denied. This is a recoverable
|
// Stream compression has been denied. This is a recoverable
|
||||||
// situation. It is still possible to authenticate and
|
// situation. It is still possible to authenticate and
|
||||||
// use the connection but using an uncompressed connection
|
// use the connection but using an uncompressed connection
|
||||||
// TODO Parse failure stanza
|
// TODO Parse failure stanza
|
||||||
compressSyncPoint.reportFailure(new SmackException(
|
compressSyncPoint.reportFailure(new SmackException.SmackMessageException(
|
||||||
"Could not establish compression"));
|
"Could not establish compression"));
|
||||||
break;
|
break;
|
||||||
case SaslStreamElements.NAMESPACE:
|
case SaslStreamElements.NAMESPACE:
|
||||||
|
@ -957,7 +957,7 @@ public class XMPPTCPConnection extends AbstractXMPPConnection {
|
||||||
if (enabled.isResumeSet()) {
|
if (enabled.isResumeSet()) {
|
||||||
smSessionId = enabled.getId();
|
smSessionId = enabled.getId();
|
||||||
if (StringUtils.isNullOrEmpty(smSessionId)) {
|
if (StringUtils.isNullOrEmpty(smSessionId)) {
|
||||||
SmackException xmppException = new SmackException("Stream Management 'enabled' element with resume attribute but without session id received");
|
SmackException xmppException = new SmackException.SmackMessageException("Stream Management 'enabled' element with resume attribute but without session id received");
|
||||||
smEnabledSyncPoint.reportFailure(xmppException);
|
smEnabledSyncPoint.reportFailure(xmppException);
|
||||||
throw xmppException;
|
throw xmppException;
|
||||||
}
|
}
|
||||||
|
@ -1069,7 +1069,7 @@ public class XMPPTCPConnection extends AbstractXMPPConnection {
|
||||||
case XmlPullParser.END_DOCUMENT:
|
case XmlPullParser.END_DOCUMENT:
|
||||||
// END_DOCUMENT only happens in an error case, as otherwise we would see a
|
// END_DOCUMENT only happens in an error case, as otherwise we would see a
|
||||||
// closing stream element before.
|
// closing stream element before.
|
||||||
throw new SmackException(
|
throw new SmackException.SmackMessageException(
|
||||||
"Parser got END_DOCUMENT event. This could happen e.g. if the server closed the connection without sending a closing stream element");
|
"Parser got END_DOCUMENT event. This could happen e.g. if the server closed the connection without sending a closing stream element");
|
||||||
}
|
}
|
||||||
eventType = parser.next();
|
eventType = parser.next();
|
||||||
|
|
Loading…
Reference in a new issue