Commit Graph

207 Commits

Author SHA1 Message Date
Florian Schmaus add4ff5b5a Fix PubSub namespaces
Those were broken since 9e797c1b17 as they
always used the basic PubSub namespace, i.e. without a fragment. Which
resulted in e.g. delete requests look like

<iq to="pubsub.ec-xmpp" id="2GAeW-75" type="set">
  <pubsub xmlns="http://jabber.org/protocol/pubsub">
    <delete node="2e92d38c-9e90-47f6-8e26-330d25ebe96b"/>
  </pubsub>
</iq>

when the namespace should be in fact

http://jabber.org/protocol/pubsub#owner
2014-12-17 13:34:49 +01:00
Florian Schmaus 84ffa265ce Rework SynchronizationPoint
- synchronize wasSuccessful() and requestSent()
- Add comment
- Clarify log message
2014-12-17 10:29:48 +01:00
Jae Jang d5c7a2cad3 Switch right bracket to left bracket on condition start tag.
StreamError toXML should output <..><cond>..</cond>,
not <..>>cond>..</cond>.
2014-12-10 23:15:14 +01:00
Florian Schmaus 8bfc887f63 Prefer AndroidDebugger over JulDebugger
since most JUL implementations do not print log messages of level
FINE (or lower) per default. Therefore the debugging output is not seen
by the user who wants to debug and a second step is required to
configure JUL to also log FINE or lower log messages to the console.
2014-12-10 14:00:36 +01:00
Florian Schmaus 7640414e8d Set conditionText to null if it's the empty string
This fixes e.g. IllegalArgumentException "'conflict' can not contain a
condition text", when receiving elements like

<stream:error>
  <conflict xmlns='urn:ietf:params:xml:ns:xmpp-streams'></conflict>
  <text xml:lang='' xmlns='urn:ietf:params:xml:ns:xmpp-streams'>
    Replaced by new connection
  </text>
</sream:error>

(ejabberd does this)
2014-12-10 12:36:35 +01:00
Florian Schmaus c89d06861b Use switch-case in PacketParserUtils.parseContentDepthWithoutRoundtrip() 2014-12-10 12:28:22 +01:00
Florian Schmaus 77f0fdc156 Add (IQ|PacketExtension)IntrospectionProvider
This simplifies code as there is no longer a distinction between
"normal" providers and introspection providers in ProviderManager
necessary.

It's also easier to get an idea where introspection is used for parsing.
2014-12-10 11:09:52 +01:00
Daniele Ricci 00f5008794 Consider also unavailable presences when dealing with the roster
This is needed for checking <delay/> extensions in unavailable
presence stanzas.

Signed-off-by: Daniele Ricci <daniele.athome@gmail.com>
2014-12-09 21:30:28 +01:00
Florian Schmaus c9bf420b37 Make Filters fields final and use StringUtils 2014-12-09 14:32:09 +01:00
Florian Schmaus 1c08d1c594 Remove PacketExtensionFilter(Class) constructor
as it's potential error prone, because most PacketExtension's don't
have a non-argument constructor required for this to work.

Also add some javadoc.
2014-12-09 14:32:09 +01:00
Florian Schmaus 05870e6a22 s/Unkown/Unknown/g 2014-12-09 13:23:01 +01:00
Florian Schmaus 187e158260 Improve OfflineMessages.getMessages()
poll the result before waiting for a message (with nextResult()), in
order to prevent waiting unnecessarily.

Add PacketCollector.pollResultOrThrow()
2014-12-07 23:43:26 +01:00
Florian Schmaus ba2df2a995 Add Message(String,String) 2014-12-01 14:40:58 +01:00
Florian Schmaus 252d5172e9 Return more specific types (e.g. Collection → List)
be generic as possible in what you accept, but more specific in what you
return.

Also tweak MultiuserChatManager methods a bit.
2014-11-29 13:41:49 +01:00
Florian Schmaus 9286a1decb Rework XMPP Error class design
Introduce AbstractError, change 'Conditions' to enums. Because of
AbstractError, it was necessary that PlainStreamElement and
TopLevelStreamElement becomes an interface. Thus the implementation of
TopLevelStreamElement.toString() had to be removed.

This adds

- policy-violation
- unexpected-request

to XMPPError.Condition, and removes the

- payment-required
- remote-server-error
- unexpected-condition
- request-timeout

Conditions

The file transfer code does now no longer throw XMPPErrorExceptions, but
SmackExceptions.

