diff options
author | Daniel Gultsch <daniel@gultsch.de> | 2016-07-25 15:57:47 +0200 |
---|---|---|
committer | Christian Schneppe <christian@pix-art.de> | 2016-07-25 19:50:40 +0200 |
commit | 5cf5195e266b60bd3721116d012c463b681c62f5 (patch) | |
tree | 7c0e9ed5e09e47de438bf06a80f77d4acc8d2248 /src/main/java/eu/siacs/conversations/xmpp | |
parent | e388c64361a3dad44442dd1f8633e452302188e8 (diff) |
display specific error message when password is too weak on registration
Diffstat (limited to '')
-rw-r--r-- | src/main/java/eu/siacs/conversations/xmpp/XmppConnection.java | 29 |
1 files changed, 17 insertions, 12 deletions
diff --git a/src/main/java/eu/siacs/conversations/xmpp/XmppConnection.java b/src/main/java/eu/siacs/conversations/xmpp/XmppConnection.java index a4476c052..fec96969b 100644 --- a/src/main/java/eu/siacs/conversations/xmpp/XmppConnection.java +++ b/src/main/java/eu/siacs/conversations/xmpp/XmppConnection.java @@ -34,6 +34,7 @@ import java.security.Principal; import java.security.PrivateKey; import java.security.cert.X509Certificate; import java.util.ArrayList; +import java.util.Arrays; import java.util.HashMap; import java.util.Hashtable; import java.util.Iterator; @@ -183,20 +184,24 @@ public class XmppConnection implements Runnable { forceCloseSocket(); changeStatus(Account.State.REGISTRATION_SUCCESSFUL); } else { + final List<String> PASSWORD_TOO_WEAK_MSGS = Arrays.asList( + "The password is too weak", + "Please use a longer password."); Element error = packet.findChild("error"); - if (error != null && error.hasChild("conflict")) { - forceCloseSocket(); - changeStatus(Account.State.REGISTRATION_CONFLICT); - } else if (error != null - && "wait".equals(error.getAttribute("type")) - && error.hasChild("resource-constraint")) { - forceCloseSocket(); - changeStatus(Account.State.REGISTRATION_PLEASE_WAIT); - } else { - forceCloseSocket(); - changeStatus(Account.State.REGISTRATION_FAILED); - Log.d(Config.LOGTAG, packet.toString()); + Account.State state = Account.State.REGISTRATION_FAILED; + if (error != null) { + if (error.hasChild("conflict")) { + state = Account.State.REGISTRATION_CONFLICT; + } else if (error.hasChild("resource-constraint") + && "wait".equals(error.getAttribute("type"))) { + state = Account.State.REGISTRATION_PLEASE_WAIT; + } else if (error.hasChild("not-acceptable") + && PASSWORD_TOO_WEAK_MSGS.contains(error.findChildContent("text"))) { + state = Account.State.REGISTRATION_PASSWORD_TOO_WEAK; + } } + changeStatus(state); + forceCloseSocket(); } } }; |