mirror of
https://github.com/vanitasvitae/Smack.git
synced 2024-11-22 03:52:06 +01:00
Add message String to all SmackExceptions
SMACK-599
This commit is contained in:
parent
387be5bded
commit
d04517cd08
2 changed files with 36 additions and 8 deletions
|
@ -54,7 +54,7 @@ public class SmackException extends Exception {
|
|||
}
|
||||
|
||||
/**
|
||||
* Exception thrown always when there was no response to an IQ request within the packet reply
|
||||
* Exception thrown always when there was no response to an (IQ) request within the packet reply
|
||||
* timeout of the used connection instance.
|
||||
*/
|
||||
public static class NoResponseException extends SmackException {
|
||||
|
@ -64,6 +64,7 @@ public class SmackException extends Exception {
|
|||
private static final long serialVersionUID = -6523363748984543636L;
|
||||
|
||||
public NoResponseException() {
|
||||
super("No response received within packet reply timeout");
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -75,6 +76,7 @@ public class SmackException extends Exception {
|
|||
private static final long serialVersionUID = 3216216839100019278L;
|
||||
|
||||
public NotLoggedInException() {
|
||||
super("Client is not logged in");
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -86,6 +88,7 @@ public class SmackException extends Exception {
|
|||
private static final long serialVersionUID = 5011416918049935231L;
|
||||
|
||||
public AlreadyLoggedInException() {
|
||||
super("Client is already logged in");
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -97,6 +100,7 @@ public class SmackException extends Exception {
|
|||
private static final long serialVersionUID = 5011416918049135231L;
|
||||
|
||||
public AlreadyConnectedException() {
|
||||
super("Client is already connected");
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -108,6 +112,7 @@ public class SmackException extends Exception {
|
|||
private static final long serialVersionUID = 9197980400776001173L;
|
||||
|
||||
public NotConnectedException() {
|
||||
super("Client is not, or no longer, connected");
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -122,21 +127,40 @@ public class SmackException extends Exception {
|
|||
}
|
||||
}
|
||||
|
||||
public static class SecurityRequiredException extends SmackException {
|
||||
public static abstract class SecurityRequiredException extends SmackException {
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
private static final long serialVersionUID = 384291845029773545L;
|
||||
|
||||
public SecurityRequiredException() {
|
||||
}
|
||||
|
||||
public SecurityRequiredException(String message) {
|
||||
super(message);
|
||||
}
|
||||
}
|
||||
|
||||
public static class SecurityRequiredByClientException extends SecurityRequiredException {
|
||||
/**
|
||||
*
|
||||
*/
|
||||
private static final long serialVersionUID = 2395325821201543159L;
|
||||
|
||||
public SecurityRequiredByClientException() {
|
||||
super("SSL/TLS required by client but not supported by server");
|
||||
}
|
||||
}
|
||||
|
||||
public static class SecurityRequiredByServerException extends SecurityRequiredException {
|
||||
/**
|
||||
*
|
||||
*/
|
||||
private static final long serialVersionUID = 8268148813117631819L;
|
||||
|
||||
public SecurityRequiredByServerException() {
|
||||
super("SSL/TLS required by server but disabled in client");
|
||||
}
|
||||
}
|
||||
|
||||
public static class SecurityNotPossibleException extends SmackException {
|
||||
|
||||
/**
|
||||
|
@ -238,5 +262,8 @@ public class SmackException extends Exception {
|
|||
*/
|
||||
private static final long serialVersionUID = 2346934138253437571L;
|
||||
|
||||
public ResourceBindingNotOfferedException() {
|
||||
super("Resource binding was not offered by server");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -29,6 +29,8 @@ import org.jivesoftware.smack.SmackException.AlreadyLoggedInException;
|
|||
import org.jivesoftware.smack.SmackException.NoResponseException;
|
||||
import org.jivesoftware.smack.SmackException.NotConnectedException;
|
||||
import org.jivesoftware.smack.SmackException.ConnectionException;
|
||||
import org.jivesoftware.smack.SmackException.SecurityRequiredByClientException;
|
||||
import org.jivesoftware.smack.SmackException.SecurityRequiredByServerException;
|
||||
import org.jivesoftware.smack.SmackException.SecurityRequiredException;
|
||||
import org.jivesoftware.smack.SynchronizationPoint;
|
||||
import org.jivesoftware.smack.XMPPException.StreamErrorException;
|
||||
|
@ -922,8 +924,7 @@ public class XMPPTCPConnection extends AbstractXMPPConnection {
|
|||
StartTls startTlsFeature = getFeature(StartTls.ELEMENT, StartTls.NAMESPACE);
|
||||
if (startTlsFeature != null) {
|
||||
if (startTlsFeature.required() && config.getSecurityMode() == SecurityMode.disabled) {
|
||||
notifyConnectionError(new SecurityRequiredException(
|
||||
"TLS required by server but not allowed by connection configuration"));
|
||||
notifyConnectionError(new SecurityRequiredByServerException());
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -938,7 +939,7 @@ public class XMPPTCPConnection extends AbstractXMPPConnection {
|
|||
// and are secure, however (features get parsed a second time after TLS is established).
|
||||
if (!isSecureConnection() && startTlsFeature == null
|
||||
&& getConfiguration().getSecurityMode() == SecurityMode.required) {
|
||||
throw new SecurityRequiredException();
|
||||
throw new SecurityRequiredByClientException();
|
||||
}
|
||||
|
||||
if (getSASLAuthentication().authenticationSuccessful()) {
|
||||
|
|
Loading…
Reference in a new issue