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() { 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() { public List<Identity> getIdentities() {

View file

@ -99,8 +99,8 @@ public abstract class AbstractGenerator {
for (String feature : getFeatures(account)) { for (String feature : getFeatures(account)) {
s.append(feature).append('<'); s.append(feature).append('<');
} }
byte[] sha1 = md.digest(s.toString().getBytes()); final byte[] sha1 = md.digest(s.toString().getBytes());
return new String(Base64.encode(sha1, Base64.DEFAULT)).trim(); return Base64.encodeToString(sha1, Base64.NO_WRAP);
} }
public static String getTimestamp(long time) { 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); 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) { public IqPacket publishElement(final String namespace, final Element element, String id, final Bundle options) {
final Element item = new Element("item"); final Element item = new Element("item");
item.setAttribute("id", id); item.setAttribute("id", id);
@ -263,17 +259,17 @@ public class IqGenerator extends AbstractGenerator {
final Element signedPreKeyPublic = bundle.addChild("signedPreKeyPublic"); final Element signedPreKeyPublic = bundle.addChild("signedPreKeyPublic");
signedPreKeyPublic.setAttribute("signedPreKeyId", signedPreKeyRecord.getId()); signedPreKeyPublic.setAttribute("signedPreKeyId", signedPreKeyRecord.getId());
ECPublicKey publicKey = signedPreKeyRecord.getKeyPair().getPublicKey(); 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"); 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"); 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); final Element prekeys = bundle.addChild("prekeys", AxolotlService.PEP_PREFIX);
for (PreKeyRecord preKeyRecord : preKeyRecords) { for (PreKeyRecord preKeyRecord : preKeyRecords) {
final Element prekey = prekeys.addChild("preKeyPublic"); final Element prekey = prekeys.addChild("preKeyPublic");
prekey.setAttribute("preKeyId", preKeyRecord.getId()); 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); 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) { for (int i = 0; i < certificates.length; ++i) {
try { try {
Element certificate = chain.addChild("certificate"); 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); certificate.setAttribute("index", i);
} catch (CertificateEncodingException e) { } catch (CertificateEncodingException e) {
Log.d(Config.LOGTAG, "could not encode certificate"); 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); 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 (android.os.Build.VERSION.SDK_INT >= android.os.Build.VERSION_CODES.P) {
if (cursor instanceof AbstractWindowedCursor) { if (cursor instanceof AbstractWindowedCursor) {
final AbstractWindowedCursor windowedCursor = (AbstractWindowedCursor) cursor; 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) { if (cursor instanceof SQLiteCursor) {
((SQLiteCursor) cursor).setFillWindowForwardOnly(true); ((SQLiteCursor) cursor).setFillWindowForwardOnly(true);