mirror of
https://github.com/moparisthebest/Conversations
synced 2024-11-27 19:22:15 -05:00
differentiate starttls failure and sasl failure
This commit is contained in:
parent
91db2023d3
commit
5056a28553
@ -11,4 +11,6 @@ public final class Namespace {
|
|||||||
public static final String MAM_LEGACY = "urn:xmpp:mam:0";
|
public static final String MAM_LEGACY = "urn:xmpp:mam:0";
|
||||||
public static final String IDLE = "urn:xmpp:idle:1";
|
public static final String IDLE = "urn:xmpp:idle:1";
|
||||||
public static final String OOB = "jabber:x:oob";
|
public static final String OOB = "jabber:x:oob";
|
||||||
|
public static final String SASL = "urn:ietf:params:xml:ns:xmpp-sasl";
|
||||||
|
public static final String TLS = "urn:ietf:params:xml:ns:xmpp-tls";
|
||||||
}
|
}
|
||||||
|
@ -531,21 +531,25 @@ public class XmppConnection implements Runnable {
|
|||||||
break;
|
break;
|
||||||
} else if (nextTag.isStart("failure")) {
|
} else if (nextTag.isStart("failure")) {
|
||||||
final Element failure = tagReader.readElement(nextTag);
|
final Element failure = tagReader.readElement(nextTag);
|
||||||
final String text = failure.findChildContent("text");
|
if (Namespace.SASL.equals(failure.getNamespace())) {
|
||||||
if (failure.hasChild("account-disabled")
|
final String text = failure.findChildContent("text");
|
||||||
&& text != null
|
if (failure.hasChild("account-disabled")
|
||||||
&& text.contains("renew")
|
&& text != null
|
||||||
&& Config.MAGIC_CREATE_DOMAIN != null
|
&& text.contains("renew")
|
||||||
&& text.contains(Config.MAGIC_CREATE_DOMAIN)) {
|
&& Config.MAGIC_CREATE_DOMAIN != null
|
||||||
throw new StateChangingException(Account.State.PAYMENT_REQUIRED);
|
&& text.contains(Config.MAGIC_CREATE_DOMAIN)) {
|
||||||
|
throw new StateChangingException(Account.State.PAYMENT_REQUIRED);
|
||||||
|
} else {
|
||||||
|
throw new StateChangingException(Account.State.UNAUTHORIZED);
|
||||||
|
}
|
||||||
|
} else if (Namespace.TLS.equals(failure.getNamespace())) {
|
||||||
|
throw new StateChangingException(Account.State.TLS_ERROR);
|
||||||
} else {
|
} else {
|
||||||
throw new StateChangingException(Account.State.UNAUTHORIZED);
|
throw new StateChangingException(Account.State.INCOMPATIBLE_SERVER);
|
||||||
}
|
}
|
||||||
} else if (nextTag.isStart("challenge")) {
|
} else if (nextTag.isStart("challenge")) {
|
||||||
final String challenge = tagReader.readElement(nextTag).getContent();
|
final String challenge = tagReader.readElement(nextTag).getContent();
|
||||||
final Element response = new Element("response");
|
final Element response = new Element("response",Namespace.SASL);
|
||||||
response.setAttribute("xmlns",
|
|
||||||
"urn:ietf:params:xml:ns:xmpp-sasl");
|
|
||||||
try {
|
try {
|
||||||
response.setContent(saslMechanism.getResponse(challenge));
|
response.setContent(saslMechanism.getResponse(challenge));
|
||||||
} catch (final SaslMechanism.AuthenticationException e) {
|
} catch (final SaslMechanism.AuthenticationException e) {
|
||||||
@ -781,7 +785,7 @@ public class XmppConnection implements Runnable {
|
|||||||
|
|
||||||
private void sendStartTLS() throws IOException {
|
private void sendStartTLS() throws IOException {
|
||||||
final Tag startTLS = Tag.empty("starttls");
|
final Tag startTLS = Tag.empty("starttls");
|
||||||
startTLS.setAttribute("xmlns", "urn:ietf:params:xml:ns:xmpp-tls");
|
startTLS.setAttribute("xmlns", Namespace.TLS);
|
||||||
tagWriter.writeTag(startTLS);
|
tagWriter.writeTag(startTLS);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -864,8 +868,7 @@ public class XmppConnection implements Runnable {
|
|||||||
private void authenticate() throws IOException {
|
private void authenticate() throws IOException {
|
||||||
final List<String> mechanisms = extractMechanisms(streamFeatures
|
final List<String> mechanisms = extractMechanisms(streamFeatures
|
||||||
.findChild("mechanisms"));
|
.findChild("mechanisms"));
|
||||||
final Element auth = new Element("auth");
|
final Element auth = new Element("auth",Namespace.SASL);
|
||||||
auth.setAttribute("xmlns", "urn:ietf:params:xml:ns:xmpp-sasl");
|
|
||||||
if (mechanisms.contains("EXTERNAL") && account.getPrivateKeyAlias() != null) {
|
if (mechanisms.contains("EXTERNAL") && account.getPrivateKeyAlias() != null) {
|
||||||
saslMechanism = new External(tagWriter, account, mXmppConnectionService.getRNG());
|
saslMechanism = new External(tagWriter, account, mXmppConnectionService.getRNG());
|
||||||
} else if (mechanisms.contains("SCRAM-SHA-256")) {
|
} else if (mechanisms.contains("SCRAM-SHA-256")) {
|
||||||
|
Loading…
Reference in New Issue
Block a user