aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--src/eu/siacs/conversations/ui/ConversationFragment.java1
-rw-r--r--src/eu/siacs/conversations/utils/CryptoHelper.java20
-rw-r--r--src/eu/siacs/conversations/utils/SASL.java24
-rw-r--r--src/eu/siacs/conversations/xmpp/XmppConnection.java3
4 files changed, 21 insertions, 27 deletions
diff --git a/src/eu/siacs/conversations/ui/ConversationFragment.java b/src/eu/siacs/conversations/ui/ConversationFragment.java
index 5c552b42..2c84ffed 100644
--- a/src/eu/siacs/conversations/ui/ConversationFragment.java
+++ b/src/eu/siacs/conversations/ui/ConversationFragment.java
@@ -610,7 +610,6 @@ public class ConversationFragment extends Fragment {
return false;
}
try {
- Log.d("gultsch","calling to decrypt message id #"+params[i].getUuid());
decrypted = activity.xmppConnectionService.getPgpEngine().decrypt(body);
} catch (UserInputRequiredException e) {
askForPassphraseIntent = e.getPendingIntent().getIntentSender();
diff --git a/src/eu/siacs/conversations/utils/CryptoHelper.java b/src/eu/siacs/conversations/utils/CryptoHelper.java
index 6e606fa1..ebbbd967 100644
--- a/src/eu/siacs/conversations/utils/CryptoHelper.java
+++ b/src/eu/siacs/conversations/utils/CryptoHelper.java
@@ -1,5 +1,7 @@
package eu.siacs.conversations.utils;
+import android.util.Base64;
+
public class CryptoHelper {
final protected static char[] hexArray = "0123456789ABCDEF".toCharArray();
public static String bytesToHex(byte[] bytes) {
@@ -11,4 +13,22 @@ public class CryptoHelper {
}
return new String(hexChars);
}
+ public static String saslPlain(String username, String password) {
+ byte[] userBytes = username.getBytes();
+ int userLenght = userBytes.length;
+ byte[] passwordBytes = password.getBytes();
+ byte[] saslBytes = new byte[userBytes.length+passwordBytes.length+2];
+ saslBytes[0] = 0x0;
+ for(int i = 1; i < saslBytes.length; ++i) {
+ if (i<=userLenght) {
+ saslBytes[i] = userBytes[i-1];
+ } else if (i==userLenght+1) {
+ saslBytes[i] = 0x0;
+ } else {
+ saslBytes[i] = passwordBytes[i-(userLenght+2)];
+ }
+ }
+
+ return Base64.encodeToString(saslBytes, Base64.DEFAULT);
+ }
}
diff --git a/src/eu/siacs/conversations/utils/SASL.java b/src/eu/siacs/conversations/utils/SASL.java
deleted file mode 100644
index cda1f97b..00000000
--- a/src/eu/siacs/conversations/utils/SASL.java
+++ /dev/null
@@ -1,24 +0,0 @@
-package eu.siacs.conversations.utils;
-
-import android.util.Base64;
-
-public class SASL {
- public static String plain(String username, String password) {
- byte[] userBytes = username.getBytes();
- int userLenght = userBytes.length;
- byte[] passwordBytes = password.getBytes();
- byte[] saslBytes = new byte[userBytes.length+passwordBytes.length+2];
- saslBytes[0] = 0x0;
- for(int i = 1; i < saslBytes.length; ++i) {
- if (i<=userLenght) {
- saslBytes[i] = userBytes[i-1];
- } else if (i==userLenght+1) {
- saslBytes[i] = 0x0;
- } else {
- saslBytes[i] = passwordBytes[i-(userLenght+2)];
- }
- }
-
- return Base64.encodeToString(saslBytes, Base64.DEFAULT);
- }
-}
diff --git a/src/eu/siacs/conversations/xmpp/XmppConnection.java b/src/eu/siacs/conversations/xmpp/XmppConnection.java
index 6e236210..53f9b85a 100644
--- a/src/eu/siacs/conversations/xmpp/XmppConnection.java
+++ b/src/eu/siacs/conversations/xmpp/XmppConnection.java
@@ -34,7 +34,6 @@ import android.util.Log;
import eu.siacs.conversations.entities.Account;
import eu.siacs.conversations.utils.CryptoHelper;
import eu.siacs.conversations.utils.DNSHelper;
-import eu.siacs.conversations.utils.SASL;
import eu.siacs.conversations.xml.Element;
import eu.siacs.conversations.xml.Tag;
import eu.siacs.conversations.xml.TagWriter;
@@ -361,7 +360,7 @@ public class XmppConnection implements Runnable {
}
private void sendSaslAuth() throws IOException, XmlPullParserException {
- String saslString = SASL.plain(account.getUsername(),
+ String saslString = CryptoHelper.saslPlain(account.getUsername(),
account.getPassword());
Element auth = new Element("auth");
auth.setAttribute("xmlns", "urn:ietf:params:xml:ns:xmpp-sasl");