use Base64.NO_WRAP instead of trim()

This commit is contained in:
Daniel Gultsch 2019-12-04 17:35:06 +01:00
parent c5ea734761
commit b3c00d7163
4 changed files with 10 additions and 14 deletions

View File

@ -158,7 +158,7 @@ public class ServiceDiscoveryResult {
}
public String getVer() {
return new String(Base64.encode(this.ver, Base64.DEFAULT)).trim();
return Base64.encodeToString(this.ver, Base64.NO_WRAP);
}
public List<Identity> getIdentities() {

View File

@ -99,8 +99,8 @@ public abstract class AbstractGenerator {
for (String feature : getFeatures(account)) {
s.append(feature).append('<');
}
byte[] sha1 = md.digest(s.toString().getBytes());
return new String(Base64.encode(sha1, Base64.DEFAULT)).trim();
final byte[] sha1 = md.digest(s.toString().getBytes());
return Base64.encodeToString(sha1, Base64.NO_WRAP);
}
public static String getTimestamp(long time) {

View File

@ -160,10 +160,6 @@ public class IqGenerator extends AbstractGenerator {
return publish("urn:xmpp:avatar:data", item, options);
}
public IqPacket publishElement(final String namespace, final Element element, final Bundle options) {
return publishElement(namespace, element, "curent", options);
}
public IqPacket publishElement(final String namespace, final Element element, String id, final Bundle options) {
final Element item = new Element("item");
item.setAttribute("id", id);
@ -263,17 +259,17 @@ public class IqGenerator extends AbstractGenerator {
final Element signedPreKeyPublic = bundle.addChild("signedPreKeyPublic");
signedPreKeyPublic.setAttribute("signedPreKeyId", signedPreKeyRecord.getId());
ECPublicKey publicKey = signedPreKeyRecord.getKeyPair().getPublicKey();
signedPreKeyPublic.setContent(Base64.encodeToString(publicKey.serialize(), Base64.DEFAULT));
signedPreKeyPublic.setContent(Base64.encodeToString(publicKey.serialize(), Base64.NO_WRAP));
final Element signedPreKeySignature = bundle.addChild("signedPreKeySignature");
signedPreKeySignature.setContent(Base64.encodeToString(signedPreKeyRecord.getSignature(), Base64.DEFAULT));
signedPreKeySignature.setContent(Base64.encodeToString(signedPreKeyRecord.getSignature(), Base64.NO_WRAP));
final Element identityKeyElement = bundle.addChild("identityKey");
identityKeyElement.setContent(Base64.encodeToString(identityKey.serialize(), Base64.DEFAULT));
identityKeyElement.setContent(Base64.encodeToString(identityKey.serialize(), Base64.NO_WRAP));
final Element prekeys = bundle.addChild("prekeys", AxolotlService.PEP_PREFIX);
for (PreKeyRecord preKeyRecord : preKeyRecords) {
final Element prekey = prekeys.addChild("preKeyPublic");
prekey.setAttribute("preKeyId", preKeyRecord.getId());
prekey.setContent(Base64.encodeToString(preKeyRecord.getKeyPair().getPublicKey().serialize(), Base64.DEFAULT));
prekey.setContent(Base64.encodeToString(preKeyRecord.getKeyPair().getPublicKey().serialize(), Base64.NO_WRAP));
}
return publish(AxolotlService.PEP_BUNDLES + ":" + deviceId, item, publishOptions);
@ -287,13 +283,13 @@ public class IqGenerator extends AbstractGenerator {
for (int i = 0; i < certificates.length; ++i) {
try {
Element certificate = chain.addChild("certificate");
certificate.setContent(Base64.encodeToString(certificates[i].getEncoded(), Base64.DEFAULT));
certificate.setContent(Base64.encodeToString(certificates[i].getEncoded(), Base64.NO_WRAP));
certificate.setAttribute("index", i);
} catch (CertificateEncodingException e) {
Log.d(Config.LOGTAG, "could not encode certificate");
}
}
verification.addChild("signature").setContent(Base64.encodeToString(signature, Base64.DEFAULT));
verification.addChild("signature").setContent(Base64.encodeToString(signature, Base64.NO_WRAP));
return publish(AxolotlService.PEP_VERIFICATION + ":" + deviceId, item);
}

View File

@ -11,7 +11,7 @@ public class CursorUtils {
if (android.os.Build.VERSION.SDK_INT >= android.os.Build.VERSION_CODES.P) {
if (cursor instanceof AbstractWindowedCursor) {
final AbstractWindowedCursor windowedCursor = (AbstractWindowedCursor) cursor;
windowedCursor.setWindow(new CursorWindow("8k", 8 * 1024 * 1024));
windowedCursor.setWindow(new CursorWindow("8M", 8 * 1024 * 1024));
}
if (cursor instanceof SQLiteCursor) {
((SQLiteCursor) cursor).setFillWindowForwardOnly(true);