Fixes SMACK-608. Makes it possible to resolves SMACK-386.
2014-11-25 13:19:32 +01:00
Florian Schmaus cc09192095 Smack 4.0.6
-----BEGIN PGP SIGNATURE-----
 Version: GnuPG v2
 
 iQF8BAABCgBmBQJUci2fXxSAAAAAAC4AKGlzc3Vlci1mcHJAbm90YXRpb25zLm9w
 ZW5wZ3AuZmlmdGhob3JzZW1hbi5uZXQxMzU3QjAxODY1QjI1MDNDMTg0NTNEMjA4
 Q0FDMkE5Njc4NTQ4RTM1AAoJEIysKpZ4VI415IIH/j1eCvLIjNqNP6ytXdgomYY+
 j2i5KRHMv69La1JqtdmAeTeZfD13549s/66I5VUfegEfaADGUPr1NGrQKlb8lJBe
 YSqthMaQUybLBuCL9Lwg/3jE6s27GixRjW/Wip4ntac1wS2R3qD18lAxYIivsGJh
 gvyGHGoXvdct6teu9X0RtmyE/EOBfV63y1gVJG07Jv5/AJ2wCh9dIOD4jFuqvkoA
 cz2OfVJOIFletBV2psLxc0VVeqU9Lpba5TZuW1ZylY61z+X2rpt9BwCgBD35jTF9
 ztP2ytQY80+vZO6uP+Tl75QxdQd/e0O9oGnYbmMp1gfYQjgETaHUDxAL2uw4XNo=
 =7UY+
 -----END PGP SIGNATURE-----

Merge tag '4.0.6'

Smack 4.0.6

Conflicts:
	smack-core/src/main/java/org/jivesoftware/smack/util/DNSUtil.java
	smack-extensions/src/main/java/org/jivesoftware/smackx/caps/EntityCapsManager.java
	version.gradle
2014-11-23 20:05:44 +01:00
Florian Schmaus 255f7a1ad5 Add AbstractDebugger and JulDebugger
there was a lot of duplicate code in ConsoleDebugger and
AndroidDebugger, which resides now in AbstractDebugger. Those two and
the new JulDebugger subclass AbstractDebugger.
2014-11-21 18:36:26 +01:00
Florian Schmaus 6e569701b3 Add support for SASL X-OAUTH2 2014-11-20 18:50:33 +01:00
Florian Schmaus 646a4a6f90 Add support for SASL failure 'text' elements
- Also move toString() into TopLevelStreamElement.
- Fix SASLFailure toXML xmlnsAttribute(NAMESPACE)
- Improve SASLFailure parsing
- And introduce XmlUnitUtils
2014-11-19 09:57:39 +01:00
Florian Schmaus 5dd2bb5874 Log a warning if the server didn't report SASL mechanisms
and return the empty list.
2014-11-16 19:03:03 +01:00
Florian Schmaus 763f9c7c14 Implemented MD5 just like the SHA1 util 2014-11-15 09:46:39 +01:00
Florian Schmaus 0db76f4eb1 Throw a NotConnectedException on disconnect()
if not connected. For consistent behavior, so that it is always
thrown. Previously it may be thrown or not.
2014-11-15 09:46:39 +01:00
Florian Schmaus def8fea05f Add reply timeout to NoResponseException message 2014-11-15 09:46:38 +01:00
Florian Schmaus c81cd34561 Apply builder pattern to ConnectionConfiguration
Introducing a clean split between the constant connection configuration
parameters, which are now all in ConnectionConfiguration and the dynamic
connection state (e.g. hostAddresses) which are now in
AbstractXMPPConnection.

Also removed all arguments of login() since the username, password,
resource and callback handler need now to be configured via
ConnectionConfiguration.

Also remove documentation/extensions/messageevents.md, as it's already
in documentation/legacy
2014-11-15 09:46:31 +01:00
Florian Schmaus 4000adb70c Fallback to host if DNS SRV lookup fails
Also fix javadoc for DNSUtil, _jabber SRV records are no longer tried.

Fixes SMACK-616.
2014-11-10 21:21:44 +01:00
Florian Schmaus 9e797c1b17 Enable PacketExtensions for IQs
This is actually only part one, i.e. with this commit if the user adds a
PacketExtension to an IQ it will be included in IQ.toXml(). Which was
previously only the case if the IQ subclass explicitly included packet
extensions.

The second part of the change is to change the IQ provider, so that
packet extensions are automatically parsed.

Cases where PacketExtensions are used for Message and IQ are slightly
changed. The IQ sublcass now only has a field with this
PacketExtension (see for example
bytestreams.ibb.packet.DataPacketExtension).

Also changed hoxt API: Removed unnecessary indirection and made the
API more Smack idiomatic.
2014-11-10 11:43:18 +01:00
Florian Schmaus a9c798f3bb Remove empty statements 2014-11-09 18:31:07 +01:00
Florian Schmaus 77a4867450 Change Packet.getExtensionsXML()
Remove the synchronized, as getExtensions() is properly synchronized and will
return a copy.

Return XmlStringBuilder instead of CharSequence to take advantage of
fast XmlStringBuilder.append(XmlStringBuilder).

Mark the method as final, as it should not be overwritten.
2014-11-05 20:25:51 +01:00
Florian Schmaus 10643cce7c Use LinkedHashMap for PacketExtensions in Packet
to keep the order in which the elements are added.

Some XEPs define a Schema using 'xs:sequence' (see for example XEP-60 §
17.1), so the order the PacketExtensions are added should be the same
they are transformed to a XML String.
2014-11-05 17:58:32 +01:00
Florian Schmaus fe3dcba9b2 Fix javadoc warnings and deprecated methods 2014-11-02 12:12:56 +01:00
Florian Schmaus 5647cac39c Move is(Connected|Authenticated) and getUser()
into AbstractXMPPConnection.

Also remove wasAuthenticated field from XMPPBOSHConnection, it is
already in AbstractXMPPConnection.
2014-11-01 12:42:53 +01:00
Florian Schmaus c1aef37081 Undeprecate Packet.getExtension(String)
as there a valid uses for it, see for example ChatStateManager:173.
2014-10-31 17:12:24 +01:00
Florian Schmaus 5fcfe548f9 Validate ProviderManager arguments 2014-10-31 00:24:26 +01:00
Florian Schmaus 0408d075b7 Merge invokePacketCollectors() and notifiyReceivedListeners()
into invokePacketCollectorsAndNotifyRecvListeners()
2014-10-30 23:36:40 +01:00
Florian Schmaus 1de2fc2a81 Refactor Bind and Roster IQ parsing code into providers 2014-10-30 13:21:36 +01:00
Florian Schmaus 0e4196ae4b Added javadoc about extended content to PacketExtension 2014-10-30 13:21:36 +01:00
Florian Schmaus e88583d287 Use switch/case in 'IQ parse(XmlPullParser)' 2014-10-30 13:21:36 +01:00
Florian Schmaus b5daee3032 Include the full content in UnparsedResultIQ
In order to prevent

<iq to='...' from='...' type='result' id='1'>
  <mynode xmlns='my:namespace' myattr='...'>
    <somenode\>
  </mynode>
</iq>

showing up as UnparsedResultIQ like this:

<iq to='...' from='...' type='result' id='1'>
  <somenode\>
</iq>
2014-10-30 13:21:36 +01:00
Florian Schmaus e63fe22647 Add support for XEP-335: JSON Containers
and GCM JSON payloads for Google's GCM Cloud Connection Server.
2014-10-30 13:21:33 +01:00
Florian Schmaus ed66c838e1 Invoke PacketCollectors in ListenerNotification
Also make executorService a non-ScheduledExecutorService. This was an
artifact from times where executorService as used to schedule
Runnables. But now it's just used to queue the receive packets in
Runnables and call the packet collectors and listeners.
2014-10-29 19:38:45 +01:00
Florian Schmaus b73bb27463 Improve Packet javadoc 2014-10-29 14:05:38 +01:00
Florian Schmaus d60b63a89a Remove hashCode/equals from Message and Packet
Those where never correctly implemented and are not really used. If you
want to compare Packets, compare their toXML() result.

N.B. that we keep hashCode/equals for Message.(Subject|Body) because
those are correct and are in-use ('bodies' and 'subjects' are Sets in
Message).
2014-10-28 15:11:48 +01:00
Florian Schmaus 416f42deb7 Make fields in Packet and Message final 2014-10-28 15:11:48 +01:00
Florian Schmaus f94f7590a6 Store packet extensions in a HashMap
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).
2014-10-28 15:11:43 +01:00
Florian Schmaus 9f56842ee4 Notify packet sending listeners in new thread
sendListeners are now invoked *after* the packet has been put on the
wire.

Also sending listener exceptions are not catched and not only
NotConnectedExceptions. And a exception does not cause a 'break' but a
'continue' now. Log level is WARNING now.
2014-10-25 16:35:58 +02:00
Florian Schmaus 53bba50f91 Call pingServerIfNecessary in new thread
in order to prevent the BroadcastReceiver from timing out.

To prevent:

10-24 10:59:35.096 W/BroadcastQueue( 1044): Timeout of broadcast BroadcastRecord{43400df0 u0 org.igniterealtime.smackx.ping.ACTION} - receiver=android.os.BinderProxy@42d37cc0, started 60000ms ago
10-24 10:59:35.096 W/BroadcastQueue( 1044): Receiver during timeout: BroadcastFilter{42cee7b0 u0 ReceiverList{42cfd9f0 16003 org.projectmaxs.transport.xmpp/10149/u0 remote:42d37cc0}}

