1
0
Fork 0
mirror of https://github.com/vanitasvitae/Smack.git synced 2025-12-12 14:01:08 +01:00

Create smack.util.stringencoder for Base64, Base32,…

Use Android's Base64 implementation when on Android, otherwise, when on
Java7, use the existing one.
This commit is contained in:
Florian Schmaus 2014-09-04 11:04:51 +02:00
parent 90c0064394
commit 5d4aa76d19
32 changed files with 491 additions and 231 deletions

View file

@ -28,8 +28,8 @@ import java.util.logging.Level;
import java.util.logging.Logger;
import org.jivesoftware.smack.packet.PacketExtension;
import org.jivesoftware.smack.util.StringUtils;
import org.jivesoftware.smack.util.XmlStringBuilder;
import org.jivesoftware.smack.util.stringencoder.Base64;
/**
* Properties provide an easy mechanism for clients to share data. Each property has a
@ -182,7 +182,7 @@ public class JivePropertiesExtension implements PacketExtension {
out = new ObjectOutputStream(byteStream);
out.writeObject(value);
type = "java-object";
valueStr = StringUtils.encodeBase64(byteStream.toByteArray());
valueStr = Base64.encodeToString(byteStream.toByteArray());
}
catch (Exception e) {
LOGGER.log(Level.SEVERE, "Error encoding java object", e);

View file

@ -25,7 +25,7 @@ import java.util.logging.Logger;
import org.jivesoftware.smack.packet.PacketExtension;
import org.jivesoftware.smack.provider.PacketExtensionProvider;
import org.jivesoftware.smack.util.StringUtils;
import org.jivesoftware.smack.util.stringencoder.Base64;
import org.jivesoftware.smackx.jiveproperties.JivePropertiesManager;
import org.jivesoftware.smackx.jiveproperties.packet.JivePropertiesExtension;
import org.xmlpull.v1.XmlPullParser;
@ -94,7 +94,7 @@ public class JivePropertiesExtensionProvider implements PacketExtensionProvider
else if ("java-object".equals(type)) {
if (JivePropertiesManager.isJavaObjectEnabled()) {
try {
byte[] bytes = StringUtils.decodeBase64(valueText);
byte[] bytes = Base64.decode(valueText);
ObjectInputStream in = new ObjectInputStream(
new ByteArrayInputStream(bytes));
value = in.readObject();