aboutsummaryrefslogtreecommitdiffstats
path: root/src/main/java/de/pixart/messenger/generator
diff options
context:
space:
mode:
authorChristian Schneppe <christian@pix-art.de>2018-06-17 00:13:34 +0200
committerChristian Schneppe <christian@pix-art.de>2018-06-17 00:13:34 +0200
commit0d297def28a9e1e848a0020ae140f304957114ca (patch)
treee5efecc425c64769aaae2babc34cff274cf78069 /src/main/java/de/pixart/messenger/generator
parent483ca6466febf2a7a19c18ec4b934f2b2b6f3226 (diff)
use Tor on http upload is account uses onion domain
Diffstat (limited to 'src/main/java/de/pixart/messenger/generator')
-rw-r--r--src/main/java/de/pixart/messenger/generator/AbstractGenerator.java17
-rw-r--r--src/main/java/de/pixart/messenger/generator/IqGenerator.java6
-rw-r--r--src/main/java/de/pixart/messenger/generator/PresenceGenerator.java4
3 files changed, 14 insertions, 13 deletions
diff --git a/src/main/java/de/pixart/messenger/generator/AbstractGenerator.java b/src/main/java/de/pixart/messenger/generator/AbstractGenerator.java
index a87a37885..37a098300 100644
--- a/src/main/java/de/pixart/messenger/generator/AbstractGenerator.java
+++ b/src/main/java/de/pixart/messenger/generator/AbstractGenerator.java
@@ -15,6 +15,7 @@ import java.util.TimeZone;
import de.pixart.messenger.Config;
import de.pixart.messenger.R;
import de.pixart.messenger.crypto.axolotl.AxolotlService;
+import de.pixart.messenger.entities.Account;
import de.pixart.messenger.services.XmppConnectionService;
import de.pixart.messenger.utils.Namespace;
import de.pixart.messenger.utils.PhoneHelper;
@@ -73,7 +74,7 @@ public abstract class AbstractGenerator {
return mXmppConnectionService.getString(R.string.app_name) + " " + getIdentityVersion();
}
- public String getIdentityType() {
+ String getIdentityType() {
if ("chromium".equals(android.os.Build.BRAND)) {
return "pc";
} else {
@@ -81,9 +82,9 @@ public abstract class AbstractGenerator {
}
}
- public String getCapHash() {
+ String getCapHash(final Account account) {
StringBuilder s = new StringBuilder();
- s.append("client/" + getIdentityType() + "//" + getIdentityName() + "<");
+ s.append("client/").append(getIdentityType()).append("//").append(getIdentityName()).append('<');
MessageDigest md;
try {
md = MessageDigest.getInstance("SHA-1");
@@ -91,8 +92,8 @@ public abstract class AbstractGenerator {
return null;
}
- for (String feature : getFeatures()) {
- s.append(feature + "<");
+ 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();
@@ -103,8 +104,8 @@ public abstract class AbstractGenerator {
return DATE_FORMAT.format(time);
}
- public List<String> getFeatures() {
- ArrayList<String> features = new ArrayList<>();
+ public List<String> getFeatures(Account account) {
+ ArrayList<String> features = new ArrayList<>(Arrays.asList(FEATURES));
features.addAll(Arrays.asList(FEATURES));
if (mXmppConnectionService.confirmMessages()) {
features.addAll(Arrays.asList(MESSAGE_CONFIRMATION_FEATURES));
@@ -115,7 +116,7 @@ public abstract class AbstractGenerator {
if (Config.supportOmemo()) {
features.add(AxolotlService.PEP_DEVICE_LIST_NOTIFY);
}
- if (!mXmppConnectionService.useTorToConnect()) {
+ if (!mXmppConnectionService.useTorToConnect() && !account.isOnion()) {
features.addAll(Arrays.asList(PRIVACY_SENSITIVE));
}
if (Config.supportOtr()) {
diff --git a/src/main/java/de/pixart/messenger/generator/IqGenerator.java b/src/main/java/de/pixart/messenger/generator/IqGenerator.java
index 159e730f3..eab087975 100644
--- a/src/main/java/de/pixart/messenger/generator/IqGenerator.java
+++ b/src/main/java/de/pixart/messenger/generator/IqGenerator.java
@@ -41,7 +41,7 @@ public class IqGenerator extends AbstractGenerator {
super(service);
}
- public IqPacket discoResponse(final IqPacket request) {
+ public IqPacket discoResponse(final Account account, final IqPacket request) {
final IqPacket packet = new IqPacket(IqPacket.TYPE.RESULT);
packet.setId(request.getId());
packet.setTo(request.getFrom());
@@ -51,7 +51,7 @@ public class IqGenerator extends AbstractGenerator {
identity.setAttribute("category", "client");
identity.setAttribute("type", getIdentityType());
identity.setAttribute("name", getIdentityName());
- for (final String feature : getFeatures()) {
+ for (final String feature : getFeatures(account)) {
query.addChild("feature").setAttribute("var", feature);
}
return packet;
@@ -113,7 +113,7 @@ public class IqGenerator extends AbstractGenerator {
return publish(node, item, null);
}
- protected IqPacket retrieve(String node, Element item) {
+ private IqPacket retrieve(String node, Element item) {
final IqPacket packet = new IqPacket(IqPacket.TYPE.GET);
final Element pubsub = packet.addChild("pubsub", Namespace.PUBSUB);
final Element items = pubsub.addChild("items");
diff --git a/src/main/java/de/pixart/messenger/generator/PresenceGenerator.java b/src/main/java/de/pixart/messenger/generator/PresenceGenerator.java
index b66f6b184..95221ce31 100644
--- a/src/main/java/de/pixart/messenger/generator/PresenceGenerator.java
+++ b/src/main/java/de/pixart/messenger/generator/PresenceGenerator.java
@@ -48,11 +48,11 @@ public class PresenceGenerator extends AbstractGenerator {
packet.addChild("show").setContent(status.toShowString());
}
packet.setFrom(account.getJid());
- String sig = account.getPgpSignature();
+ final String sig = account.getPgpSignature();
if (includePgpAnnouncement && sig != null && mXmppConnectionService.getPgpEngine() != null) {
packet.addChild("x", "jabber:x:signed").setContent(sig);
}
- String capHash = getCapHash();
+ final String capHash = getCapHash(account);
if (capHash != null) {
Element cap = packet.addChild("c",
"http://jabber.org/protocol/caps");