mirror of
https://github.com/vanitasvitae/Smack.git
synced 2025-12-14 15:01:07 +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:
parent
90c0064394
commit
5d4aa76d19
32 changed files with 491 additions and 231 deletions
|
|
@ -35,8 +35,8 @@ import org.jivesoftware.smack.filter.PacketFilter;
|
|||
import org.jivesoftware.smack.filter.AndFilter;
|
||||
import org.jivesoftware.smack.filter.PacketTypeFilter;
|
||||
import org.jivesoftware.smack.filter.PacketExtensionFilter;
|
||||
import org.jivesoftware.smack.util.Base64;
|
||||
import org.jivesoftware.smack.util.Cache;
|
||||
import org.jivesoftware.smack.util.stringencoder.Base64;
|
||||
import org.jivesoftware.smackx.caps.cache.EntityCapsPersistentCache;
|
||||
import org.jivesoftware.smackx.caps.packet.CapsExtension;
|
||||
import org.jivesoftware.smackx.disco.NodeInformationProvider;
|
||||
|
|
@ -663,7 +663,7 @@ public class EntityCapsManager extends Manager {
|
|||
// (note: the Base64 output MUST NOT include whitespace and MUST set
|
||||
// padding bits to zero).
|
||||
byte[] digest = md.digest(sb.toString().getBytes());
|
||||
return Base64.encodeBytes(digest);
|
||||
return Base64.encodeToString(digest);
|
||||
}
|
||||
|
||||
private static void formFieldValuesToCaps(List<String> i, StringBuilder sb) {
|
||||
|
|
|
|||
|
|
@ -25,9 +25,9 @@ import java.io.IOException;
|
|||
import java.util.logging.Level;
|
||||
import java.util.logging.Logger;
|
||||
|
||||
import org.jivesoftware.smack.util.Base32Encoder;
|
||||
import org.jivesoftware.smack.util.PacketParserUtils;
|
||||
import org.jivesoftware.smack.util.StringEncoder;
|
||||
import org.jivesoftware.smack.util.stringencoder.Base32;
|
||||
import org.jivesoftware.smack.util.stringencoder.StringEncoder;
|
||||
import org.jivesoftware.smackx.disco.packet.DiscoverInfo;
|
||||
|
||||
/**
|
||||
|
|
@ -48,14 +48,14 @@ public class SimpleDirectoryPersistentCache implements EntityCapsPersistentCache
|
|||
* Creates a new SimpleDirectoryPersistentCache Object. Make sure that the
|
||||
* cacheDir exists and that it's an directory.
|
||||
* <p>
|
||||
* Default filename encoder {@link Base32Encoder}, as this will work on all
|
||||
* Default filename encoder {@link Base32}, as this will work on all
|
||||
* file systems, both case sensitive and case insensitive. It does however
|
||||
* produce longer filenames.
|
||||
*
|
||||
* @param cacheDir
|
||||
*/
|
||||
public SimpleDirectoryPersistentCache(File cacheDir) {
|
||||
this(cacheDir, Base32Encoder.getInstance());
|
||||
this(cacheDir, Base32.getStringEncoder());
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -63,7 +63,7 @@ public class SimpleDirectoryPersistentCache implements EntityCapsPersistentCache
|
|||
* cacheDir exists and that it's an directory.
|
||||
*
|
||||
* If your cacheDir is case insensitive then make sure to set the
|
||||
* StringEncoder to {@link Base32Encoder} (which is the default).
|
||||
* StringEncoder to {@link Base32} (which is the default).
|
||||
*
|
||||
* @param cacheDir The directory where the cache will be stored.
|
||||
* @param filenameEncoder Encodes the node string into a filename.
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue