aboutsummaryrefslogtreecommitdiffstats
path: root/src/main/java/de/thedevstack/conversationsplus/crypto
diff options
context:
space:
mode:
authorsteckbrief <steckbrief@chefmail.de>2018-05-11 19:49:27 +0200
committersteckbrief <steckbrief@chefmail.de>2018-05-11 19:49:27 +0200
commitbff97731deed4c599dcb6c3a2887c9f47165dd3f (patch)
tree1a1479be225fef127146f58d69f32a947c4d013e /src/main/java/de/thedevstack/conversationsplus/crypto
parent1d8c547b447d68daf079d9db2b1d792fc631e462 (diff)
introduces JidUtil for Jid creation, fixes duplication of childs while adding childs with xmlns and name
Diffstat (limited to 'src/main/java/de/thedevstack/conversationsplus/crypto')
-rw-r--r--src/main/java/de/thedevstack/conversationsplus/crypto/OtrService.java11
-rw-r--r--src/main/java/de/thedevstack/conversationsplus/crypto/axolotl/AxolotlServiceImpl.java9
2 files changed, 11 insertions, 9 deletions
diff --git a/src/main/java/de/thedevstack/conversationsplus/crypto/OtrService.java b/src/main/java/de/thedevstack/conversationsplus/crypto/OtrService.java
index 34023d9f..56ee4dbc 100644
--- a/src/main/java/de/thedevstack/conversationsplus/crypto/OtrService.java
+++ b/src/main/java/de/thedevstack/conversationsplus/crypto/OtrService.java
@@ -35,6 +35,7 @@ import de.thedevstack.conversationsplus.xmpp.chatstate.ChatState;
import de.thedevstack.conversationsplus.xmpp.jid.InvalidJidException;
import de.thedevstack.conversationsplus.xmpp.jid.Jid;
import de.thedevstack.conversationsplus.xmpp.stanzas.MessagePacket;
+import de.thedevstack.conversationsplus.xmpp.jid.JidUtil;
public class OtrService extends OtrCryptoEngineImpl implements OtrEngineHost {
@@ -102,7 +103,7 @@ public class OtrService extends OtrCryptoEngineImpl implements OtrEngineHost {
@Override
public void askForSecret(SessionID id, InstanceTag instanceTag, String question) {
try {
- final Jid jid = Jid.fromSessionID(id);
+ final Jid jid = JidUtil.fromSessionID(id);
Conversation conversation = this.mXmppConnectionService.find(this.account,jid);
if (conversation!=null) {
conversation.smp().hint = question;
@@ -182,7 +183,7 @@ public class OtrService extends OtrCryptoEngineImpl implements OtrEngineHost {
packet.setBody(body);
MessageGenerator.addMessageHints(packet);
try {
- Jid jid = Jid.fromSessionID(session);
+ Jid jid = JidUtil.fromSessionID(session);
Conversation conversation = mXmppConnectionService.find(account,jid);
if (conversation != null && conversation.setOutgoingChatState(Config.DEFAULT_CHATSTATE)) {
if (ConversationsPlusPreferences.chatStates()) {
@@ -227,7 +228,7 @@ public class OtrService extends OtrCryptoEngineImpl implements OtrEngineHost {
private void setSmpStatus(SessionID id, int status) {
try {
- final Jid jid = Jid.fromSessionID(id);
+ final Jid jid = JidUtil.fromSessionID(id);
Conversation conversation = this.mXmppConnectionService.find(this.account,jid);
if (conversation!=null) {
conversation.smp().status = status;
@@ -259,7 +260,7 @@ public class OtrService extends OtrCryptoEngineImpl implements OtrEngineHost {
public void sendOtrErrorMessage(SessionID session, String errorText) {
try {
- Jid jid = Jid.fromSessionID(session);
+ Jid jid = JidUtil.fromSessionID(session);
Conversation conversation = mXmppConnectionService.find(account, jid);
String id = conversation == null ? null : conversation.getLastReceivedOtrMessageId();
if (id != null) {
@@ -285,7 +286,7 @@ public class OtrService extends OtrCryptoEngineImpl implements OtrEngineHost {
public void verify(SessionID id, String fingerprint, boolean approved) {
Logging.d(Config.LOGTAG,"OtrService.verify("+id.toString()+","+fingerprint+","+String.valueOf(approved)+")");
try {
- final Jid jid = Jid.fromSessionID(id);
+ final Jid jid = JidUtil.fromSessionID(id);
Conversation conversation = this.mXmppConnectionService.find(this.account,jid);
if (conversation!=null) {
if (approved) {
diff --git a/src/main/java/de/thedevstack/conversationsplus/crypto/axolotl/AxolotlServiceImpl.java b/src/main/java/de/thedevstack/conversationsplus/crypto/axolotl/AxolotlServiceImpl.java
index 3569a7a5..cdf78761 100644
--- a/src/main/java/de/thedevstack/conversationsplus/crypto/axolotl/AxolotlServiceImpl.java
+++ b/src/main/java/de/thedevstack/conversationsplus/crypto/axolotl/AxolotlServiceImpl.java
@@ -52,6 +52,7 @@ import de.thedevstack.conversationsplus.xmpp.jid.InvalidJidException;
import de.thedevstack.conversationsplus.xmpp.jid.Jid;
import de.thedevstack.conversationsplus.xmpp.stanzas.IqPacket;
import de.thedevstack.conversationsplus.xmpp.stanzas.IqPacketReceiver;
+import de.thedevstack.conversationsplus.xmpp.jid.JidUtil;
public class AxolotlServiceImpl implements OnAdvancedStreamFeaturesLoaded, AxolotlService {
@@ -166,7 +167,7 @@ public class AxolotlServiceImpl implements OnAdvancedStreamFeaturesLoaded, Axolo
Bundle information = CryptoHelper.extractCertificateInformation(certificate);
try {
final String cn = information.getString("subject_cn");
- final Jid jid = Jid.fromString(bareJid);
+ final Jid jid = JidUtil.fromString(bareJid);
Log.d(Config.LOGTAG,"setting common name for "+jid+" to "+cn);
account.getRoster().getContact(jid).setCommonName(cn);
} catch (final InvalidJidException ignored) {
@@ -660,7 +661,7 @@ public class AxolotlServiceImpl implements OnAdvancedStreamFeaturesLoaded, Axolo
final AxolotlAddress address = session.getRemoteAddress();
final IdentityKey identityKey = session.getIdentityKey();
try {
- IqPacket packet = mXmppConnectionService.getIqGenerator().retrieveVerificationForDevice(Jid.fromString(address.getName()), address.getDeviceId());
+ IqPacket packet = mXmppConnectionService.getIqGenerator().retrieveVerificationForDevice(JidUtil.fromString(address.getName()), address.getDeviceId());
mXmppConnectionService.sendIqPacket(account, packet, new OnIqPacketReceived() {
@Override
public void onIqPacketReceived(Account account, IqPacket packet) {
@@ -681,7 +682,7 @@ public class AxolotlServiceImpl implements OnAdvancedStreamFeaturesLoaded, Axolo
Bundle information = CryptoHelper.extractCertificateInformation(verification.first[0]);
try {
final String cn = information.getString("subject_cn");
- final Jid jid = Jid.fromString(address.getName());
+ final Jid jid = JidUtil.fromString(address.getName());
Log.d(Config.LOGTAG,"setting common name for "+jid+" to "+cn);
account.getRoster().getContact(jid).setCommonName(cn);
} catch (final InvalidJidException ignored) {
@@ -733,7 +734,7 @@ public class AxolotlServiceImpl implements OnAdvancedStreamFeaturesLoaded, Axolo
try {
IqPacket bundlesPacket = mXmppConnectionService.getIqGenerator().retrieveBundlesForDevice(
- Jid.fromString(address.getName()), address.getDeviceId());
+ JidUtil.fromString(address.getName()), address.getDeviceId());
Log.d(Config.LOGTAG, AxolotlServiceImpl.getLogprefix(account) + "Retrieving bundle: " + bundlesPacket);
mXmppConnectionService.sendIqPacket(account, bundlesPacket, new OnIqPacketReceived() {