diff options
author | Daniel Gultsch <daniel.gultsch@rwth-aachen.de> | 2014-01-30 16:42:35 +0100 |
---|---|---|
committer | Daniel Gultsch <daniel.gultsch@rwth-aachen.de> | 2014-01-30 16:42:35 +0100 |
commit | 6c5c3ac2decac75ec3208d47912e67c4e1a33548 (patch) | |
tree | c6cdcc5d76608369da08eb76891c48ffefbb9a48 /src/de/gultsch/chat/utils/SASL.java | |
parent | ad11dab6359a1eb2b6921d36117093066999fb96 (diff) |
first draft on xml parser and communication. a long way to go. code definitly not perfect. will refactor asap
Diffstat (limited to 'src/de/gultsch/chat/utils/SASL.java')
-rw-r--r-- | src/de/gultsch/chat/utils/SASL.java | 24 |
1 files changed, 24 insertions, 0 deletions
diff --git a/src/de/gultsch/chat/utils/SASL.java b/src/de/gultsch/chat/utils/SASL.java new file mode 100644 index 000000000..266f0cb29 --- /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); + } +} |