10-24 10:59:38.201 E/ActivityManager( 1044): ANR in org.projectmaxs.transport.xmpp
10-24 10:59:38.201 E/ActivityManager( 1044): PID: 16003
10-24 10:59:38.201 E/ActivityManager( 1044): Reason: Broadcast of Intent { act=org.igniterealtime.smackx.ping.ACTION flg=0x14 (has extras) }
10-24 10:59:38.201 E/ActivityManager( 1044): Load: 18.97 / 31.7 / 45.71
10-24 10:59:38.201 E/ActivityManager( 1044): CPU usage from 20588ms to 0ms ago:
10-24 10:59:38.201 E/ActivityManager( 1044):   0.4% 1044/system_server: 0.2% user + 0.1% kernel / faults: 188 minor 1 major
10-24 10:59:38.201 E/ActivityManager( 1044):   0.4% 9089/kworker/0:3: 0% user + 0.4% kernel
10-24 10:59:38.201 E/ActivityManager( 1044):   0.1% 1567/mpdecision: 0% user + 0.1% kernel
10-24 10:59:38.201 E/ActivityManager( 1044):   0.1% 28507/kworker/u:5: 0% user + 0.1% kernel
10-24 10:59:38.201 E/ActivityManager( 1044):   0% 7/kworker/u:0H: 0% user + 0% kernel
10-24 10:59:38.201 E/ActivityManager( 1044):   0% 148/mmcqd/0: 0% user + 0% kernel
10-24 10:59:38.201 E/ActivityManager( 1044):   0% 14687/com.teslacoilsw.launcher: 0% user + 0% kernel / faults: 6 minor
10-24 10:59:38.201 E/ActivityManager( 1044):   0% 3/ksoftirqd/0: 0% user + 0% kernel
10-24 10:59:38.201 E/ActivityManager( 1044):   0% 1111/MC_Thread: 0% user + 0% kernel
10-24 10:59:38.201 E/ActivityManager( 1044):   0% 1135/wpa_supplicant: 0% user + 0% kernel
10-24 10:59:38.201 E/ActivityManager( 1044):   0% 1283/com.android.phone: 0% user + 0% kernel
10-24 10:59:38.201 E/ActivityManager( 1044):   0% 11469/com.getpebble.android: 0% user + 0% kernel / faults: 1 minor
10-24 10:59:38.201 E/ActivityManager( 1044):   0% 14971/com.google.android.apps.unveil: 0% user + 0% kernel / faults: 6 minor
10-24 10:59:38.201 E/ActivityManager( 1044):   0% 28677/watch_server: 0% user + 0% kernel
10-24 10:59:38.201 E/ActivityManager( 1044):   0% 31539/kworker/0:2: 0% user + 0% kernel
10-24 10:59:38.201 E/ActivityManager( 1044): 1.2% TOTAL: 0.4% user + 0.5% kernel + 0.2% iowait
10-24 10:59:38.201 E/ActivityManager( 1044): CPU usage from 2536ms to 3060ms later:
10-24 10:59:38.201 E/ActivityManager( 1044):   9.2% 1044/system_server: 1.8% user + 7.4% kernel / faults: 56 minor
10-24 10:59:38.201 E/ActivityManager( 1044):     5.5% 1058/ActivityManager: 0% user + 5.5% kernel
10-24 10:59:38.201 E/ActivityManager( 1044):   1.3% 23415/kworker/0:1H: 0% user + 1.3% kernel
10-24 10:59:38.201 E/ActivityManager( 1044): 0% TOTAL: 0% user + 0% kernel + 0% iowait
10-24 10:59:38.208 I/ActivityManager( 1044): Killing 16003:org.projectmaxs.transport.xmpp/u0a149 (adj 0): background ANR
2014-10-24 11:45:28 +02:00
Florian Schmaus 10cca256c6 Remove unnecessary code in Message 2014-10-24 11:45:22 +02:00
Florian Schmaus ce8ccf3647 Make Message and Presence class final
In order to prevent users from trying to subclass those two, trying to
add their custom attributes (or attribute values) in the element of
those two, instead of using extension elements aka. PacketExtension.

See

- http://stackoverflow.com/q/26516386/
- http://stackoverflow.com/q/26507753/
- http://stackoverflow.com/q/26542601/
2014-10-24 11:14:41 +02:00
Florian Schmaus 403ecff2b2 Add SCRAM-SHA1 support
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
2014-10-21 15:03:48 +02:00
Florian Schmaus b348ebfd6d Make ProviderManager handle StreamFeatureProvider(s)
when a new ProviderLoader is added. This was previously missing.
2014-10-20 23:05:10 +02:00