allowing O(1) lookups for PacketExtensions
The one EntityCapsManagerTest becomes obsolete with this change, as
duplicate extension elements (RFC 6120 § 8.4) are now no longer possible
after the stanza has been parsed (they still may be received on the
wire, but only the last duplicate will be added).
Thanks to Stefan Karlsson for helping with the implementation.
Also add SASLMechanism.checkIfSuccessfulOrThrow(), to increase the
security by verifying the mechanisms state at the end of SASL
authentication.
SASLMechanism now has a SASLPrep StringTransformer.
Refactor SHA1 functions out of StringUtils into SHA1 utility class.
Add MAC utility class.
Make DummyConnection getSentpacket() methods use generics to make unit
testing SCRAM-SHA1 easier.
Fixes SMACK-398
Make sure that the Packets are of type Message. To prevent:
E/AbstractXMPPConnection﹕ Exception in packet listener
java.lang.ClassCastException: org.jivesoftware.smack.packet.Presence cannot be cast to org.jivesoftware.smack.packet.Message
at org.jivesoftware.smackx.muc.MultiUserChatManager$2.processPacket(MultiUserChatM anager.java:124)
at org.jivesoftware.smack.AbstractXMPPConnection.notifiyReceivedListeners(Abstract XMPPConnection.java:854)
at org.jivesoftware.smack.AbstractXMPPConnection$ListenerNotification.run(Abstract XMPPConnection.java:876)
at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:390)
at java.util.concurrent.FutureTask.run(FutureTask.java:234)
at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.access$201 (ScheduledThreadPoolExecutor.java:153)
at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.run(Schedu ledThreadPoolExecutor.java:267)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1080)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:573)
at java.lang.Thread.run(Thread.java:856)
I've got reports from users that in some cases there can be multiple
identities. Not just one, and in this case, the node type may not be the
first identity. We now iterate over all identities until we either found
one of type "leaf" or "collection".
For example one user reports an ejabberd with PEP case, where the first
identity is of type "pep", the second of type "leaf" and a third one
with category "account" and type "registered".
Also extend DiscoverInfo API with hasIdentity(String, String) and
getIdentities(String, String).
in AdHocCommandData.
This check was added in 3a37b71e19, but a
session ID can be null, if it's the first invocation. This prevented
RemoteCommand.execute() from executing, since RemoteCommand's sessionID
member will be null at the first invocation.
apply the Manager pattern to 'muc'. This prevents the user creating
multiple MultiUserChat instances for the same MUC.
Move the static method from MultiUserChat to MultiUserChatManager.
Also add AbstractNodeInformationProvider.
Use CopyOnWriteArraySet for listeners, remove the old reflection based
listener invocation approach.
Remove unnecessary casts.
Return List instead of Collection where possible.
sendMessage(Message) now set's the MUC as 'to' and the message type to
groupchat.
remove PacketMultiplexListener, RoomListenerMultiplexor and
ConnectionDetachedPacketCollector(Test), which was a bunch of
(in same cases redundant) code that formed a complex construct that
presumably tried to make MultiUserChat instances easily garbage
collect-able.
Now, MultiUserChat should be eligible for gc if the userHashLeft() is
invoked before the reference to the instance is dropped, which should be
the case in the most scenarios. Otherwise the connection may references
the MultiUserChat instance over Packet(Listener|Interceptor)s preventing
the gc.
Using
createPacketCollector(filter);
sendPacket(packet);
was error prone, i.e. the PacketCollector could leak if sendPacket()
would throw an exception and the user forgot to call
PacketCollector.cancel(). For cases where
createPacketCollectorAndSend(IQ) is not sufficient (because we don't
send IQs), createPacketCollectorAndSend(PacketFilter, Packet) is now
used, which does take care that the PacketCollector does not leak if
sendPacket() throws an Exception.
Use PresenceListener as intercepting callback interface.
Remove the for-each loops in MultiUserChat by using the interception
facilities of the XMPPConnection.
Add ToFilter.
both serve the same purpose: As callback for Packets. There is no need
to have both, so remace PacketInterceptor and let PacketListener take
its place. Some classes like ChatStateManager can now use
MessageListener as interceptor callback, which is more convenient.
instead of using a PacketListener, which means that the user has to
downcast the Packet to Message, we now use a Listener which callback
parameter is already Message/Presence.
It is necessary to introduce MessageListener and PresenceListener, which
are interfaces that have a callback for Message/Presence instead of
Packet. The 'old' MessageListener is renamed to ChatMessageListener.
Use Generics in ConnectionDetachedPacketCollector.
- Make MultipleAddress.Type a enum
- Change the signature of the methods to use Collection instead of List
- Use for-each loops instead of iterators
- Switch Provider to new provider pattern (using switch-case)
- Use XmlStringBuilder (extend the API by two new methods)
this is the first stop towards fixing "SMACK-65: parsing should look for
depth", by providing the initial parsing depth to the provider. Some
methods (.e.g parseMessage) now use the depth as abort condition,
instead of a unclean String equals check.
parseIQ() and parseExtension() where both renamed to parse.
This also restricts the Exceptions thrown by the parse method, to just
XmlPullParserException, IOException and SmackException (not really a big
victory, but nevertheless a slight improvement).
StreamFeatureProvider is now gone, we simply use PacketExtensionProvider
for stream features.
also remove 'lang' attribute, since it belongs into IQ, see XEP-50 3.7:
"The requester SHOULD provide its locale information using the "xml:lang"
attribute on either the <iq/> (RECOMMENDED) or <command/> element."
- De-duplicate code by moving it into AbstractXMPPConnection
- Introduce TopLevelStreamElement as superclass for all XMPP stream elements.
- Add SynchronizationPoint, ParserUtils
- Add ParserUtils
Fixes SMACK-333 and SMACK-521
let's use the standard idiom for Input- to OutputStream transfers. This
also avoids an initial no-op on the first write, when the count is '0'.
Also fixes a bug when the size of file/stream transferred is '0' (which
is perfectly fine and possible).
which is basically the body of the pingServerRunnable available as
public part of the API. The intention is to allow 3rd party
components (e.g. Android's AlarmManager) to trigger the code.
The Pong class was harmful, as people could try to use it with
PacketTypeFilter, which wouldn't work, a Pong is just a plain IQ result
without child XML.
also remove faulty PongFilter from PingManager. It never matched any
stanzas, since a Pong is just a plain result IQ that is not qualified by
any XMPP Ping namespace.
Fixes SMACK-597
- determine all local IPv4 and IPv6 addresses
- prevent loopback addresses from appearing as streamhost
Some unit tests where changed because they assumed that a host only has
one local address. But nowadays hosts often have more, at least because
they are IPv4 and IPv6 multi-homed.
to prevent
org.jivesoftware.smackx.bytestreams.socks5.Socks5ClientForInitiatorTest
> shouldSuccessfullyEstablishConnectionAndActivateSocks5Proxy
FAILED
java.lang.NullPointerException at Socks5ClientForInitiatorTest.java:292
This will help to get rid of repetitive class casts, and make
PacketCollector api more inline with itself (since some methods
are already generic return methods).
to avoid
feature-not-implemented
at org.jivesoftware.smack.PacketCollector.nextResultOrThrow(PacketCollector.java:182)
at org.jivesoftware.smack.PacketCollector.nextResultOrThrow(PacketCollector.java:161)
at org.jivesoftware.smackx.disco.ServiceDiscoveryManager.discoverItems(ServiceDiscoveryManager.java:573)
at org.jivesoftware.smackx.address.MultipleRecipientManager.getMultipleRecipienServiceAddress(MultipleRecipientManager.java:310)
at org.jivesoftware.smackx.address.MultipleRecipientManager.send$7a184d34(MultipleRecipientManager.java:82)
for e.g. Google Apps XMPP services.
This is not to be merged in master/4.1 branch as it already contains a
similar fix.
Similar flaw was also fixed in 2c7f1efe80.
Also ensure that OfflineMessagesManager doesn't leak collector by using
a try/finally block.
Fixes SMACK-592
It's a common pattern to look for all services hosted under the users
service that provide a given feature. Let's provide an API for that and
use that API in the methods that benefit from it.