aboutsummaryrefslogtreecommitdiffstats
path: root/src/main/java/de/pixart/messenger/services
diff options
context:
space:
mode:
authorChristian Schneppe <christian@pix-art.de>2017-03-04 12:23:44 +0100
committerChristian Schneppe <christian@pix-art.de>2017-03-04 12:23:44 +0100
commitcda645677635758cc0f884151bf0a21b2327f044 (patch)
treead319a55ffbe50a7892032dff7c897f3bf185d1e /src/main/java/de/pixart/messenger/services
parent51b436fbf05374c08ecd696437600d36d306c21b (diff)
make x509 verification node world readable
Diffstat (limited to 'src/main/java/de/pixart/messenger/services')
-rw-r--r--src/main/java/de/pixart/messenger/services/XmppConnectionService.java49
1 files changed, 38 insertions, 11 deletions
diff --git a/src/main/java/de/pixart/messenger/services/XmppConnectionService.java b/src/main/java/de/pixart/messenger/services/XmppConnectionService.java
index 3fa4f9d4c..931ccf06e 100644
--- a/src/main/java/de/pixart/messenger/services/XmppConnectionService.java
+++ b/src/main/java/de/pixart/messenger/services/XmppConnectionService.java
@@ -1906,9 +1906,10 @@ public class XmppConnectionService extends Service {
}
public void updateKeyInAccount(final Account account, final String alias) {
- Log.d(Config.LOGTAG, "update key in account " + alias);
+ Log.d(Config.LOGTAG, account.getJid().toBareJid() + ": update key in account " + alias);
try {
X509Certificate[] chain = KeyChain.getCertificateChain(XmppConnectionService.this, alias);
+ Log.d(Config.LOGTAG, account.getJid().toBareJid() + " loaded certificate chain");
Pair<Jid, String> info = CryptoHelper.extractJidAndName(chain[0]);
if (account.getJid().toBareJid().equals(info.first)) {
account.setPrivateKeyAlias(alias);
@@ -1916,7 +1917,7 @@ public class XmppConnectionService extends Service {
databaseBackend.updateAccount(account);
if (Config.X509_VERIFICATION) {
try {
- getMemorizingTrustManager().getNonInteractive(account.getJid().getDomainpart()).checkClientTrusted(chain, "RSA");
+ getMemorizingTrustManager().getNonInteractive().checkClientTrusted(chain, "RSA");
} catch (CertificateException e) {
showErrorToastInUi(R.string.certificate_chain_is_not_trusted);
}
@@ -2529,7 +2530,7 @@ public class XmppConnectionService extends Service {
joinMuc(conversation, new OnConferenceJoined() {
@Override
public void onConferenceJoined(final Conversation conversation) {
- pushConferenceConfiguration(conversation, IqGenerator.defaultRoomConfiguration(), new OnConferenceOptionsPushed() {
+ pushConferenceConfiguration(conversation, IqGenerator.defaultRoomConfiguration(), new OnConfigurationPushed() {
@Override
public void onPushSucceeded() {
if (subject != null && !subject.trim().isEmpty()) {
@@ -2613,7 +2614,38 @@ public class XmppConnectionService extends Service {
});
}
- public void pushConferenceConfiguration(final Conversation conversation, final Bundle options, final OnConferenceOptionsPushed callback) {
+ public void pushNodeConfiguration(Account account, final Jid jid, final String node, final Bundle options, final OnConfigurationPushed callback) {
+ sendIqPacket(account, mIqGenerator.requestPubsubConfiguration(jid, node), new OnIqPacketReceived() {
+ @Override
+ public void onIqPacketReceived(Account account, IqPacket packet) {
+ if (packet.getType() == IqPacket.TYPE.RESULT) {
+ Element pubsub = packet.findChild("pubsub", "http://jabber.org/protocol/pubsub#owner");
+ Element configuration = pubsub == null ? null : pubsub.findChild("configure");
+ Element x = configuration == null ? null : configuration.findChild("x", "jabber:x:data");
+ if (x != null) {
+ Data data = Data.parse(x);
+ data.submit(options);
+ sendIqPacket(account, mIqGenerator.publishPubsubConfiguration(jid, node, data), new OnIqPacketReceived() {
+ @Override
+ public void onIqPacketReceived(Account account, IqPacket packet) {
+ if (packet.getType() == IqPacket.TYPE.RESULT) {
+ callback.onPushSucceeded();
+ } else {
+ Log.d(Config.LOGTAG, packet.toString());
+ }
+ }
+ });
+ } else {
+ callback.onPushFailed();
+ }
+ } else {
+ callback.onPushFailed();
+ }
+ }
+ });
+ }
+
+ public void pushConferenceConfiguration(final Conversation conversation, final Bundle options, final OnConfigurationPushed callback) {
IqPacket request = new IqPacket(IqPacket.TYPE.GET);
request.setTo(conversation.getJid().toBareJid());
request.query("http://jabber.org/protocol/muc#owner");
@@ -2622,12 +2654,7 @@ public class XmppConnectionService extends Service {
public void onIqPacketReceived(Account account, IqPacket packet) {
if (packet.getType() == IqPacket.TYPE.RESULT) {
Data data = Data.parse(packet.query().findChild("x", "jabber:x:data"));
- for (Field field : data.getFields()) {
- if (options.containsKey(field.getFieldName())) {
- field.setValue(options.getString(field.getFieldName()));
- }
- }
- data.submit();
+ data.submit(options);
IqPacket set = new IqPacket(IqPacket.TYPE.SET);
set.setTo(conversation.getJid().toBareJid());
set.query("http://jabber.org/protocol/muc#owner").addChild(data);
@@ -4045,7 +4072,7 @@ public class XmppConnectionService extends Service {
void onConferenceJoined(Conversation conversation);
}
- public interface OnConferenceOptionsPushed {
+ public interface OnConfigurationPushed {
void onPushSucceeded();
void onPushFailed();