From 6c2684b8585a9401eff369dfcc41a7f7d5c3e168 Mon Sep 17 00:00:00 2001 From: Sam Whited Date: Sun, 7 Aug 2016 09:46:01 -0500 Subject: Support ANONYMOUS SASL --- .../de/pixart/messenger/crypto/sasl/Anonymous.java | 28 ++++++++++++++++++++++ .../de/pixart/messenger/xmpp/XmppConnection.java | 3 +++ 2 files changed, 31 insertions(+) create mode 100644 src/main/java/de/pixart/messenger/crypto/sasl/Anonymous.java (limited to 'src/main/java/de') diff --git a/src/main/java/de/pixart/messenger/crypto/sasl/Anonymous.java b/src/main/java/de/pixart/messenger/crypto/sasl/Anonymous.java new file mode 100644 index 000000000..7e4e98bc6 --- /dev/null +++ b/src/main/java/de/pixart/messenger/crypto/sasl/Anonymous.java @@ -0,0 +1,28 @@ +package de.pixart.messenger.crypto.sasl; + +import java.security.SecureRandom; + +import de.pixart.messenger.entities.Account; +import de.pixart.messenger.xml.TagWriter; + +public class Anonymous extends SaslMechanism { + + public Anonymous(TagWriter tagWriter, Account account, SecureRandom rng) { + super(tagWriter, account, rng); + } + + @Override + public int getPriority() { + return 0; + } + + @Override + public String getMechanism() { + return "ANONYMOUS"; + } + + @Override + public String getClientFirstMessage() { + return ""; + } +} diff --git a/src/main/java/de/pixart/messenger/xmpp/XmppConnection.java b/src/main/java/de/pixart/messenger/xmpp/XmppConnection.java index 85f2718ba..784289975 100644 --- a/src/main/java/de/pixart/messenger/xmpp/XmppConnection.java +++ b/src/main/java/de/pixart/messenger/xmpp/XmppConnection.java @@ -56,6 +56,7 @@ import javax.net.ssl.X509TrustManager; import de.duenndns.ssl.MemorizingTrustManager; import de.pixart.messenger.Config; import de.pixart.messenger.crypto.XmppDomainVerifier; +import de.pixart.messenger.crypto.sasl.Anonymous; import de.pixart.messenger.crypto.sasl.DigestMd5; import de.pixart.messenger.crypto.sasl.External; import de.pixart.messenger.crypto.sasl.Plain; @@ -854,6 +855,8 @@ public class XmppConnection implements Runnable { saslMechanism = new Plain(tagWriter, account); } else if (mechanisms.contains("DIGEST-MD5")) { saslMechanism = new DigestMd5(tagWriter, account, mXmppConnectionService.getRNG()); + } else if (mechanisms.contains("ANONYMOUS")) { + saslMechanism = new Anonymous(tagWriter, account, mXmppConnectionService.getRNG()); } if (saslMechanism != null) { final JSONObject keys = account.getKeys(); -- cgit v1.2.3