From 6c5c3ac2decac75ec3208d47912e67c4e1a33548 Mon Sep 17 00:00:00 2001 From: Daniel Gultsch Date: Thu, 30 Jan 2014 16:42:35 +0100 Subject: first draft on xml parser and communication. a long way to go. code definitly not perfect. will refactor asap --- src/de/gultsch/chat/utils/SASL.java | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) create mode 100644 src/de/gultsch/chat/utils/SASL.java (limited to 'src/de/gultsch/chat/utils') diff --git a/src/de/gultsch/chat/utils/SASL.java b/src/de/gultsch/chat/utils/SASL.java new file mode 100644 index 00000000..266f0cb2 --- /dev/null +++ b/src/de/gultsch/chat/utils/SASL.java @@ -0,0 +1,24 @@ +package de.gultsch.chat.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); + } +} -- cgit v1.2.3