blob: 8deb9b8860f966fe9893d5b147072a56d227a75a (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
|
/*
* Copyright (c) 2010, Isode Limited, London, England.
* All rights reserved.
*/
/*
* Copyright (c) 2010, Remko Tronçon.
* All rights reserved.
*/
package com.isode.stroke.serializer;
import com.isode.stroke.base.ByteArray;
import com.isode.stroke.elements.AuthResponse;
import com.isode.stroke.elements.Element;
import com.isode.stroke.stringcodecs.Base64;
class AuthResponseSerializer extends GenericElementSerializer<AuthResponse> {
public AuthResponseSerializer() {
super(AuthResponse.class);
}
public String serialize(Element element) {
AuthResponse authResponse = (AuthResponse) element;
String value = "";
ByteArray message = authResponse.getValue();
if (message != null) {
if (message.isEmpty()) {
value = "=";
} else {
value = Base64.encode(message);
}
}
return "<response xmlns=\"urn:ietf:params:xml:ns:xmpp-sasl\">" + value + "</response>";
}
}
|