Merge branch 'master' into development
This commit is contained in:
commit
9edcca1045
|
@ -101,6 +101,9 @@ public class ScramSha1 extends SaslMechanism {
|
||||||
public String getResponse(final String challenge) throws AuthenticationException {
|
public String getResponse(final String challenge) throws AuthenticationException {
|
||||||
switch (state) {
|
switch (state) {
|
||||||
case AUTH_TEXT_SENT:
|
case AUTH_TEXT_SENT:
|
||||||
|
if (challenge == null) {
|
||||||
|
throw new AuthenticationException("challenge can not be null");
|
||||||
|
}
|
||||||
serverFirstMessage = Base64.decode(challenge, Base64.DEFAULT);
|
serverFirstMessage = Base64.decode(challenge, Base64.DEFAULT);
|
||||||
final Tokenizer tokenizer = new Tokenizer(serverFirstMessage);
|
final Tokenizer tokenizer = new Tokenizer(serverFirstMessage);
|
||||||
String nonce = "";
|
String nonce = "";
|
||||||
|
|
|
@ -358,11 +358,7 @@ public class FileBackend {
|
||||||
file.delete();
|
file.delete();
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
} catch (FileNotFoundException e) {
|
} catch (IllegalArgumentException | IOException | NoSuchAlgorithmException e) {
|
||||||
return false;
|
|
||||||
} catch (IOException e) {
|
|
||||||
return false;
|
|
||||||
} catch (NoSuchAlgorithmException e) {
|
|
||||||
return false;
|
return false;
|
||||||
} finally {
|
} finally {
|
||||||
close(os);
|
close(os);
|
||||||
|
|
|
@ -150,7 +150,6 @@ public class XmppConnection implements Runnable {
|
||||||
shouldAuthenticate = shouldBind = !account.isOptionSet(Account.OPTION_REGISTER);
|
shouldAuthenticate = shouldBind = !account.isOptionSet(Account.OPTION_REGISTER);
|
||||||
tagReader = new XmlReader(wakeLock);
|
tagReader = new XmlReader(wakeLock);
|
||||||
tagWriter = new TagWriter();
|
tagWriter = new TagWriter();
|
||||||
packetCallbacks.clear();
|
|
||||||
this.changeStatus(Account.State.CONNECTING);
|
this.changeStatus(Account.State.CONNECTING);
|
||||||
if (DNSHelper.isIp(account.getServer().toString())) {
|
if (DNSHelper.isIp(account.getServer().toString())) {
|
||||||
socket = new Socket();
|
socket = new Socket();
|
||||||
|
@ -197,10 +196,7 @@ public class XmppConnection implements Runnable {
|
||||||
socket = new Socket();
|
socket = new Socket();
|
||||||
socket.connect(addr, Config.SOCKET_TIMEOUT * 1000);
|
socket.connect(addr, Config.SOCKET_TIMEOUT * 1000);
|
||||||
socketError = false;
|
socketError = false;
|
||||||
} catch (final UnknownHostException e) {
|
} catch (final Throwable e) {
|
||||||
Log.d(Config.LOGTAG, account.getJid().toBareJid().toString() + ": " + e.getMessage());
|
|
||||||
i++;
|
|
||||||
} catch (final IOException e) {
|
|
||||||
Log.d(Config.LOGTAG, account.getJid().toBareJid().toString() + ": " + e.getMessage());
|
Log.d(Config.LOGTAG, account.getJid().toBareJid().toString() + ": " + e.getMessage());
|
||||||
i++;
|
i++;
|
||||||
}
|
}
|
||||||
|
@ -470,6 +466,7 @@ public class XmppConnection implements Runnable {
|
||||||
this.jingleListener.onJinglePacketReceived(account,(JinglePacket) packet);
|
this.jingleListener.onJinglePacketReceived(account,(JinglePacket) packet);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
|
synchronized (this.packetCallbacks) {
|
||||||
if (packetCallbacks.containsKey(packet.getId())) {
|
if (packetCallbacks.containsKey(packet.getId())) {
|
||||||
final Pair<IqPacket, OnIqPacketReceived> packetCallbackDuple = packetCallbacks.get(packet.getId());
|
final Pair<IqPacket, OnIqPacketReceived> packetCallbackDuple = packetCallbacks.get(packet.getId());
|
||||||
// Packets to the server should have responses from the server
|
// Packets to the server should have responses from the server
|
||||||
|
@ -478,21 +475,22 @@ public class XmppConnection implements Runnable {
|
||||||
packetCallbackDuple.second.onIqPacketReceived(account, packet);
|
packetCallbackDuple.second.onIqPacketReceived(account, packet);
|
||||||
packetCallbacks.remove(packet.getId());
|
packetCallbacks.remove(packet.getId());
|
||||||
} else {
|
} else {
|
||||||
Log.e(Config.LOGTAG,account.getJid().toBareJid().toString()+": ignoring spoofed iq packet");
|
Log.e(Config.LOGTAG, account.getJid().toBareJid().toString() + ": ignoring spoofed iq packet");
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
if (packet.getFrom().equals(packetCallbackDuple.first.getTo())) {
|
if (packet.getFrom().equals(packetCallbackDuple.first.getTo())) {
|
||||||
packetCallbackDuple.second.onIqPacketReceived(account, packet);
|
packetCallbackDuple.second.onIqPacketReceived(account, packet);
|
||||||
packetCallbacks.remove(packet.getId());
|
packetCallbacks.remove(packet.getId());
|
||||||
} else {
|
} else {
|
||||||
Log.e(Config.LOGTAG,account.getJid().toBareJid().toString()+": ignoring spoofed iq packet");
|
Log.e(Config.LOGTAG, account.getJid().toBareJid().toString() + ": ignoring spoofed iq packet");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else if (packet.getType() == IqPacket.TYPE.GET|| packet.getType() == IqPacket.TYPE.SET) {
|
} else if (packet.getType() == IqPacket.TYPE.GET || packet.getType() == IqPacket.TYPE.SET) {
|
||||||
this.unregisteredIqListener.onIqPacketReceived(account, packet);
|
this.unregisteredIqListener.onIqPacketReceived(account, packet);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
private void processMessage(final Tag currentTag) throws XmlPullParserException, IOException {
|
private void processMessage(final Tag currentTag) throws XmlPullParserException, IOException {
|
||||||
final MessagePacket packet = (MessagePacket) processPacket(currentTag,PACKET_MESSAGE);
|
final MessagePacket packet = (MessagePacket) processPacket(currentTag,PACKET_MESSAGE);
|
||||||
|
@ -720,15 +718,17 @@ public class XmppConnection implements Runnable {
|
||||||
}
|
}
|
||||||
|
|
||||||
private void clearIqCallbacks() {
|
private void clearIqCallbacks() {
|
||||||
Log.d(Config.LOGTAG,account.getJid().toBareJid()+": clearing iq iq callbacks");
|
Log.d(Config.LOGTAG, account.getJid().toBareJid() + ": clearing iq iq callbacks");
|
||||||
final IqPacket failurePacket = new IqPacket(IqPacket.TYPE.ERROR);
|
final IqPacket failurePacket = new IqPacket(IqPacket.TYPE.ERROR);
|
||||||
|
synchronized (this.packetCallbacks) {
|
||||||
Iterator<Entry<String, Pair<IqPacket, OnIqPacketReceived>>> iterator = this.packetCallbacks.entrySet().iterator();
|
Iterator<Entry<String, Pair<IqPacket, OnIqPacketReceived>>> iterator = this.packetCallbacks.entrySet().iterator();
|
||||||
while(iterator.hasNext()) {
|
while (iterator.hasNext()) {
|
||||||
Entry<String, Pair<IqPacket, OnIqPacketReceived>> entry = iterator.next();
|
Entry<String, Pair<IqPacket, OnIqPacketReceived>> entry = iterator.next();
|
||||||
entry.getValue().second.onIqPacketReceived(account,failurePacket);
|
entry.getValue().second.onIqPacketReceived(account, failurePacket);
|
||||||
iterator.remove();
|
iterator.remove();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
private void sendStartSession() {
|
private void sendStartSession() {
|
||||||
final IqPacket startSession = new IqPacket(IqPacket.TYPE.SET);
|
final IqPacket startSession = new IqPacket(IqPacket.TYPE.SET);
|
||||||
|
@ -899,8 +899,10 @@ public class XmppConnection implements Runnable {
|
||||||
packet.setAttribute("id", id);
|
packet.setAttribute("id", id);
|
||||||
}
|
}
|
||||||
if (callback != null) {
|
if (callback != null) {
|
||||||
|
synchronized (this.packetCallbacks) {
|
||||||
packetCallbacks.put(packet.getId(), new Pair<>(packet, callback));
|
packetCallbacks.put(packet.getId(), new Pair<>(packet, callback));
|
||||||
}
|
}
|
||||||
|
}
|
||||||
this.sendPacket(packet);
|
this.sendPacket(packet);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue